-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Respect unpack minimatch for symlinks within previously unpacked directories #341
base: main
Are you sure you want to change the base?
Conversation
… previously unpacked directories. This directly fixes unpacking static `.framework` modules on Mac, as otherwise codesigning will fail due to symlink files/directories not being reflected in the app.asar.unpacked directory. Added unit test with Hello.framework, generated from tutorial https://jano.dev/apple/mach-o/2024/06/28/Hello-Static-Framework.html Fixes: electron-userland/electron-builder#8655
prettier
change readlinkSync to realpathSync for windows OS
…mmaietta/asar into fix/static-framework-symlinks-2
b98871b
to
888ef4f
Compare
const link = await fs.readlink(file.filename); | ||
await fs.symlink(link, path.join(`${dest}.unpacked`, filename)).catch(async (error) => { | ||
if (error.code === 'EPERM' && error.syscall === 'symlink') { | ||
throw new Error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows, using junction to create symlinks should avoid permission issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great callout. I read somewhere (can't find the link atm) that junctions are absolute links, as opposed to a "pointer" relative path. If so, we don't want absolute links between folders in the unpacked folder, otherwise I don't think the asar will work on other computers.
test/cli-spec.js
Outdated
.endsWith('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Versions/A/Headers'), | ||
); | ||
} else { | ||
assert.ok( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After git cloning on Windows, SymlinkedDir is not a symlink but rather a regular file. I suggest only testing this on macOS/Linux. No need to test on Windows since you're not handling symlink in window.
https://github.com/mmaietta/asar/blob/1676a0ea070967f818167164be5bf7d0e378fb41/src/disk.ts#L65-L68
Summary:
Fixes issue with unpack configuration when considering symlinks within previously unpacked directories. This directly fixes unpacking static
.framework
modules on Mac, as otherwise codesigning will fail due to symlink files/directories not being reflected in the app.asar.unpacked directory.Fix:
unpacked
flag asnode.unpacked=true
symlink
andreadlink
Hello.framework
for mac/linux symlink verificationAdded unit test with Hello.framework, generated from HelloWorld tutorial https://jano.dev/apple/mach-o/2024/06/28/Hello-Static-Framework.html
Note: This implementation is isolated to mac/linux. It seems symlinks created on Windows (
mklink
) do not get properly committed to git, they seem to be committed as an actual file and I couldn't figure out whyDetails:
.framework
has to have all symlinks reproduced in the unpacked directory for signing. The top is with electron/asar unpacked folder, the bottom is the actual framework contents.Without this PR, codesigning will fail with
QtCore.framework: bundle format unrecognized, invalid, or unsuitable
Fixes: electron-userland/electron-builder#8655 (comment)