-
Notifications
You must be signed in to change notification settings - Fork 29
feat: add loong64 support #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,3 +50,10 @@ modules.order | |
| Module.symvers | ||
| Mkfile.old | ||
| dkms.conf | ||
|
|
||
| miniroot | ||
| fuse-3.15.0 | ||
| out | ||
| squa* | ||
| *.tar.* | ||
| tmp | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| ARCHITECTURE=$1 | ||
| fi | ||
| uname -m | ||
| apk update | ||
| if [ "$ARCHITECTURE" == "loong64" ];then | ||
| # only loong64 can install this package, other arch can not install it. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,22 @@ | |
|
|
||
| set -ex | ||
|
|
||
| cleanup () { | ||
| if [ -d "./miniroot" ];then | ||
| sudo umount miniroot/proc miniroot/sys miniroot/dev | ||
| fi | ||
| # sudo rm -rf ./miniroot | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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 | ||
|
|
||
| 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 |
There was a problem hiding this comment.
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.