Skip to content

Commit 6877c6f

Browse files
authored
Merge pull request #10235 from SomberNight/202509_ci_appimage
ci: fix appimage build
2 parents 14d7c96 + 750f1d0 commit 6877c6f

File tree

10 files changed

+94
-66
lines changed

10 files changed

+94
-66
lines changed

.cirrus.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,10 @@ task:
344344
only_if: $CIRRUS_CRON == ""
345345
- trigger_type: automatic
346346
only_if: $CIRRUS_CRON == "nightly"
347-
container:
348-
dockerfile: contrib/build-linux/appimage/Dockerfile
347+
compute_engine_instance:
348+
image_project: cirrus-images
349+
image: family/docker-builder
350+
platform: linux
349351
cpu: 2
350352
memory: 2G
351353
pip_cache:
@@ -361,11 +363,9 @@ task:
361363
- cat contrib/make_libsecp256k1.sh | sha256sum
362364
- git ls-files -s contrib/build-linux/appimage/
363365
build_script:
364-
- ./contrib/build-linux/appimage/make_appimage.sh
366+
- ./contrib/build-linux/appimage/build.sh
365367
binaries_artifacts:
366368
path: "dist/*"
367-
env:
368-
CIRRUS_DOCKER_CONTEXT: contrib/build-linux/appimage
369369
depends_on:
370370
- "unittests: py3.10"
371371

contrib/android/Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,16 @@ RUN apt -y update -qq \
174174

175175
# create new user to avoid using root; but with sudo access and no password for convenience.
176176
ARG UID=1000
177-
ENV USER="user"
178-
ENV HOME_DIR="/home/${USER}"
177+
RUN if [ "$UID" != "0" ] ; then useradd --uid $UID --create-home --shell /bin/bash "user" ; fi
178+
RUN usermod -append --groups sudo $(id -nu $UID || echo "user")
179+
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
180+
RUN HOME_DIR=$(getent passwd $UID | cut -d: -f6)
179181
ENV WORK_DIR="${HOME_DIR}/wspace" \
180182
PATH="${HOME_DIR}/.local/bin:${PATH}"
181-
RUN useradd --uid $UID --create-home --shell /bin/bash ${USER}
182-
RUN usermod -append --groups sudo ${USER}
183-
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
184183
WORKDIR ${WORK_DIR}
185-
RUN chown --recursive ${USER} ${WORK_DIR} ${ANDROID_SDK_HOME}
186-
RUN chown ${USER} /opt
187-
USER ${USER}
184+
RUN chown --recursive ${UID} ${WORK_DIR} ${ANDROID_SDK_HOME}
185+
RUN chown ${UID} /opt
186+
USER ${UID}
188187

189188
# venv, VIRTUAL_ENV is used by buildozer to indicate a venv environment
190189
ENV VIRTUAL_ENV=/opt/venv

contrib/android/build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ else
6363
fi
6464

6565
DOCKER_RUN_FLAGS=""
66-
6766
if [[ "$3" == "release" ]] ; then
6867
info "'release' mode selected. mounting ~/.keystore inside container."
6968
DOCKER_RUN_FLAGS="-v $HOME/.keystore:/home/user/.keystore"
7069
fi
70+
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then
71+
info "/dev/tty is available and usable"
72+
DOCKER_RUN_FLAGS="$DOCKER_RUN_FLAGS -it"
73+
fi
7174

7275
info "building binary..."
7376
mkdir --parents "$PROJECT_ROOT_OR_FRESHCLONE_ROOT"/.buildozer/.gradle
@@ -78,7 +81,7 @@ if [ ! -z "$ELECBUILD_COMMIT" ] ; then # fresh clone (reproducible build)
7881
sudo chown -R 1000:1000 "$FRESH_CLONE"
7982
fi
8083
fi
81-
docker run -it --rm \
84+
docker run --rm \
8285
--name electrum-android-builder-cont \
8386
-v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT":/home/user/wspace/electrum \
8487
-v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT"/.buildozer/.gradle:/home/user/.gradle \

contrib/build-linux/appimage/Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,12 @@ RUN apt-get update -q && \
7575

7676
# create new user to avoid using root; but with sudo access and no password for convenience.
7777
ARG UID=1000
78-
ENV USER="user"
79-
ENV HOME_DIR="/home/${USER}"
78+
RUN if [ "$UID" != "0" ] ; then useradd --uid $UID --create-home --shell /bin/bash "user" ; fi
79+
RUN usermod -append --groups sudo $(id -nu $UID || echo "user")
80+
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
81+
RUN HOME_DIR=$(getent passwd $UID | cut -d: -f6)
8082
ENV WORK_DIR="${HOME_DIR}/wspace" \
8183
PATH="${HOME_DIR}/.local/bin:${PATH}"
82-
RUN useradd --uid $UID --create-home --shell /bin/bash ${USER}
83-
RUN usermod -append --groups sudo ${USER}
84-
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
8584
WORKDIR ${WORK_DIR}
86-
RUN chown --recursive ${USER} ${WORK_DIR}
87-
USER ${USER}
85+
RUN chown --recursive ${UID} ${WORK_DIR}
86+
USER ${UID}

