Skip to content

Commit fddff57

Browse files
authored
fix: arm64/x64 inputs may contain universal binaries that are not the same (#62)
* Mach-O types are in big endian format One of my dependencies for some reason has two universal binaries per platform, and they are not exactly the same bytewise. I'm unsure why. But I am certain they are functional. In any case, this error is erroneously being thrown since it fails the previous byte comparison match. ```ts throw new Error(`Can't reconcile two non-macho files ${file}`); ``` CAFEBABE and FEEDFACE magics for universal binaries. This will allow packaging to continue if both the arm and x64 packages have universal binaries. * Update asar-utils.ts * Update asar-utils.ts
1 parent b02ce76 commit fddff57

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/asar-utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ const MACHO_MAGIC = new Set([
3333
0xcffaedfe,
3434
]);
3535

36+
const MACHO_UNIVERSAL_MAGIC = new Set([
37+
// universal
38+
0xcafebabe,
39+
0xbebafeca,
40+
]);
41+
3642
export const detectAsarMode = async (appPath: string) => {
3743
d('checking asar mode of', appPath);
3844
const asarPath = path.resolve(appPath, 'Contents', 'Resources', 'app.asar');
@@ -147,6 +153,10 @@ export const mergeASARs = async ({
147153
continue;
148154
}
149155

156+
if (MACHO_UNIVERSAL_MAGIC.has(x64Content.readUInt32LE(0)) && MACHO_UNIVERSAL_MAGIC.has(arm64Content.readUInt32LE(0))) {
157+
continue;
158+
}
159+
150160
if (!MACHO_MAGIC.has(x64Content.readUInt32LE(0))) {
151161
throw new Error(`Can't reconcile two non-macho files ${file}`);
152162
}

0 commit comments

Comments
 (0)