-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathchroot_build.sh
executable file
·72 lines (59 loc) · 3.23 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
64
65
66
67
68
69
70
71
72
#!/bin/sh
set -ex
#############################################
# Download and extract minimal Alpine system
#############################################
wget "http://dl-cdn.alpinelinux.org/alpine/v3.15/releases/${ARCHITECTURE}/alpine-minirootfs-3.15.4-${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-fuse3-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'patchelf' -exec cp {} out/patchelf-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'zsyncmake' -exec cp {} out/zsyncmake-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'mksquashfs' -exec cp {} out/mksquashfs-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'unsquashfs' -exec cp {} out/unsquashfs-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'bsdtar' -exec cp {} out/bsdtar-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'desktop-file-install' -exec cp {} out/desktop-file-install-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'desktop-file-validate' -exec cp {} out/desktop-file-validate-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'update-desktop-database' -exec cp {} out/update-desktop-database-$ARCHITECTURE \;
sudo cp miniroot/appstream-0.12.9/prefix/bin/appstreamcli out/appstreamcli-$ARCHITECTURE
sudo rm -rf miniroot/