Skip to content

Commit

Permalink
feat: add loong64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
msojocs committed May 19, 2024
1 parent 47b6655 commit ec1d06f
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
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:
ARCH: ${{ matrix.appimage_arch }}
run: |
docker run --rm --privileged loongcr.lcpu.dev/multiarch/archlinux --reset -p yes
./build_docker.sh
- name: Sign
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

miniroot
fuse-3.15.0
out
squa*
*.tar.*
17 changes: 16 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@

set -ex

cleanup () {
if [ -d "$build_dir" ]; then
rm -rf "$build_dir"
fi
}
trap cleanup EXIT

if ! command -v apk; then
echo "This script should be run in an Alpine container"
exit 1
fi

rm -rf fuse-*
rm -rf squashfuse-*

apk update
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
apk add eudev-dev gettext-dev linux-headers meson # From https://git.alpinelinux.org/aports/tree/main/fuse3/APKBUILD
wget -c -q "https://github.com/libfuse/libfuse/releases/download/fuse-3.15.0/fuse-3.15.0.tar.xz"
if [ ! -f "fuse-3.15.0.tar.xz" ];then
wget -c -q "https://github.com/libfuse/libfuse/releases/download/fuse-3.15.0/fuse-3.15.0.tar.xz"
fi
echo "70589cfd5e1cff7ccd6ac91c86c01be340b227285c5e200baa284e401eea2ca0 fuse-3.15.0.tar.xz" | sha256sum -c
tar xf fuse-3.*.tar.xz
cd fuse-3.*/
Expand All @@ -29,6 +41,9 @@ export CFLAGS="-ffunction-sections -fdata-sections -Os"

# Build static squashfuse
apk add zstd-dev zlib-dev zlib-static # fuse3-dev fuse3-static fuse-static fuse-dev
if [ "$ARCHITECTURE" == "loong64" ];then
apk add --no-cache zstd-static
fi
find / -name "libzstd.*" 2>/dev/null || true
wget -c -q "https://github.com/vasi/squashfuse/archive/e51978c.tar.gz"
echo "f544029ad30d8fbde4e4540c574b8cdc6d38b94df025a98d8551a9441f07d341 e51978c.tar.gz" | sha256sum -c
Expand Down
59 changes: 59 additions & 0 deletions build_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -ex

if [[ "${ARCH:-}" == "" ]]; then
echo "Usage: env ARCH=... bash $0"
exit 1
fi

repo_root="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")"/.)"

case "$ARCH" in
x86_64)
image_prefix=amd64/alpine
platform=linux/amd64
;;
i686)
image_prefix=i386/alpine
platform=linux/i386
;;
armhf)
image_prefix=arm32v7/alpine
platform=linux/arm/v7
;;
aarch64)
image_prefix=arm64v8/alpine
platform=linux/arm64/v8
;;
loong64)
# image_prefix=lcr.loongnix.cn/library # official unsatble
image_prefix=quay.io/msojocs/alpine-loong64
platform=linux/loong64
;;
*)
echo "unknown architecture: $ARCH"
exit 2
;;
esac

uid="$(id -u)"
docker run \
--rm \
-i \
-e ARCH \
-e GITHUB_ACTIONS \
-e GITHUB_RUN_NUMBER \
-e ARCHITECTURE="loong64" \
-e OUT_UID="$uid" \
-v "$repo_root":/source \
-v "$PWD":/out \
-w /out \
"$image_prefix:3.19" \
sh <<\EOF
/source/build.sh
chown "$OUT_UID" out
chown "$OUT_UID" out/*
EOF

mv out/runtime-fuse3-loong64 out/runtime-loong64

0 comments on commit ec1d06f

Please sign in to comment.