forked from AppImage/type2-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchroot_build.sh
executable file
·63 lines (50 loc) · 2.29 KB
/
chroot_build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
set -ex
#############################################
# Download and extract minimal Alpine system
#############################################
wget "http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/${ARCHITECTURE}/alpine-minirootfs-3.17.2-${ARCHITECTURE}.tar.gz"
sudo rm -rf ./miniroot true # Clean up from previous runs
mkdir -p ./miniroot
cd ./miniroot
sudo tar xf ../alpine-minirootfs-*-"${ARCHITECTURE}".tar.gz
cd -
#############################################
# Prepare chroot
#############################################
sudo cp -r ./src miniroot/src
sudo cp -r ./patches miniroot/patches
sudo mount -o bind /dev miniroot/dev
sudo mount -t proc none miniroot/proc
sudo mount -t sysfs none miniroot/sys
sudo cp -p /etc/resolv.conf miniroot/etc/
#############################################
# Run build.sh in chroot
#############################################
if [ "$ARCHITECTURE" = "x86" ] || [ "$ARCHITECTURE" = "x86_64" ]; then
echo "Architecture is x86 or x86_64, hence not using qemu-arm-static"
sudo cp build.sh miniroot/build.sh && sudo chroot miniroot /bin/sh -ex /build.sh
elif [ "$ARCHITECTURE" = "aarch64" ] ; then
echo "Architecture is aarch64, hence using qemu-aarch64-static"
sudo cp "$(which qemu-aarch64-static)" miniroot/usr/bin
sudo cp build.sh miniroot/build.sh && sudo chroot miniroot qemu-aarch64-static /bin/sh -ex /build.sh
elif [ "$ARCHITECTURE" = "armhf" ] ; then
echo "Architecture is armhf, hence using qemu-arm-static"
sudo cp "$(which qemu-arm-static)" miniroot/usr/bin
sudo cp build.sh miniroot/build.sh && sudo chroot miniroot qemu-arm-static /bin/sh -ex /build.sh
else
echo "Edit chroot_build.sh to support this architecture as well, it should be easy"
exit 1
fi
#############################################
# Clean up chroot
#############################################
sudo umount miniroot/proc miniroot/sys miniroot/dev
#############################################
# Copy build artefacts out
#############################################
# Use the same architecture names as https://github.com/AppImage/AppImageKit/releases/
if [ "$ARCHITECTURE" = "x86" ] ; then ARCHITECTURE=i686 ; fi
mkdir out/
sudo find miniroot/ -type f -executable -name 'runtime-fuse3' -exec cp {} "out/runtime-${ARCHITECTURE}" \;
sudo rm -rf miniroot/