Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- { qemu_arch: x86_64, appimage_arch: x86_64 }
- { qemu_arch: armv7, appimage_arch: armhf }
- { qemu_arch: aarch64, appimage_arch: aarch64 }
- { qemu_arch: loong64, appimage_arch: loong64 }

steps:
- name: Checkout
Expand All @@ -46,12 +47,21 @@ jobs:
git rev-parse --short HEAD | xargs >> src/runtime/version

- name: Build
if: matrix.appimage_arch != 'loong64'
env:
ARCHITECTURE: ${{ matrix.appimage_arch }}
run: |
sudo apt-get -y install qemu-user-static
./chroot_build.sh

- name: Build Loongarch
if: matrix.appimage_arch == 'loong64'
env:
ARCHITECTURE: ${{ matrix.appimage_arch }}
run: |
./prepare_loong64.sh
./chroot_build.sh

- name: Sign
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

miniroot
fuse-3.15.0
out
squa*
*.tar.*
tmp
9 changes: 8 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ if ! command -v apk; then
echo "This script should be run in an Alpine container"
exit 1
fi

if [ "$ARCHITECTURE" == "" ] && [ "$1" != "" ];then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, POSIX sh seems to only support [ xxx = yy ] i.e. single equal sign.

ARCHITECTURE=$1
fi
uname -m
apk update
if [ "$ARCHITECTURE" == "loong64" ];then
# only loong64 can install this package, other arch can not install it.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not because LoongArch is special, only that its Alpine baseline is different than others -- the package is also needed for other architectures if they're switched to Alpine 3.21.

For now though, the comment can be removed as having no additional info is better than inaccurate info, and the intent behind the code is at least kinda clear. Also, moving the installation of extra packages after the common ones should be more intuitive.

apk add --no-cache zstd-static
fi
apk add alpine-sdk util-linux strace file autoconf automake libtool xz

# Build static libfuse3 with patch for https://github.com/AppImage/type2-runtime/issues/10
Expand Down
20 changes: 18 additions & 2 deletions chroot_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@

set -ex

cleanup () {
if [ -d "./miniroot" ];then
sudo umount miniroot/proc miniroot/sys miniroot/dev
fi
# sudo rm -rf ./miniroot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this remnant of debugging code? It could be better to remove it before submitting for review.

}
trap cleanup EXIT

#############################################
# 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"
if [ "$ARCHITECTURE" = "loong64" ];then
wget -c "https://dev.alpinelinux.org/~loongarch/edge/releases/loongarch64/alpine-minirootfs-edge-240514-loongarch64.tar.gz" -O alpine-minirootfs-edge-240514-loong64.tar.gz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can switch to 3.21 and in fact unify the download logic here by parameterizing the version number. See #111 for an approach.

else
wget "http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/${ARCHITECTURE}/alpine-minirootfs-3.17.2-${ARCHITECTURE}.tar.gz"
fi
sudo rm -rf ./miniroot true # Clean up from previous runs
mkdir -p ./miniroot
cd ./miniroot
Expand Down Expand Up @@ -40,6 +51,11 @@ 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
elif [ "$ARCHITECTURE" = "loong64" ] ; then
# export PATH="./tmp/qemu-user-static/usr/bin:$PATH"
echo "Architecture is loongarch64, hence using qemu-loongarch64-static"
sudo cp "$(which qemu-loongarch64-static)" miniroot/usr/bin
sudo cp build.sh miniroot/build.sh && sudo chroot miniroot qemu-loongarch64-static /bin/sh -ex /build.sh $ARCHITECTURE
else
echo "Edit chroot_build.sh to support this architecture as well, it should be easy"
exit 1
Expand Down
34 changes: 34 additions & 0 deletions prepare_loong64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

set -ex

cleanup () {
echo "clean"
}
trap cleanup EXIT

mkdir -p tmp
cd tmp
mkdir -p qemu-user-static
cd qemu-user-static
wget -c https://archlinux.org/packages/extra/x86_64/qemu-user-static/download/ -O qemu-user-static.pkg.tar.zst
unzstd qemu-user-static.pkg.tar.zst
tar -xf qemu-user-static.pkg.tar
sudo mv ./usr/bin/* /usr/bin
ls -l /usr/bin/qemu-*
cd ..

mkdir -p qemu-user-static-binfmt
cd qemu-user-static-binfmt
wget -c https://archlinux.org/packages/extra/x86_64/qemu-user-static-binfmt/download/ -O qemu-user-static-binfmt.pkg.tar.zst
unzstd qemu-user-static-binfmt.pkg.tar.zst
tar -xf qemu-user-static-binfmt.pkg.tar
sudo mv ./usr/lib/binfmt.d/* /usr/lib/binfmt.d
ls -l /usr/lib/binfmt.d/qemu-*
cd ..

sudo systemctl restart systemd-binfmt.service

# from https://packages.ubuntu.com/noble/amd64/qemu-user-static/download
# wget -c http://kr.archive.ubuntu.com/ubuntu/pool/universe/q/qemu/qemu-user-static_8.2.2+ds-0ubuntu1_amd64.deb
# sudo dpkg -i qemu-user-static_8.2.2+ds-0ubuntu1_amd64.deb