From 99b0df0f9fdf1d1feb50338091e233d53f9fabc3 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 11 Feb 2026 11:02:52 -0800 Subject: [PATCH 1/5] contrib: android: Dockerfile: fix build user env The previous layers were somewhat senseless; as the buildozer user's UID and environment must remain static across the entire build. Resolves: "Usage of undefined variable '$HOME_DIR'" Refactoring command args also keeps things sane. --- contrib/android/Dockerfile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/contrib/android/Dockerfile b/contrib/android/Dockerfile index d462bd4d23bb..b1615bbff75a 100644 --- a/contrib/android/Dockerfile +++ b/contrib/android/Dockerfile @@ -196,17 +196,16 @@ RUN apt -y update -qq \ # create new user to avoid using root; but with sudo access and no password for convenience. -ARG UID=1000 -RUN if [ "$UID" != "0" ] ; then useradd --uid $UID --create-home --shell /bin/bash "user" ; fi -RUN usermod -append --groups sudo $(id -nu $UID || echo "user") +# NOTE: UID *MUST* align with buildozer's Dockerfile "user" +RUN useradd -u 1000 -m -s /usr/bin/bash -d /home/user user +RUN usermod -aG sudo user RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -RUN HOME_DIR=$(getent passwd $UID | cut -d: -f6) -ENV WORK_DIR="${HOME_DIR}/wspace" \ - PATH="${HOME_DIR}/.local/bin:${PATH}" +ENV HOME_DIR=/home/user +ENV WORK_DIR="${HOME_DIR}/wspace" +ENV PATH="${HOME_DIR}/.local/bin:${PATH}" WORKDIR ${WORK_DIR} -RUN chown --recursive ${UID} ${WORK_DIR} ${ANDROID_SDK_HOME} -RUN chown ${UID} /opt -USER ${UID} +RUN chown -R user ${WORK_DIR} ${ANDROID_SDK_HOME} /opt +USER user # build cpython. FIXME we can't use the python3 from apt, as it is too new o.O # - p4a and buildozer require cython<3 (see https://github.com/kivy/python-for-android/issues/2919) From 202ea2870c1b55c0ac84b4b7570a36af2805b475 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 11 Feb 2026 11:03:47 -0800 Subject: [PATCH 2/5] contrib: android: Dockerfile: fix ownership of COPY Resolves: ERROR: Could not open requirements file: [Errno 13] Permission denied: '/opt/deterministic-build/requirements-build-base.txt' --- contrib/android/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/android/Dockerfile b/contrib/android/Dockerfile index b1615bbff75a..be455d106044 100644 --- a/contrib/android/Dockerfile +++ b/contrib/android/Dockerfile @@ -232,8 +232,8 @@ ENV VIRTUAL_ENV=/opt/venv RUN "/opt/cpython/install/bin/python3" -m venv ${VIRTUAL_ENV} ENV PATH="${VIRTUAL_ENV}/bin:${PATH}" -COPY contrib/deterministic-build/requirements-build-base.txt /opt/deterministic-build/ -COPY contrib/deterministic-build/requirements-build-android.txt /opt/deterministic-build/ +COPY --chown=user contrib/deterministic-build/requirements-build-base.txt /opt/deterministic-build/ +COPY --chown=user contrib/deterministic-build/requirements-build-android.txt /opt/deterministic-build/ RUN /opt/venv/bin/python3 -m pip install --no-build-isolation --no-dependencies \ -r /opt/deterministic-build/requirements-build-base.txt RUN /opt/venv/bin/python3 -m pip install --no-build-isolation --no-dependencies --no-binary :all: \ From 12dfa15e3e3663a7a5faf76103ee9d7c03d7ef32 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Wed, 11 Feb 2026 13:49:01 -0800 Subject: [PATCH 3/5] contrib: android: make_apk.sh: add/update testnet comments --- contrib/android/make_apk.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/contrib/android/make_apk.sh b/contrib/android/make_apk.sh index 2b6ee7360f25..3f75c35fa404 100755 --- a/contrib/android/make_apk.sh +++ b/contrib/android/make_apk.sh @@ -34,12 +34,21 @@ info "apk building phase starts." # Uncomment and change below to set a custom android package id, # e.g. to allow simultaneous mainnet and testnet installs of the apk. # defaults: +# # export APP_PACKAGE_NAME=Electrum # export APP_PACKAGE_DOMAIN=org.electrum -# FIXME: changing "APP_PACKAGE_NAME" seems to require a clean rebuild of ".buildozer/", -# to avoid that, maybe change "APP_PACKAGE_DOMAIN" instead. -# So, in particular, to build a testnet apk, simply uncomment: +# +# FIXME: changing "APP_PACKAGE_NAME" seems to require a clean rebuild of ".buildozer/". +# However, even with a clean build, the build appears to break in the final stages (~4.7.0). +# To avoid these issues; only change "APP_PACKAGE_DOMAIN" instead. +# +# So, in particular, to build testnet APKs, simply uncomment one of the following at a time (per-build): +# +# Testnet3 #export APP_PACKAGE_DOMAIN=org.electrum.testnet +# +# Testnet4 +#export APP_PACKAGE_DOMAIN=org.electrum.testnet4 if [ $CI ]; then # override log level specified in buildozer.spec to "debug": From 4800573fdee3aa0b41044649cb5fba329a740f98 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Mon, 9 Mar 2026 11:46:56 -0700 Subject: [PATCH 4/5] contrib: build-{linux,wine}: continue fixing build user env A continuation of 99b0df0f9fdf1d1feb50338091e233d53f9fabc3, as requested in https://github.com/spesmilo/electrum/pull/10486. --- contrib/build-linux/appimage/Dockerfile | 16 ++++++++-------- contrib/build-linux/sdist/Dockerfile | 16 ++++++++-------- contrib/build-wine/Dockerfile | 17 ++++++++--------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/contrib/build-linux/appimage/Dockerfile b/contrib/build-linux/appimage/Dockerfile index 5f43ac930a08..a20cebb9ba85 100644 --- a/contrib/build-linux/appimage/Dockerfile +++ b/contrib/build-linux/appimage/Dockerfile @@ -74,13 +74,13 @@ RUN apt-get update -q && \ apt-get clean # create new user to avoid using root; but with sudo access and no password for convenience. -ARG UID=1000 -RUN if [ "$UID" != "0" ] ; then useradd --uid $UID --create-home --shell /bin/bash "user" ; fi -RUN usermod -append --groups sudo $(id -nu $UID || echo "user") +# NOTE: UID *MUST* align with buildozer's Dockerfile "user" +RUN useradd -u 1000 -m -s /usr/bin/bash -d /home/user user +RUN usermod -aG sudo user RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -RUN HOME_DIR=$(getent passwd $UID | cut -d: -f6) -ENV WORK_DIR="${HOME_DIR}/wspace" \ - PATH="${HOME_DIR}/.local/bin:${PATH}" +ENV HOME_DIR=/home/user +ENV WORK_DIR="${HOME_DIR}/wspace" +ENV PATH="${HOME_DIR}/.local/bin:${PATH}" WORKDIR ${WORK_DIR} -RUN chown --recursive ${UID} ${WORK_DIR} -USER ${UID} +RUN chown -R user ${WORK_DIR} +USER user diff --git a/contrib/build-linux/sdist/Dockerfile b/contrib/build-linux/sdist/Dockerfile index 3b6f12112b9e..4320eb577ed6 100644 --- a/contrib/build-linux/sdist/Dockerfile +++ b/contrib/build-linux/sdist/Dockerfile @@ -17,13 +17,13 @@ RUN apt-get update -q && \ apt-get clean # create new user to avoid using root; but with sudo access and no password for convenience. -ARG UID=1000 -RUN if [ "$UID" != "0" ] ; then useradd --uid $UID --create-home --shell /bin/bash "user" ; fi -RUN usermod -append --groups sudo $(id -nu $UID || echo "user") +# NOTE: UID *MUST* align with buildozer's Dockerfile "user" +RUN useradd -u 1000 -m -s /usr/bin/bash -d /home/user user +RUN usermod -aG sudo user RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -RUN HOME_DIR=$(getent passwd $UID | cut -d: -f6) -ENV WORK_DIR="${HOME_DIR}/wspace" \ - PATH="${HOME_DIR}/.local/bin:${PATH}" +ENV HOME_DIR=/home/user +ENV WORK_DIR="${HOME_DIR}/wspace" +ENV PATH="${HOME_DIR}/.local/bin:${PATH}" WORKDIR ${WORK_DIR} -RUN chown --recursive ${UID} ${WORK_DIR} -USER ${UID} +RUN chown -R user ${WORK_DIR} +USER user diff --git a/contrib/build-wine/Dockerfile b/contrib/build-wine/Dockerfile index 4a7022bcea4a..62d2ccd6cf02 100644 --- a/contrib/build-wine/Dockerfile +++ b/contrib/build-wine/Dockerfile @@ -57,16 +57,15 @@ RUN DEBIAN_CODENAME=$(lsb_release --codename --short) && \ apt-get clean # create new user to avoid using root; but with sudo access and no password for convenience. -ARG UID=1000 -RUN if [ "$UID" != "0" ] ; then useradd --uid $UID --create-home --shell /bin/bash "user" ; fi -RUN usermod -append --groups sudo $(id -nu $UID || echo "user") +# NOTE: UID *MUST* align with buildozer's Dockerfile "user" +RUN useradd -u 1000 -m -s /usr/bin/bash -d /home/user user +RUN usermod -aG sudo user RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -RUN HOME_DIR=$(getent passwd $UID | cut -d: -f6) -ENV WORK_DIR="${HOME_DIR}/wspace" \ - PATH="${HOME_DIR}/.local/bin:${PATH}" +ENV HOME_DIR=/home/user +ENV WORK_DIR="${HOME_DIR}/wspace" +ENV PATH="${HOME_DIR}/.local/bin:${PATH}" WORKDIR ${WORK_DIR} -RUN chown --recursive ${UID} ${WORK_DIR} -RUN chown ${UID} /opt -USER ${UID} +RUN chown -R user ${WORK_DIR} /opt +USER user RUN mkdir --parents "/opt/wine64/drive_c/electrum" From b3be2a012d8c806e0cfbc72d8306fd70ccbfea6f Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 6 May 2026 08:50:50 +0000 Subject: [PATCH 5/5] build: fix regression: support local dev builds also using UID!=1000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - both "ELECBUILD_COMMIT fresh_clone builds" and "local dev builds" should work even when the unix user has a different UID than 1000 on the host machine - though I guess running as root does not work but that's prob ok issue was: ``` $ echo $UID 1111 $ ./contrib/build-linux/appimage/build.sh 🗯 ERROR: Building outside a git clone is not supported. ``` --- contrib/android/Dockerfile | 4 ++-- contrib/build-linux/appimage/Dockerfile | 4 ++-- contrib/build-linux/sdist/Dockerfile | 4 ++-- contrib/build-wine/Dockerfile | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/android/Dockerfile b/contrib/android/Dockerfile index be455d106044..70a6ad7d5197 100644 --- a/contrib/android/Dockerfile +++ b/contrib/android/Dockerfile @@ -196,8 +196,8 @@ RUN apt -y update -qq \ # create new user to avoid using root; but with sudo access and no password for convenience. -# NOTE: UID *MUST* align with buildozer's Dockerfile "user" -RUN useradd -u 1000 -m -s /usr/bin/bash -d /home/user user +ARG UID=1000 +RUN useradd -u "$UID" -m -s /usr/bin/bash -d /home/user user RUN usermod -aG sudo user RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ENV HOME_DIR=/home/user diff --git a/contrib/build-linux/appimage/Dockerfile b/contrib/build-linux/appimage/Dockerfile index a20cebb9ba85..0d55e238da10 100644 --- a/contrib/build-linux/appimage/Dockerfile +++ b/contrib/build-linux/appimage/Dockerfile @@ -74,8 +74,8 @@ RUN apt-get update -q && \ apt-get clean # create new user to avoid using root; but with sudo access and no password for convenience. -# NOTE: UID *MUST* align with buildozer's Dockerfile "user" -RUN useradd -u 1000 -m -s /usr/bin/bash -d /home/user user +ARG UID=1000 +RUN useradd -u "$UID" -m -s /usr/bin/bash -d /home/user user RUN usermod -aG sudo user RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ENV HOME_DIR=/home/user diff --git a/contrib/build-linux/sdist/Dockerfile b/contrib/build-linux/sdist/Dockerfile index 4320eb577ed6..4c284e4ab6f1 100644 --- a/contrib/build-linux/sdist/Dockerfile +++ b/contrib/build-linux/sdist/Dockerfile @@ -17,8 +17,8 @@ RUN apt-get update -q && \ apt-get clean # create new user to avoid using root; but with sudo access and no password for convenience. -# NOTE: UID *MUST* align with buildozer's Dockerfile "user" -RUN useradd -u 1000 -m -s /usr/bin/bash -d /home/user user +ARG UID=1000 +RUN useradd -u "$UID" -m -s /usr/bin/bash -d /home/user user RUN usermod -aG sudo user RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ENV HOME_DIR=/home/user diff --git a/contrib/build-wine/Dockerfile b/contrib/build-wine/Dockerfile index 62d2ccd6cf02..319b127abaad 100644 --- a/contrib/build-wine/Dockerfile +++ b/contrib/build-wine/Dockerfile @@ -57,8 +57,8 @@ RUN DEBIAN_CODENAME=$(lsb_release --codename --short) && \ apt-get clean # create new user to avoid using root; but with sudo access and no password for convenience. -# NOTE: UID *MUST* align with buildozer's Dockerfile "user" -RUN useradd -u 1000 -m -s /usr/bin/bash -d /home/user user +ARG UID=1000 +RUN useradd -u "$UID" -m -s /usr/bin/bash -d /home/user user RUN usermod -aG sudo user RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ENV HOME_DIR=/home/user