Skip to content

Commit

Permalink
fix: arm64/x64 inputs may contain universal binaries that are not the…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
koush authored Jun 25, 2023
1 parent b02ce76 commit fddff57
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/asar-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const MACHO_MAGIC = new Set([
0xcffaedfe,
]);

const MACHO_UNIVERSAL_MAGIC = new Set([
// universal
0xcafebabe,
0xbebafeca,
]);

export const detectAsarMode = async (appPath: string) => {
d('checking asar mode of', appPath);
const asarPath = path.resolve(appPath, 'Contents', 'Resources', 'app.asar');
Expand Down Expand Up @@ -147,6 +153,10 @@ export const mergeASARs = async ({
continue;
}

if (MACHO_UNIVERSAL_MAGIC.has(x64Content.readUInt32LE(0)) && MACHO_UNIVERSAL_MAGIC.has(arm64Content.readUInt32LE(0))) {
continue;
}

if (!MACHO_MAGIC.has(x64Content.readUInt32LE(0))) {
throw new Error(`Can't reconcile two non-macho files ${file}`);
}
Expand Down

0 comments on commit fddff57

Please sign in to comment.