ReviewOS

also looking at this

craft-native/craft

fix(packaging): stop macOS packages relocating themselves elsewhere

#46
Merged glennmichael123 wants to merge fix/pkg-bundle-relocation into main
4 files +164 -16
scripts/native-lifecycle.tsmodified+11-0
Changes to scripts/native-lifecycle.ts
@@ -155,10 +155,21 @@ async function exerciseMacOS(v1: PackageResult[], v2: PackageResult[]): Promise<
155155 const second = requireArtifact(v2, 'pkg')
156156 const app = '/Applications/craft-lifecycle.app'
157157 const executable = join(app, 'Contents', 'MacOS', 'craft-lifecycle')
158 // `installer` can report success and put the payload somewhere else entirely:
159 // a package built with bundle relocation enabled is redirected to wherever the
160 // system already has that bundle identifier registered. When that happened
161 // here the only symptom was `launch` throwing ENOENT, which says nothing about
162 // where the app went. The receipt does — `location:` is the path the payload
163 // actually landed at — so record it as its own step, into report.json and the
164 // uploaded evidence, every time.
165 const receipt = (label: string) => command(`receipt after ${label}`, ['pkgutil', '--pkg-info', 'dev.craft.lifecycle'])
166
158167 if (existsSync(app)) await command('remove pre-existing fixture', ['sudo', 'rm', '-rf', app])
159168 await command('install v1', ['sudo', 'installer', '-pkg', first, '-target', '/'])
169 await receipt('install v1')
160170 await command('launch v1', [executable], 'craft-lifecycle 1.0.0')
161171 await command('update to v2', ['sudo', 'installer', '-pkg', second, '-target', '/'])
172 await receipt('update to v2')
162173 await command('launch v2', [executable], 'craft-lifecycle 1.0.1')
163174 for (const step of macOSRollbackPlan(app, 'dev.craft.lifecycle', first))
164175 await command(step.name, step.argv)