Skip to content

Commit

Permalink
Satisfy shellcheck; do not install apt packages from shell script (#9)
Browse files Browse the repository at this point in the history
* Satisfy shellcheck in build.sh

* Satisfy shellcheck in chroot_build.sh

[ci skip]

* Install qemu-user-static in build.yaml

As suggested by @TheAssassin; so that the local system is not changed by running the shell scripts
  • Loading branch information
probonopd authored Jun 26, 2023
1 parent 2ea397a commit 7804775
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ jobs:
- name: Build
env:
ARCHITECTURE: ${{ matrix.appimage_arch }}
run: ./chroot_build.sh
run: |
sudo apt-get -y install qemu-user-static
./chroot_build.sh
- uses: actions/upload-artifact@v3
with:
Expand Down
11 changes: 6 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@ cd squashfuse-*/
./autogen.sh
./configure --help
./configure CFLAGS=-no-pie LDFLAGS=-static
make -j$(nproc)
make -j"$(nproc)"
make install
/usr/bin/install -c -m 644 *.h '/usr/local/include/squashfuse' # ll.h
/usr/bin/install -c -m 644 ./*.h '/usr/local/include/squashfuse' # ll.h
cd -

# Build static AppImage runtime
export GIT_COMMIT=$(cat src/runtime/version)
GIT_COMMIT="$(cat src/runtime/version)"
export GIT_COMMIT
cd src/runtime
make runtime-fuse3 -j$(nproc)
make runtime-fuse3 -j"$(nproc)"
file runtime-fuse3
strip runtime-fuse3
ls -lh runtime-fuse3
echo -ne 'AI\x02' | dd of=runtime-fuse3 bs=1 count=3 seek=8 conv=notrunc # magic bytes, always do AFTER strip
cd -

mkdir -p out
cp src/runtime/runtime-fuse3 out/runtime-fuse3-$ARCHITECTURE
cp src/runtime/runtime-fuse3 "out/runtime-fuse3-${ARCHITECTURE}"
12 changes: 5 additions & 7 deletions chroot_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ 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
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
sudo tar xf ../alpine-minirootfs-*-"${ARCHITECTURE}".tar.gz
cd -

#############################################
Expand All @@ -33,13 +33,11 @@ if [ "$ARCHITECTURE" = "x86" ] || [ "$ARCHITECTURE" = "x86_64" ]; then
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 apt-get -y install qemu-user-static
sudo cp $(which qemu-aarch64-static) miniroot/usr/bin
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 apt-get -y install qemu-user-static
sudo cp $(which qemu-arm-static) miniroot/usr/bin
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"
Expand All @@ -60,5 +58,5 @@ sudo umount miniroot/proc miniroot/sys miniroot/dev
if [ "$ARCHITECTURE" = "x86" ] ; then ARCHITECTURE=i686 ; fi

mkdir out/
sudo find miniroot/ -type f -executable -name 'runtime-fuse3' -exec cp {} out/runtime-$ARCHITECTURE \;
sudo find miniroot/ -type f -executable -name 'runtime-fuse3' -exec cp {} "out/runtime-${ARCHITECTURE}" \;
sudo rm -rf miniroot/

0 comments on commit 7804775

Please sign in to comment.