contrib/build-linux/appimage/build.sh

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ CONTRIB_APPIMAGE="$CONTRIB/build-linux/appimage"
1313
DISTDIR="$PROJECT_ROOT/dist"
1414
BUILD_UID=$(/usr/bin/stat -c %u "$PROJECT_ROOT")
1515

16-
# when bumping the runtime commit also check if the `type2-runtime-reproducible-build.patch` still works
17-
TYPE2_RUNTIME_COMMIT="5e7217b7cfeecee1491c2d251e355c3cf8ba6e4d"
18-
TYPE2_RUNTIME_REPO="https://github.com/AppImage/type2-runtime.git"
19-
2016
. "$CONTRIB"/build_tools_util.sh
2117

2218

@@ -52,29 +48,13 @@ fi
5248

5349
# build the type2-runtime binary, this build step uses a separate docker container
5450
# defined in the type2-runtime repo (patched with type2-runtime-reproducible-build.patch)
55-
TYPE2_RUNTIME_REPO_DIR="$PROJECT_ROOT_OR_FRESHCLONE_ROOT/contrib/build-linux/appimage/.cache/appimage/type2-runtime"
56-
(
57-
if [ -f "$TYPE2_RUNTIME_REPO_DIR/runtime-x86_64" ]; then
58-
info "type2-runtime already built, skipping"
59-
exit 0
60-
fi
61-
clone_or_update_repo "$TYPE2_RUNTIME_REPO" "$TYPE2_RUNTIME_COMMIT" "$TYPE2_RUNTIME_REPO_DIR"
62-
63-
# Apply patch to make runtime build reproducible
64-
info "Applying type2-runtime patch..."
65-
cd "$TYPE2_RUNTIME_REPO_DIR"
66-
git apply "$CONTRIB_APPIMAGE/patches/type2-runtime-reproducible-build.patch" || fail "Failed to apply runtime repo patch"
51+
"$CONTRIB_APPIMAGE/make_type2_runtime.sh" || fail "Error building type2-runtime."
6752

68-
info "building type2-runtime in build container..."
69-
cd "$TYPE2_RUNTIME_REPO_DIR/scripts/docker"
70-
env ARCH=x86_64 ./build-with-docker.sh
71-
mv "./runtime-x86_64" "$TYPE2_RUNTIME_REPO_DIR/"
72-
73-
# clean up the empty created 'out' dir to prevent permission issues
74-
rm -rf "$TYPE2_RUNTIME_REPO_DIR/out"
75-
76-
info "runtime build successful: $(sha256sum "$TYPE2_RUNTIME_REPO_DIR/runtime-x86_64")"
77-
)
53+
DOCKER_RUN_FLAGS=""
54+
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then
55+
info "/dev/tty is available and usable"
56+
DOCKER_RUN_FLAGS="-it"
57+
fi
7858

7959
info "building binary..."
8060
# check uid and maybe chown. see #8261
@@ -84,7 +64,7 @@ if [ ! -z "$ELECBUILD_COMMIT" ] ; then # fresh clone (reproducible build)
8464
sudo chown -R 1000:1000 "$FRESH_CLONE"
8565
fi
8666
fi
87-
docker run -it \
67+
docker run $DOCKER_RUN_FLAGS \
8868
--name electrum-appimage-builder-cont \
8969
-v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT":/opt/electrum \
9070
--rm \
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
PROJECT_ROOT="$(dirname "$(readlink -e "$0")")/../../.."
6+
PROJECT_ROOT_OR_FRESHCLONE_ROOT="$PROJECT_ROOT"
7+
CONTRIB="$PROJECT_ROOT/contrib"
8+
CONTRIB_APPIMAGE="$CONTRIB/build-linux/appimage"
9+
10+
# when bumping the runtime commit also check if the `type2-runtime-reproducible-build.patch` still works
11+
TYPE2_RUNTIME_COMMIT="5e7217b7cfeecee1491c2d251e355c3cf8ba6e4d"
12+
TYPE2_RUNTIME_REPO="https://github.com/AppImage/type2-runtime.git"
13+
14+
. "$CONTRIB"/build_tools_util.sh
15+
16+
17+
TYPE2_RUNTIME_REPO_DIR="$PROJECT_ROOT_OR_FRESHCLONE_ROOT/contrib/build-linux/appimage/.cache/appimage/type2-runtime"
18+
if [ -f "$TYPE2_RUNTIME_REPO_DIR/runtime-x86_64" ]; then
19+
info "type2-runtime already built, skipping"
20+
exit 0
21+
fi
22+
clone_or_update_repo "$TYPE2_RUNTIME_REPO" "$TYPE2_RUNTIME_COMMIT" "$TYPE2_RUNTIME_REPO_DIR"
23+
24+
# Apply patch to make runtime build reproducible
25+
info "Applying type2-runtime patch..."
26+
cd "$TYPE2_RUNTIME_REPO_DIR"
27+
git apply "$CONTRIB_APPIMAGE/patches/type2-runtime-reproducible-build.patch" || fail "Failed to apply runtime repo patch"
28+
29+
info "building type2-runtime in build container..."
30+
cd "$TYPE2_RUNTIME_REPO_DIR/scripts/docker"
31+
env ARCH=x86_64 ./build-with-docker.sh
32+
mv "./runtime-x86_64" "$TYPE2_RUNTIME_REPO_DIR/"
33+
34+
# clean up the empty created 'out' dir to prevent permission issues
35+
rm -rf "$TYPE2_RUNTIME_REPO_DIR/out"
36+
37+
info "runtime build successful: $(sha256sum "$TYPE2_RUNTIME_REPO_DIR/runtime-x86_64")"

contrib/build-linux/sdist/Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ RUN apt-get update -q && \
1818

1919
# create new user to avoid using root; but with sudo access and no password for convenience.
2020
ARG UID=1000
21-
ENV USER="user"
22-
ENV HOME_DIR="/home/${USER}"
21+
RUN if [ "$UID" != "0" ] ; then useradd --uid $UID --create-home --shell /bin/bash "user" ; fi
22+
RUN usermod -append --groups sudo $(id -nu $UID || echo "user")
23+
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
24+
RUN HOME_DIR=$(getent passwd $UID | cut -d: -f6)
2325
ENV WORK_DIR="${HOME_DIR}/wspace" \
2426
PATH="${HOME_DIR}/.local/bin:${PATH}"
25-
RUN useradd --uid $UID --create-home --shell /bin/bash ${USER}
26-
RUN usermod -append --groups sudo ${USER}
27-
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
2827
WORKDIR ${WORK_DIR}
29-
RUN chown --recursive ${USER} ${WORK_DIR}
30-
USER ${USER}
28+
RUN chown --recursive ${UID} ${WORK_DIR}
29+
USER ${UID}

contrib/build-linux/sdist/build.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ else
4646
info "not doing fresh clone."
4747
fi
4848

49+
DOCKER_RUN_FLAGS=""
50+
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then
51+
info "/dev/tty is available and usable"
52+
DOCKER_RUN_FLAGS="-it"
53+
fi
54+
4955
info "building binary..."
5056
# check uid and maybe chown. see #8261
5157
if [ ! -z "$ELECBUILD_COMMIT" ] ; then # fresh clone (reproducible build)
@@ -54,7 +60,7 @@ if [ ! -z "$ELECBUILD_COMMIT" ] ; then # fresh clone (reproducible build)
5460
sudo chown -R 1000:1000 "$FRESH_CLONE"
5561
fi
5662
fi
57-
docker run -it \
63+
docker run $DOCKER_RUN_FLAGS \
5864
--name electrum-sdist-builder-cont \
5965
-v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT":/opt/electrum \
6066
--rm \

contrib/build-wine/Dockerfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,15 @@ RUN DEBIAN_CODENAME=$(lsb_release --codename --short) && \
5858

5959
# create new user to avoid using root; but with sudo access and no password for convenience.
6060
ARG UID=1000
61-
ENV USER="user"
62-
ENV HOME_DIR="/home/${USER}"
61+
RUN if [ "$UID" != "0" ] ; then useradd --uid $UID --create-home --shell /bin/bash "user" ; fi
62+
RUN usermod -append --groups sudo $(id -nu $UID || echo "user")
63+
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
64+
RUN HOME_DIR=$(getent passwd $UID | cut -d: -f6)
6365
ENV WORK_DIR="${HOME_DIR}/wspace" \
6466
PATH="${HOME_DIR}/.local/bin:${PATH}"
65-
RUN useradd --uid $UID --create-home --shell /bin/bash ${USER}
66-
RUN usermod -append --groups sudo ${USER}
67-
RUN echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
6867
WORKDIR ${WORK_DIR}
69-
RUN chown --recursive ${USER} ${WORK_DIR}
70-
RUN chown ${USER} /opt
71-
USER ${USER}
68+
RUN chown --recursive ${UID} ${WORK_DIR}
69+
RUN chown ${UID} /opt
70+
USER ${UID}
7271

7372
RUN mkdir --parents "/opt/wine64/drive_c/electrum"

contrib/build-wine/build.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ else
4848
info "not doing fresh clone."
4949
fi
5050

51+
DOCKER_RUN_FLAGS=""
52+
if sh -c ": >/dev/tty" >/dev/null 2>/dev/null; then
53+
info "/dev/tty is available and usable"
54+
DOCKER_RUN_FLAGS="-it"
55+
fi
56+
5157
info "building binary..."
5258
# check uid and maybe chown. see #8261
5359
if [ ! -z "$ELECBUILD_COMMIT" ] ; then # fresh clone (reproducible build)
@@ -56,7 +62,7 @@ if [ ! -z "$ELECBUILD_COMMIT" ] ; then # fresh clone (reproducible build)
5662
sudo chown -R 1000:1000 "$FRESH_CLONE"
5763
fi
5864
fi
59-
docker run -it \
65+
docker run $DOCKER_RUN_FLAGS \
6066
--name electrum-wine-builder-cont \
6167
-v "$PROJECT_ROOT_OR_FRESHCLONE_ROOT":/opt/wine64/drive_c/electrum \
6268
--rm \

0 commit comments

Comments
 (0)