Skip to content

Commit 7ba4ed2

Browse files
committed
Use common build scripts in chroot env, too
1 parent cb59828 commit 7ba4ed2

File tree

2 files changed

+15
-48
lines changed

2 files changed

+15
-48
lines changed

scripts/chroot/build.sh

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,16 @@
33
set -ex
44

55
if ! command -v apk; then
6-
echo "This script should be run in an Alpine container"
6+
echo "This script should be run in an Alpine chroot environment"
77
exit 1
88
fi
99

10-
apk update
11-
apk add alpine-sdk util-linux strace file autoconf automake libtool xz bash
12-
13-
# Build static libfuse3 with patch for https://github.com/AppImage/type2-runtime/issues/10
14-
apk add eudev-dev gettext-dev linux-headers meson # From https://git.alpinelinux.org/aports/tree/main/fuse3/APKBUILD
15-
wget -c -q "https://github.com/libfuse/libfuse/releases/download/fuse-3.15.0/fuse-3.15.0.tar.xz"
16-
echo "70589cfd5e1cff7ccd6ac91c86c01be340b227285c5e200baa284e401eea2ca0 fuse-3.15.0.tar.xz" | sha256sum -c
17-
tar xf fuse-3.*.tar.xz
18-
cd fuse-3.*/
19-
patch -p1 < ../patches/libfuse/mount.c.diff
20-
mkdir build
21-
cd build
22-
meson setup --prefix=/usr ..
23-
meson configure --default-library static
24-
ninja install
25-
cd ../../
10+
find /scripts
2611

27-
# Minimize binary size
28-
export CFLAGS="-ffunction-sections -fdata-sections -Os"
29-
30-
# Build static squashfuse
31-
apk add zstd-dev zlib-dev zlib-static # fuse3-dev fuse3-static fuse-static fuse-dev
32-
find / -name "libzstd.*" 2>/dev/null || true
33-
wget -c -q "https://github.com/vasi/squashfuse/archive/e51978c.tar.gz"
34-
echo "f544029ad30d8fbde4e4540c574b8cdc6d38b94df025a98d8551a9441f07d341 e51978c.tar.gz" | sha256sum -c
35-
tar xf e51978c.tar.gz
36-
cd squashfuse-*/
37-
./autogen.sh
38-
./configure --help
39-
./configure CFLAGS="${CFLAGS} -no-pie" LDFLAGS=-static
40-
make -j"$(nproc)"
41-
make install
42-
/usr/bin/install -c -m 644 ./*.h '/usr/local/include/squashfuse' # ll.h
43-
cd -
12+
apk update
13+
apk add alpine-sdk util-linux strace file autoconf automake libtool xz bash \
14+
eudev-dev gettext-dev linux-headers meson \
15+
zstd-dev zlib-dev zlib-static # fuse3-dev fuse3-static fuse-static fuse-dev
4416

45-
# Build static AppImage runtime
46-
GIT_COMMIT="$(cat src/runtime/version)"
47-
export GIT_COMMIT
48-
cd src/runtime
49-
make runtime -j"$(nproc)"
50-
file runtime
51-
objcopy --only-keep-debug runtime runtime.debug
52-
strip runtime
53-
ls -lh runtime runtime.debug
54-
echo -ne 'AI\x02' | dd of=runtime bs=1 count=3 seek=8 conv=notrunc # magic bytes, always do AFTER strip
55-
cd -
17+
/scripts/common/install-dependencies.sh
18+
/scripts/build-runtime.sh

scripts/chroot/chroot_build.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,21 @@ sudo cp -p /etc/resolv.conf miniroot/etc/
5353
# Run build.sh in chroot
5454
#############################################
5555

56+
# copy build scripts so that they are available within the chroot environment
57+
# build.sh combines existing scripts shared by all available build environments
58+
sudo cp -R "$repo_root_dir"/scripts miniroot/scripts
59+
5660
if [ "$ALPINE_ARCH" = "x86" ] || [ "$ALPINE_ARCH" = "x86_64" ]; then
5761
echo "Architecture is x86 or x86_64, hence not using qemu-arm-static"
58-
sudo cp "$repo_root_dir"/scripts/chroot/build.sh miniroot/build.sh && sudo chroot miniroot /bin/sh -ex /build.sh
62+
sudo chroot miniroot /bin/sh -ex /scripts/chroot/build.sh
5963
elif [ "$ALPINE_ARCH" = "aarch64" ] ; then
6064
echo "Architecture is aarch64, hence using qemu-aarch64-static"
6165
sudo cp "$(which qemu-aarch64-static)" miniroot/usr/bin
62-
sudo cp "$repo_root_dir"/scripts/chroot/build.sh miniroot/build.sh && sudo chroot miniroot qemu-aarch64-static /bin/sh -ex /build.sh
66+
sudo chroot miniroot qemu-aarch64-static /bin/sh -ex /scripts/chroot/build.sh
6367
elif [ "$ALPINE_ARCH" = "armhf" ] ; then
6468
echo "Architecture is armhf, hence using qemu-arm-static"
6569
sudo cp "$(which qemu-arm-static)" miniroot/usr/bin
66-
sudo cp "$repo_root_dir"/scripts/chroot/build.sh miniroot/build.sh && sudo chroot miniroot qemu-arm-static /bin/sh -ex /build.sh
70+
sudo cp "$repo_root_dir"/scripts/chroot/build.sh miniroot/build.sh && sudo chroot miniroot qemu-arm-static /bin/sh -ex /scripts/chroot/build.sh
6771
else
6872
echo "Edit chroot_build.sh to support this architecture as well, it should be easy"
6973
exit 1

0 commit comments

Comments
 (0)