Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Commit

Permalink
Fix App Lock is not working on macOS ARM64 (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
quanglam2807 authored Mar 12, 2021
1 parent 3bd3974 commit 8c8a140
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 99 deletions.
1 change: 1 addition & 0 deletions .github/workflows/macos-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: bash build-keytar-arm64.sh
# https://github.com/mui-org/material-ui/issues/12432
- run: yarn --prefer-offline --network-timeout 600000
- run: yarn lint
Expand Down
49 changes: 49 additions & 0 deletions build-keytar-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# set -euox pipefail

# This whole script is a huge hack. There's an issue in keytar
# https://github.com/atom/node-keytar/issues/346, actually seems more like an
# issue in node prebuild with the combination of Electron, which causes x86_64
# keytar.node to end up in app-amd64.asar, when building a universal macOS app.
#
# In order to mitigate the issue, we compile keytar manually, tarball it, and
# put in the cache directory where npm rebuild will be looking for it.

# Prepare variables
ELECTRON_VERSION=$(yarn list electron | grep "electron@.*" | sed 's/^.*electron@//' | sed 's/^[ \t]*//;s/[ \t]*$//')
echo $ELECTRON_VERSION
KEYTAR_OUT=build/Release/keytar.node
ABI=$(node -p "require('node-abi').getAbi('$ELECTRON_VERSION', 'electron')")
KEYTAR_VERSION=$(npm ls keytar | grep "keytar@.*" | sed 's/^.*keytar@//'| sed 's/^[ \t]*//;s/[ \t]*$//')
KEYTAR_TAR_NAME="keytar-v$KEYTAR_VERSION-electron-v$ABI-darwin-arm64.tar.gz"
# npm prebuild-install prepends the filename with a short digest of the download URL
# * https://github.com/prebuild/prebuild/blob/master/util.js#L6
# * https://github.com/prebuild/prebuild-install/blob/master/util.js#L72
DIGEST=$(md5 -qs "https://github.com/atom/node-keytar/releases/download/v$KEYTAR_VERSION/$KEYTAR_TAR_NAME")
DIGEST=${DIGEST:0:6}
PREBUILDS_CACHE_DIR=$(npm config get cache)"/_prebuilds"

cd node_modules/keytar

# Cleanup existing build artefacts just in case
rm -rf build/Release prebuilds

# Compile keytar using node-gyp directly
SDKROOT=macosx npx node-gyp rebuild \
--arch=arm64 \
--runtime=electron \
--dist-url=https://atom.io/download/electron \
--target="$ELECTRON_VERSION" \
--build_v8_with_gn=false

# Check the arch, should be arm64
lipo -archs $KEYTAR_OUT

# create tar
mkdir -p "$PREBUILDS_CACHE_DIR"
tar -zcvf "$PREBUILDS_CACHE_DIR/$DIGEST-$KEYTAR_TAR_NAME" $KEYTAR_OUT

# Should contain cached keytar prebuild
ls -la "$PREBUILDS_CACHE_DIR"/*keytar-v"$KEYTAR_VERSION"*

cd ../..
99 changes: 0 additions & 99 deletions public/open-source-notices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4391,31 +4391,6 @@ THE SOFTWARE.

-----

The following software may be included in this product: ast-types. A copy of the source code may be downloaded from git://github.com/benjamn/ast-types.git. This software contains the following license and notice below:

Copyright (c) 2013 Ben Newman <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-----

The following software may be included in this product: astral-regex, dir-glob, npm-conf, shebang-command. A copy of the source code may be downloaded from https://github.com/kevva/astral-regex.git (astral-regex), https://github.com/kevva/dir-glob.git (dir-glob), https://github.com/kevva/npm-conf.git (npm-conf), https://github.com/kevva/shebang-command.git (shebang-command). This software contains the following license and notice below:

MIT License
Expand Down Expand Up @@ -12202,30 +12177,6 @@ THE SOFTWARE.

-----

The following software may be included in this product: ftp. A copy of the source code may be downloaded from http://github.com/mscdex/node-ftp.git. This software contains the following license and notice below:

Copyright Brian White. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

-----

The following software may be included in this product: function-bind. A copy of the source code may be downloaded from git://github.com/Raynos/function-bind.git. This software contains the following license and notice below:

Copyright (c) 2013 Raynos.
Expand Down Expand Up @@ -18323,31 +18274,6 @@ SOFTWARE.

-----

The following software may be included in this product: proxy-from-env. A copy of the source code may be downloaded from https://github.com/Rob--W/proxy-from-env.git. This software contains the following license and notice below:

The MIT License

Copyright (C) 2016-2018 Rob Wu <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-----

The following software may be included in this product: prr. A copy of the source code may be downloaded from https://github.com/rvagg/prr.git. This software contains the following license and notice below:

The MIT License (MIT)
Expand Down Expand Up @@ -20473,31 +20399,6 @@ THE SOFTWARE.

-----

The following software may be included in this product: socks. A copy of the source code may be downloaded from https://github.com/JoshGlazebrook/socks.git. This software contains the following license and notice below:

The MIT License (MIT)

Copyright (c) 2013 Josh Glazebrook

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-----

The following software may be included in this product: sort-keys-length. A copy of the source code may be downloaded from https://github.com/kevva/sort-keys-length.git. This software contains the following license and notice below:

Copyright (c) Kevin Mårtensson
Expand Down

0 comments on commit 8c8a140

Please sign in to comment.