Skip to content
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

build.productName = 'Å' causes mac / dmg build to fail #4840

Closed
olipo186 opened this issue Apr 2, 2020 · 0 comments · Fixed by #4841
Closed

build.productName = 'Å' causes mac / dmg build to fail #4840

olipo186 opened this issue Apr 2, 2020 · 0 comments · Fixed by #4841

Comments

@olipo186
Copy link
Contributor

olipo186 commented Apr 2, 2020

  • Version: 22.4.1
  • Electron Version: 8.2.0
  • Electron Type (current, beta, nightly): current
  • Target: Mac / dmg

Problem

When building dmg files for apps that use some specific characters in their productName (for example "Å") - electron-builder fails due to an error in the python package mac_alias (hard copy stored here), which is a dependency of dmg-builder.

This problem occurs when mac_alias reads the path of the newly mounted dmg volume ("/Volumes/Å") using libc statfs in OSX (here is where it happens). The file path that is returned (which is used here) is a unicode NFD string, which is incompatible with other unicode strings used in mac_alias that are in the NFC format. When comparing NFD strings with NFC strings to calculate file paths, things go wrong which leads to this error.

Steps to reproduce

  1. Clone the project https://github.com/chentsulin/electron-react-boilerplate
  2. Modify package.json to reference the latest versions of electron and electron-builder
"electron": "^8.2.0",
"electron-builder": "^22.4.1",
  1. Add the following to package.json to make sure only dmg is built for mac
  "build": {
   ...
    "mac": {
      "target": "dmg"
    },
    ...
  1. Modify build.productName in package.json to "Å"
  "build": {
    ...
    "productName": "Å",
  1. Run npm install
  2. Run npm run package

Expected result

Success

Actual result

Failure:

  • building        target=DMG arch=x64 file=release/Å-1.1.0.dmg
  ⨯ Exit code: 1. Command failed: /usr/bin/python /Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/dmgbuild/core.py
Traceback (most recent call last):
  File "/Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/dmgbuild/core.py", line 282, in <module>
    build_dmg()
  File "/Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/dmgbuild/core.py", line 253, in build_dmg
    icvp['backgroundImageAlias'] = biplist.Data(alias.to_bytes())
  File "/Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/mac_alias/alias.py", line 589, in to_bytes
    self._to_fd(b)
  File "/Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/mac_alias/alias.py", line 476, in _to_fd
    *self.target.cnid_path)
struct.error: 'I' format requires 0 <= number <= 4294967295

Traceback (most recent call last):
  File "/Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/dmgbuild/core.py", line 282, in <module>
    build_dmg()
  File "/Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/dmgbuild/core.py", line 253, in build_dmg
    icvp['backgroundImageAlias'] = biplist.Data(alias.to_bytes())
  File "/Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/mac_alias/alias.py", line 589, in to_bytes
    self._to_fd(b)
  File "/Users/inera/Repositories/electron-react-boilerplate/node_modules/dmg-builder/vendor/mac_alias/alias.py", line 476, in _to_fd
    *self.target.cnid_path)
struct.error: 'I' format requires 0 <= number <= 4294967295
  stackTrace=

Solution

In alias.py on line 13, add:

from unicodedata import normalize

In alias.py on line 347, replace

vol_path = st.f_mntonname

with

vol_path = st.f_mntonname

# File and folder names in HFS+ are normalized to a form similar to NFD.
# Must be normalized (NFD->NFC) before use to avoid unicode string comparison issues.
vol_path = normalize("NFC", vol_path.decode('utf-8')).encode('utf-8')

The same issue have been posted on dmgbuild/mac_alias#6 which I think is where you have copied your code from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant