[HOWTO] Install Alpine Chroot for armhf/armv7/aarm64/x86

I created a simple script which downloads Alpine linux to a given folder.
This lets you install all Alpine packages on your openrt system.
If you add $PATH and library in profile you dont even need to chroot into alpine since its compiled with musl just like openwrt.

Intallation:
Just prepare some space on any folder and change "INSTALL" & "ARCH" to your corresponding path and platform.
After the installation you can chroot into the path and use it as a normal alpine install.

#!/bin/sh

INSTALL='/opt'
APKTOOLS='2.10.4-r1'
ARCH='aarch64'
MIRROR='http://dl-cdn.alpinelinux.org/alpine'
VER='v3.10'
RED='\033[0;31m'
NC='\033[0m'

printf "${RED}Downloading Static installer apk...${NC}\n"
wget $MIRROR/$VER/main/$ARCH/apk-tools-static-$APKTOOLS.apk
tar -xzf apk-tools-static-*.apk
rm apk-tools-static-*.apk
rm .PKGINFO


printf "\n${RED}Installing Base Alpine...${NC}\n"
./sbin/apk.static -X $MIRROR/$VER/main -U --allow-untrusted --root $INSTALL --initdb add alpine-base
rm -r ./sbin/



printf "\n${RED}Adding Repos to chroot${NC}\n"
echo "$MIRROR/$VER/main" > $INSTALL/etc/apk/repositories
echo "$MIRROR/$VER/community" >> $INSTALL/etc/apk/repositories
echo "http://nl.alpinelinux.org/alpine/edge/testing/" >> $INSTALL/etc/apk/repositories
chroot $INSTALL apk update
2 Likes

Once inside the chroot environment, you can build, debug, and run alpine packages. The guide can also be used to install Alpine Linux from a non- Alpine Linux livecd such as Ubuntu or System rescue CD. This example installation of Alpine Linux in a chroot will work with the latest release.
Here are steps l took how to install Alpine linux on Scaleway ARM64 servers: https://docsbay.net/alpine-linux-on-arm64
Hopefully it helps!

1 Like