From f0a14099a1171330c6d338644d6590dfe07089c8 Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Sat, 28 Nov 2026 14:55:50 +0100 Subject: [PATCH] Normalize generated central pack licence line endings --- tools/build-central-resource-pack.mjs | 9 ++++++--- tools/build-planet-texture-packs.test.mjs | 21 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tools/build-central-resource-pack.mjs b/tools/build-central-resource-pack.mjs index 57e72e3f..bd883b18 100644 --- a/tools/build-central-resource-pack.mjs +++ b/tools/build-central-resource-pack.mjs @@ -8,6 +8,7 @@ import {profiles,textureEntries,zip} from './build-planet-texture-packs.mjs'; const texturePrefix='assets/minecraft/textures/'; const packPrefix='assets/dunerealms/textures/planets/'; const blocksAtlas='assets/minecraft/atlases/blocks.json'; +const generatedLicenceText=new Set(['CREDITS-Sand.txt','LICENSE-Sand-Luanti.txt']); const cubeItems=fs.readFileSync(new URL('../JarvisConnector/src/main/resources/planet-cube-items.txt',import.meta.url),'utf8') .split(/\r?\n/).map(line=>line.trim()).filter(Boolean); if(new Set(cubeItems).size!==cubeItems.length||cubeItems.some(item=>!/^[a-z0-9_]+$/.test(item)))throw Error('Invalid planet cube item catalogue'); @@ -19,7 +20,7 @@ function addEntry(entries,name,bytes){ entries.set(name,bytes); } -export function centralPackEntries(base){ +export function centralPackEntries(base,planetEntries=textureEntries){ const merged=new Map(base); if(!merged.has('pack.mcmeta'))throw Error('The base must be an extracted network resource pack'); const packInfo=JSON.parse(merged.get('pack.mcmeta')); @@ -29,12 +30,14 @@ export function centralPackEntries(base){ const sprites=new Map(atlas.sources.filter(source=>source.type==='single'||source.type==='minecraft:single') .map(source=>[source.sprite??source.resource,source.resource])); for(const planet of Object.keys(profiles)){ - for(const [name,bytes] of textureEntries(planet)){ + for(const [name,bytes] of planetEntries(planet)){ if(name==='pack.mcmeta')continue; const target=name.startsWith(texturePrefix) ?packPrefix+planet+'/'+name.slice(texturePrefix.length) :'licenses/planet-materials/'+name; - addEntry(merged,target,bytes); + // The standalone planet archives retain their existing published checksums. + const content=generatedLicenceText.has(name)?Buffer.from(bytes.toString('utf8').replaceAll('\r\n','\n')):bytes; + addEntry(merged,target,content); } for(const material of cubeItems){ const id=planet+'/'+material; diff --git a/tools/build-planet-texture-packs.test.mjs b/tools/build-planet-texture-packs.test.mjs index 9ab8c439..aeef799b 100644 --- a/tools/build-planet-texture-packs.test.mjs +++ b/tools/build-planet-texture-packs.test.mjs @@ -5,7 +5,7 @@ import {createHash} from 'node:crypto'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; -import {build,profiles,textureEntries,protectedTextures} from './build-planet-texture-packs.mjs'; +import {build,profiles,textureEntries,protectedTextures,zip} from './build-planet-texture-packs.mjs'; import {sandPalettes} from './flat-sand.mjs'; import {centralPackEntries} from './build-central-resource-pack.mjs'; @@ -114,3 +114,22 @@ test('the central builder preserves compatible common runtime assets and leaves assert(!entries.has('assets/minecraft/textures/block/stone.png')); assert(entries.has('assets/dunerealms/textures/planets/arrakis/block/stone.png')); }); + +test('central generated licence text has identical ZIP bytes for Windows and LF inputs',()=>{ + const inherited=Buffer.from('Production attribution\r\nKeep verbatim\r\n'); + const base=new Map([ + ['pack.mcmeta',Buffer.from(JSON.stringify({pack:{pack_format:64}}))], + ['CREDITS-Sand.txt',inherited], + ['LICENSE-Sand-Luanti.txt',inherited] + ]); + const names=['CREDITS-Sand.txt','LICENSE-Sand-Luanti.txt']; + const text='Copyright © 2026\nTerms remain intact.\n'; + const fixture=eol=>()=>new Map(names.map(name=>[name,Buffer.from(text.replaceAll('\n',eol))])); + const windows=centralPackEntries(base,fixture('\r\n')); + const linux=centralPackEntries(base,fixture('\n')); + assert.deepEqual(zip(windows),zip(linux)); + for(const name of names){ + assert.deepEqual(windows.get(name),inherited); + assert.equal(windows.get('licenses/planet-materials/'+name).toString('utf8'),text); + } +});