mac build: rm pyinstaller monkey-patch used to codesign embedded files
When the monkey-patch was added, we were building pyinstaller onefile binaries; but since then we changed to build pyinstaller onedir binaries instead. So I believe there are no embedded files inside the main executable anymore, so doing `codesign --deep *.app` (near the end of make_osx) should be sufficient.
This commit is contained in:
@@ -161,7 +161,7 @@ find . -exec touch -t '200101220000' {} + || true
|
|||||||
VERSION=`git describe --tags --dirty --always`
|
VERSION=`git describe --tags --dirty --always`
|
||||||
|
|
||||||
info "Building binary"
|
info "Building binary"
|
||||||
APP_SIGN="$CODESIGN_CERT" pyinstaller --noconfirm --ascii --clean --name $VERSION contrib/osx/osx.spec || fail "Could not build binary"
|
pyinstaller --noconfirm --ascii --clean --name $VERSION contrib/osx/osx.spec || fail "Could not build binary"
|
||||||
|
|
||||||
info "Adding bitcoin URI types to Info.plist"
|
info "Adding bitcoin URI types to Info.plist"
|
||||||
plutil -insert 'CFBundleURLTypes' \
|
plutil -insert 'CFBundleURLTypes' \
|
||||||
|
|||||||
@@ -8,43 +8,6 @@ PACKAGE='Electrum'
|
|||||||
PYPKG='electrum'
|
PYPKG='electrum'
|
||||||
MAIN_SCRIPT='run_electrum'
|
MAIN_SCRIPT='run_electrum'
|
||||||
ICONS_FILE=PYPKG + '/gui/icons/electrum.icns'
|
ICONS_FILE=PYPKG + '/gui/icons/electrum.icns'
|
||||||
APP_SIGN = os.environ.get('APP_SIGN', '')
|
|
||||||
|
|
||||||
def fail(*msg):
|
|
||||||
RED='\033[0;31m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
print("\r🗯 {}ERROR:{}".format(RED, NC), *msg)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def codesign(identity, binary):
|
|
||||||
d = os.path.dirname(binary)
|
|
||||||
saved_dir=None
|
|
||||||
if d:
|
|
||||||
# switch to directory of the binary so codesign verbose messages don't include long path
|
|
||||||
saved_dir = os.path.abspath(os.path.curdir)
|
|
||||||
os.chdir(d)
|
|
||||||
binary = os.path.basename(binary)
|
|
||||||
os.system("codesign -v -f -s '{}' '{}'".format(identity, binary))==0 or fail("Could not code sign " + binary)
|
|
||||||
if saved_dir:
|
|
||||||
os.chdir(saved_dir)
|
|
||||||
|
|
||||||
def monkey_patch_pyinstaller_for_codesigning(identity):
|
|
||||||
# Monkey-patch PyInstaller so that we app-sign all binaries *after* they are modified by PyInstaller
|
|
||||||
# If we app-sign before that point, the signature will be invalid because PyInstaller modifies
|
|
||||||
# @loader_path in the Mach-O loader table.
|
|
||||||
try:
|
|
||||||
import PyInstaller.depend.dylib
|
|
||||||
_saved_func = PyInstaller.depend.dylib.mac_set_relative_dylib_deps
|
|
||||||
except (ImportError, NameError, AttributeError):
|
|
||||||
# Hmm. Likely wrong PyInstaller version.
|
|
||||||
fail("Could not monkey-patch PyInstaller for code signing. Please ensure that you are using PyInstaller 3.4.")
|
|
||||||
_signed = set()
|
|
||||||
def my_func(fn, distname):
|
|
||||||
_saved_func(fn, distname)
|
|
||||||
if (fn, distname) not in _signed:
|
|
||||||
codesign(identity, fn)
|
|
||||||
_signed.add((fn,distname)) # remember we signed it so we don't sign again
|
|
||||||
PyInstaller.depend.dylib.mac_set_relative_dylib_deps = my_func
|
|
||||||
|
|
||||||
|
|
||||||
for i, x in enumerate(sys.argv):
|
for i, x in enumerate(sys.argv):
|
||||||
@@ -133,10 +96,6 @@ for x in a.binaries.copy():
|
|||||||
a.binaries.remove(x)
|
a.binaries.remove(x)
|
||||||
print('----> Removed x =', x)
|
print('----> Removed x =', x)
|
||||||
|
|
||||||
# If code signing, monkey-patch in a code signing step to pyinstaller. See: https://github.com/spesmilo/electrum/issues/4994
|
|
||||||
if APP_SIGN:
|
|
||||||
monkey_patch_pyinstaller_for_codesigning(APP_SIGN)
|
|
||||||
|
|
||||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||||
|
|
||||||
exe = EXE(
|
exe = EXE(
|
||||||
|
|||||||
Reference in New Issue
Block a user