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
11 changes: 6 additions & 5 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ The chroot-based environment is designed for people who really do not want to us
To run a build, use the following command:

```sh
> env ALPINE_ARCH=<arch> chroot/chroot_build.sh
> env ALPINE_ARCH=<arch> scripts/chroot/chroot_build.sh

# example calls:
> env ALPINE_ARCH=x86_64 chroot/chroot_build.sh
> env ALPINE_ARCH=i686 chroot/chroot_build.sh
> env ALPINE_ARCH=armhf chroot/chroot_build.sh
> env ALPINE_ARCH=aarch64 chroot/chroot_build.sh
> env ALPINE_ARCH=x86_64 scripts/chroot/chroot_build.sh
> env ALPINE_ARCH=i686 scripts/chroot/chroot_build.sh
> env ALPINE_ARCH=armhf scripts/chroot/chroot_build.sh
> env ALPINE_ARCH=aarch64 scripts/chroot/chroot_build.sh
> env ALPINE_ARCH=loongarch64 scripts/chroot/chroot_build.sh
```

The script will download an Alpine miniroot image, extract it into a specific location, bind-mount a set of temporary filesystems (e.g., `/proc`) there, chroot into there and run the build script. It attempts to unmount the previously mounted paths again.
Expand Down
2 changes: 2 additions & 0 deletions scripts/build-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ elif [[ "$runtime" =~ EABI5 ]]; then
architecture=armhf
elif [[ "$runtime" =~ x86-64 ]]; then
architecture=x86_64
elif [[ "$runtime" =~ "64-bit .*, LoongArch" ]]; then
architecture=loongarch64
else
echo "Unsupported architecture: ${runtime#* }"
exit 2
Expand Down
18 changes: 15 additions & 3 deletions scripts/chroot/chroot_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -ex

if [ -z "${ALPINE_ARCH}" ]; then
echo "Usage: env ALPINE_ARCH=<arch> $0"
echo "Example values: x86_64 x86 armhf aarch64"
echo "Example values: x86_64 x86 armhf aarch64 loongarch64"
exit 2
fi

Expand Down Expand Up @@ -35,7 +35,14 @@ cd "$tempdir"
# Download and extract minimal Alpine system
#############################################

wget "http://dl-cdn.alpinelinux.org/alpine/v3.17/releases/${ALPINE_ARCH}/alpine-minirootfs-3.17.2-${ALPINE_ARCH}.tar.gz"
if [ "${ALPINE_ARCH}" = loongarch64 ]; then
alpine_version=3.21.0 # first version with support
else
alpine_version=3.17.2
fi

alpine_major_minor="${alpine_version%.*}"
wget "http://dl-cdn.alpinelinux.org/alpine/v${alpine_major_minor}/releases/${ALPINE_ARCH}/alpine-minirootfs-${alpine_version}-${ALPINE_ARCH}.tar.gz"
mkdir -p ./miniroot
cd ./miniroot
sudo tar xf ../alpine-minirootfs-*-"${ALPINE_ARCH}".tar.gz
Expand Down Expand Up @@ -72,6 +79,11 @@ elif [ "$ALPINE_ARCH" = "armhf" ] ; then
echo "Architecture is armhf, hence using qemu-arm-static"
sudo cp "$(which qemu-arm-static)" miniroot/usr/bin
sudo cp "$repo_root_dir"/scripts/chroot/build.sh miniroot/build.sh && sudo chroot miniroot qemu-arm-static /bin/sh -ex /scripts/chroot/build.sh
elif [ "$ALPINE_ARCH" = "loongarch64" ] ; then
echo "Architecture is loongarch64, hence using qemu-loongarch64-static"
sudo cp "$(which qemu-loongarch64-static)" miniroot/usr/bin
sudo cp "$repo_root_dir"/scripts/chroot/build.sh miniroot/build.sh && sudo chroot miniroot qemu-loongarch64-static /bin/sh -ex /scripts/chroot/build.sh

else
echo "Edit chroot_build.sh to support this architecture as well, it should be easy"
exit 1
Expand All @@ -94,4 +106,4 @@ esac
cd "$repo_root_dir"
mkdir -p ./out/
cp "${tempdir}/miniroot/out/runtime-${appimage_arch}" out/
cp "${tempdir}/miniroot/out/runtime-${appimage_arch}.debug" out/
cp "${tempdir}/miniroot/out/runtime-${appimage_arch}.debug" out/