From 8aa6ef89da62bfc0515bbc35346e4b80210d8f44 Mon Sep 17 00:00:00 2001 From: msojocs Date: Sun, 19 May 2024 15:32:04 +0800 Subject: [PATCH] feat: add loong64 support --- .github/workflows/build.yaml | 10 ++++++++++ .gitignore | 6 ++++++ build.sh | 19 +++++++++++++++++-- build_loong64.sh | 23 +++++++++++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100755 build_loong64.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index bd8c143..3dc6c31 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 @@ -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: | + docker run --rm --privileged loongcr.lcpu.dev/multiarch/archlinux --reset -p yes + ./build_loong64.sh + - name: Sign env: SIGNING_KEY: ${{ secrets.SIGNING_KEY }} diff --git a/.gitignore b/.gitignore index c6127b3..bd6769d 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,9 @@ modules.order Module.symvers Mkfile.old dkms.conf + +miniroot +fuse-3.15.0 +out +squa* +*.tar.* \ No newline at end of file diff --git a/build.sh b/build.sh index bbe669a..6c572e9 100755 --- a/build.sh +++ b/build.sh @@ -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.*/ @@ -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 @@ -54,4 +69,4 @@ echo -ne 'AI\x02' | dd of=runtime-fuse3 bs=1 count=3 seek=8 conv=notrunc # magic cd - mkdir -p out -cp src/runtime/runtime-fuse3 "out/runtime-fuse3-${ARCHITECTURE}" +cp src/runtime/runtime-fuse3 "out/runtime-${ARCHITECTURE}" diff --git a/build_loong64.sh b/build_loong64.sh new file mode 100755 index 0000000..89d3d3b --- /dev/null +++ b/build_loong64.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -ex + +repo_root="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")"/.)" +# image="lcr.loongnix.cn/library/alpine:3.19" +image="quay.io/msojocs/alpine-loong64:3.19" +platform="linux/loong64" +uid="$(id -u)" +docker run \ + --platform "$platform" \ + --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" \ + sh /source/build.sh