Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/android/buildozer_qml.spec
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ source.exclude_patterns = Makefile,setup*,
packages/frozenlist-*.dist-info/*

# (str) Application versioning (method 1)
version.regex = ELECTRUM_VERSION = '(.*)'
version.filename = %(source.dir)s/electrum/version.py
#version.regex = ELECTRUM_VERSION = '(.*)'
#version.filename = %(source.dir)s/electrum/version.py

# (str) Application versioning (method 2)
#version = 1.9.8
Expand Down
3 changes: 3 additions & 0 deletions contrib/android/make_apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ PACKAGES="$PROJECT_ROOT"/packages/

git -C "$PROJECT_ROOT" rev-parse 2>/dev/null || fail "Building outside a git clone is not supported."

VERSIONC=$("$CONTRIB"/print_electrum_version.py --with-commit)
info "VERSIONC: $VERSIONC"
export APP_VERSION="$VERSIONC"

# arguments have been checked in build.sh
export ELEC_APK_GUI=$1
Expand Down
8 changes: 5 additions & 3 deletions contrib/build-linux/appimage/make_appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ PYTHON_VERSION=3.12.13
PY_VER_MAJOR="3.12" # as it appears in fs paths
PKG2APPIMAGE_COMMIT="a9c85b7e61a3a883f4a35c41c5decb5af88b6b5d"

VERSION=$(git describe --tags --dirty --always)
APPIMAGE="$DISTDIR/electrum-$VERSION-x86_64.AppImage"
VERSIONB=$("$CONTRIB"/print_electrum_version.py)
VERSIONC=$("$CONTRIB"/print_electrum_version.py --with-commit)

APPIMAGE="$DISTDIR/electrum-$VERSIONC-x86_64.AppImage"

rm -rf "$BUILDDIR"
mkdir -p "$APPDIR" "$CACHEDIR" "$PIP_CACHE_DIR" "$DISTDIR" "$DLL_TARGET_DIR"
Expand Down Expand Up @@ -271,7 +273,7 @@ args=\$(echo "\$@" | sed -e 's/-mkfs-time 0//')
"$BUILDDIR/squashfs-root/usr/bin/mksquashfs_orig" \$args
EOF
chmod +x "$BUILDDIR/squashfs-root/usr/bin/mksquashfs"
env VERSION="$VERSION" ARCH=x86_64 ./squashfs-root/AppRun --runtime-file "$TYPE2_RUNTIME_REPO_DIR/runtime-x86_64" --no-appstream --verbose "$APPDIR" "$APPIMAGE"
env VERSION="$VERSIONB" ARCH=x86_64 ./squashfs-root/AppRun --runtime-file "$TYPE2_RUNTIME_REPO_DIR/runtime-x86_64" --no-appstream --verbose "$APPDIR" "$APPIMAGE"
)


Expand Down
15 changes: 10 additions & 5 deletions contrib/build-linux/sdist/make_sdist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ info "preparing electrum-locale."
# build initial tar.gz
python3 setup.py --quiet sdist --format=gztar --dist-dir="$PY_DISTDIR"

VERSION=$("$CONTRIB"/print_electrum_version.py)
VERSIONB=$("$CONTRIB"/print_electrum_version.py)
VERSIONC=$("$CONTRIB"/print_electrum_version.py --with-commit)

# put commit-id in tarball name
mv "$PY_DISTDIR/Electrum-$VERSIONB.tar.gz" "$PY_DISTDIR/Electrum-$VERSIONC.tar.gz"

if ([ "$OMIT_UNCLEAN_FILES" = 1 ]); then
FINAL_DISTNAME="Electrum-sourceonly-$VERSION.tar.gz"
FINAL_DISTNAME="Electrum-sourceonly-$VERSIONC.tar.gz"
else
FINAL_DISTNAME="Electrum-$VERSION.tar.gz"
FINAL_DISTNAME="Electrum-$VERSIONC.tar.gz"
fi
if ([ "$OMIT_UNCLEAN_FILES" = 1 ]); then
mv "$PY_DISTDIR/Electrum-$VERSION.tar.gz" "$PY_DISTDIR/../$FINAL_DISTNAME"
mv "$PY_DISTDIR/Electrum-$VERSIONC.tar.gz" "$PY_DISTDIR/../$FINAL_DISTNAME"
rmdir "$PY_DISTDIR"
fi

Expand All @@ -66,7 +71,7 @@ info "preparing electrum-locale."
cd "$BUILDDIR/dist2"
tar -xzf "$BUILDDIR/dist1/$FINAL_DISTNAME"
find -exec touch -h -d '2000-11-11T11:11:11+00:00' {} +
GZIP=-n tar --sort=name -czf "$FINAL_DISTNAME" "Electrum-$VERSION/"
GZIP=-n tar --sort=name -czf "$FINAL_DISTNAME" "Electrum-$VERSIONB/"
mv "$FINAL_DISTNAME" "$DISTDIR/$FINAL_DISTNAME"
)

Expand Down
12 changes: 7 additions & 5 deletions contrib/build-wine/build-electrum-git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ set -e

pushd "$PROJECT_ROOT"

VERSION=$(git describe --tags --dirty --always)
info "Last commit: $VERSION"
VERSIONB=$("$CONTRIB"/print_electrum_version.py)
VERSIONC=$("$CONTRIB"/print_electrum_version.py --with-commit)
info "VERSIONB: $VERSIONB"
info "VERSIONC: $VERSIONC"

info "preparing electrum-locale."
(
Expand Down Expand Up @@ -62,7 +64,7 @@ rm -rf dist/

# build standalone and portable versions
info "Running pyinstaller..."
ELECTRUM_CMDLINE_NAME="$NAME_ROOT-$VERSION" wine "$WINE_PYHOME/scripts/pyinstaller.exe" --noconfirm --clean pyinstaller.spec
ELECTRUM_CMDLINE_NAME="$NAME_ROOT-$VERSIONC" wine "$WINE_PYHOME/scripts/pyinstaller.exe" --noconfirm --clean pyinstaller.spec

# set timestamps in dist, in order to make the installer reproducible
pushd dist
Expand All @@ -71,10 +73,10 @@ popd

info "building NSIS installer"
# $VERSION could be passed to the electrum.nsi script, but this would require some rewriting in the script itself.
makensis -DPRODUCT_VERSION=$VERSION electrum.nsi
makensis "-DPRODUCT_VERSION=$VERSIONB" electrum.nsi

cd dist
mv electrum-setup.exe $NAME_ROOT-$VERSION-setup.exe
mv electrum-setup.exe "$NAME_ROOT-$VERSIONC-setup.exe"
cd ..

info "Padding binaries to 8-byte boundaries, and fixing COFF image checksum in PE header"
Expand Down
6 changes: 3 additions & 3 deletions contrib/build-wine/unsign.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rm -rf signed/stripped
mkdir -p signed >/dev/null 2>&1
mkdir -p signed/stripped >/dev/null 2>&1

version=$("$CONTRIB"/print_electrum_version.py)
VERSIONB=$("$CONTRIB"/print_electrum_version.py)

echo "Found $(ls dist/*.exe | wc -w) files to verify."

Expand All @@ -28,8 +28,8 @@ for mine in dist/*.exe; do
if test -f "signed/$f"; then
echo "Found file at signed/$f"
else
echo "Downloading https://download.electrum.org/$version/$f"
wget -q "https://download.electrum.org/$version/$f" -O "signed/$f"
echo "Downloading https://download.electrum.org/$VERSIONB/$f"
wget -q "https://download.electrum.org/$VERSIONB/$f" -O "signed/$f"
fi
out="signed/stripped/$f"
# Remove PE signature from signed binary
Expand Down
47 changes: 23 additions & 24 deletions contrib/make_download
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import re
import os
import sys
import importlib
import importlib.util
from collections import defaultdict


Expand All @@ -13,13 +14,15 @@ if len(sys.argv) < 2:
# cd to project root
os.chdir(os.path.dirname(os.path.dirname(__file__)))

# load version.py; needlessly complicated alternative to "imp.load_source":
version_spec = importlib.util.spec_from_file_location('version', 'electrum/version.py')
version_module = importlib.util.module_from_spec(version_spec)
version_spec.loader.exec_module(version_module)
# load print_electrum_version.py; needlessly complicated alternative to "imp.load_source":
pev_spec = importlib.util.spec_from_file_location('print_electrum_version', 'contrib/print_electrum_version.py')
pev_module = importlib.util.module_from_spec(pev_spec)
pev_spec.loader.exec_module(pev_module)

ELECTRUM_VERSION = version_module.ELECTRUM_VERSION
print(f"version: {ELECTRUM_VERSION}", file=sys.stderr)
versionb = pev_module.get_bare_version()
versionc = pev_module.get_versionc()
print(f"{versionb=!r}", file=sys.stderr)
print(f"{versionc=!r}", file=sys.stderr)

dirname = sys.argv[1]

Expand All @@ -31,26 +34,21 @@ download_template = download_page + ".template"
with open(download_template) as f:
download_page_str = f.read()

version = version_win = version_mac = version_android = ELECTRUM_VERSION
download_page_str = download_page_str.replace("##VERSION##", version)
download_page_str = download_page_str.replace("##VERSION_WIN##", version_win)
download_page_str = download_page_str.replace("##VERSION_MAC##", version_mac)
download_page_str = download_page_str.replace("##VERSION_ANDROID##", version_android)
download_page_str = download_page_str.replace("##VERSION_APK##", version_android)
download_page_str = download_page_str.replace("##VERSION##", versionb)

# note: all dist files need to be listed here that we expect sigs for,
# even if they are not linked to from the website
files = {
"tgz": f"Electrum-{version}.tar.gz",
"tgz_srconly": f"Electrum-sourceonly-{version}.tar.gz",
"appimage": f"electrum-{version}-x86_64.AppImage",
"mac": f"electrum-{version_mac}.dmg",
"win": f"electrum-{version_win}.exe",
"win_setup": f"electrum-{version_win}-setup.exe",
"win_portable": f"electrum-{version_win}-portable.exe",
"apk_arm64": f"Electrum-{version_android}-arm64-v8a-release.apk",
"apk_armeabi": f"Electrum-{version_android}-armeabi-v7a-release.apk",
"apk_x86_64": f"Electrum-{version_android}-x86_64-release.apk",
"tgz": f"Electrum-{versionc}.tar.gz",
"tgz_srconly": f"Electrum-sourceonly-{versionc}.tar.gz",
"appimage": f"electrum-{versionc}-x86_64.AppImage",
"mac": f"electrum-{versionc}.dmg",
"win": f"electrum-{versionc}.exe",
"win_setup": f"electrum-{versionc}-setup.exe",
"win_portable": f"electrum-{versionc}-portable.exe",
"apk_arm64": f"Electrum-{versionc}-arm64-v8a-release.apk",
"apk_armeabi": f"Electrum-{versionc}-armeabi-v7a-release.apk",
"apk_x86_64": f"Electrum-{versionc}-x86_64-release.apk",
}

# default signers
Expand Down Expand Up @@ -78,10 +76,11 @@ download_page_str = download_page_str.replace("##signers_list##", signers_list)

for k, filename in files.items():
path = "dist/%s"%filename
assert filename in list_dir
link = "https://download.electrum.org/%s/%s"%(version, filename)
assert filename in list_dir, f"{filename!r} missing from dist/"
link = "https://download.electrum.org/%s/%s"%(versionb, filename)
download_page_str = download_page_str.replace("##link_%s##" % k, link)
download_page_str = download_page_str.replace("##sigs_%s##" % k, link + '.asc')
download_page_str = download_page_str.replace("##distname_%s##" % k, filename)


# download page has been constructed from template; now insert it into index.html
Expand Down
8 changes: 4 additions & 4 deletions contrib/osx/make_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,17 @@ find "$VENV_DIR/lib/python$PY_VER_MAJOR/site-packages/" -type f -name '*.so' -pr
info "Faking timestamps..."
find . -exec touch -t '200101220000' {} + || true

# note: no --dirty, as we have dirtied electrum/locale/ ourselves.
VERSION=$(git describe --tags --always)
VERSIONB=$("$CONTRIB"/print_electrum_version.py)
VERSIONC=$("$CONTRIB"/print_electrum_version.py --with-commit)

info "Building binary"
ELECTRUM_VERSION=$VERSION pyinstaller --noconfirm --clean contrib/osx/pyinstaller.spec || fail "Could not build binary"
ELECTRUM_VERSION="$VERSIONB" pyinstaller --noconfirm --clean contrib/osx/pyinstaller.spec || fail "Could not build binary"

info "Finished building unsigned dist/${PACKAGE}.app. This hash should be reproducible:"
find "dist/${PACKAGE}.app" -type f -print0 | sort -z | xargs -0 shasum -a 256 | shasum -a 256

info "Creating unsigned .DMG"
hdiutil create -fs HFS+ -volname $PACKAGE -srcfolder dist/$PACKAGE.app dist/electrum-$VERSION-unsigned.dmg || fail "Could not create .DMG"
hdiutil create -fs HFS+ -volname "$PACKAGE" -srcfolder "dist/$PACKAGE.app" "dist/electrum-$VERSIONC-unsigned.dmg" || fail "Could not create .DMG"

info "App was built successfully but was not code signed. Users may get security warnings from macOS."
info "Now you also need to run sign_osx.sh to codesign/notarize the binary."
7 changes: 3 additions & 4 deletions contrib/osx/sign_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ function DoCodeSignMaybe { # ARGS: infoName fileOrDirName
codesign -f -v $deep -s "$CODESIGN_CERT" $hardened_arg "$file" || fail "Could not code sign ${infoName}"
}

# note: no --dirty, as we have dirtied electrum/locale/ ourselves.
VERSION=$(git describe --tags --always)
VERSIONC=$("$CONTRIB"/print_electrum_version.py --with-commit)

DoCodeSignMaybe "app bundle" "dist/${PACKAGE}.app"

Expand All @@ -74,6 +73,6 @@ if [ ! -z "$CODESIGN_CERT" ]; then
fi

info "Creating .DMG"
hdiutil create -fs HFS+ -volname $PACKAGE -srcfolder dist/$PACKAGE.app dist/electrum-$VERSION.dmg || fail "Could not create .DMG"
hdiutil create -fs HFS+ -volname "$PACKAGE" -srcfolder "dist/$PACKAGE.app" "dist/electrum-$VERSIONC.dmg" || fail "Could not create .DMG"

DoCodeSignMaybe ".DMG" "dist/electrum-${VERSION}.dmg"
DoCodeSignMaybe ".DMG" "dist/electrum-${VERSIONC}.dmg"
36 changes: 27 additions & 9 deletions contrib/print_electrum_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3
# For usage in shell, to get the version of electrum, without needing electrum installed.
# usage: ./print_electrum_version.py [<attr_name>]
# usage: ./print_electrum_version.py [--with-commit]
#
# For example:
# $ VERSION=$("$CONTRIB"/print_electrum_version.py)
Expand All @@ -9,23 +9,41 @@

import importlib.util
import os
import subprocess
import sys


if __name__ == '__main__':
if len(sys.argv) >= 2:
attr_name = sys.argv[1]
else:
attr_name = "ELECTRUM_VERSION"
project_root = os.path.abspath(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


project_root = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def get_bare_version() -> str:
"""example: '4.8.0' """
version_file_path = os.path.join(project_root, "electrum", "version.py")

# load version.py; needlessly complicated alternative to "imp.load_source":
version_spec = importlib.util.spec_from_file_location('version', version_file_path)
version_module = version = importlib.util.module_from_spec(version_spec)
version_spec.loader.exec_module(version_module)

attr_val = getattr(version, attr_name)
print(attr_val, file=sys.stdout)
elec_ver = getattr(version, "ELECTRUM_VERSION")
return str(elec_ver)


def get_versionc() -> str:
"""example: '4.8.0-8c0adcd' """
commit = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=project_root)
commit = str(commit, "utf8").strip()
commit = commit[:7]
elec_ver = get_bare_version()
return f"{elec_ver}-{commit}"


if __name__ == '__main__':
if len(sys.argv) == 1:
print(get_bare_version(), file=sys.stdout)
elif len(sys.argv) == 2 and sys.argv[1] == "--with-commit":
print(get_versionc(), file=sys.stdout)
else:
print("usage: ./print_electrum_version.py [--with-commit]", file=sys.stderr)
sys.exit(1)

Loading