Created
February 28, 2021 21:46
-
-
Save Piraty/2b0bd709c58ca2e8dd2240cc5b1141c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -ex | |
REPO_DEFAULT="https://alpha.de.repo.voidlinux.org/" | |
# packages of https://github.com/void-linux/void-packages/pull/29139 | |
: "${REPO_EXTRA:=""}" | |
: "${XBPS_TARGET_ARCH:=armv7l-musl}" | |
: "${ROOT:="/tmp/rootfs.void.$XBPS_TARGET_ARCH"}" | |
: "${CACHEDIR:="$HOME/void-binpkgs/$XBPS_TARGET_ARCH"}" | |
: "${PKG_EXTRA:=""}" | |
# determine repo url | |
if [ -z "$REPO" ]; then | |
case "$XBPS_TARGET_ARCH" in | |
aarch64*) | |
REPO="$REPO_DEFAULT/current/aarch64" | |
;; | |
*) | |
REPO="$REPO_DEFAULT/current" | |
;; | |
esac | |
# append -musl if necessary | |
case "$XBPS_TARGET_ARCH" in | |
aarch64*) : ;; #aarch64-musl lives in the same dir | |
*-musl) | |
REPO="$REPO/musl" | |
;; | |
esac | |
fi | |
# determine qemu command | |
if [ -z "$QEMU_CMD" ]; then | |
case "$XBPS_TARGET_ARCH" in | |
armv[67]*) _qemu_arch=arm ;; | |
aarch64*) _qemu_arch=aarch64 ;; | |
ppc64le*) _qemu_arch=ppc64le ;; | |
ppc64*) _qemu_arch=ppc64 ;; | |
ppc*) _qemu_arch=ppc ;; | |
esac | |
QEMU_CMD=qemu-${_qemu_arch}-static | |
fi | |
# fetch xbps-static for the foreign arch | |
t=/tmp/xbps.static.$XBPS_TARGET_ARCH | |
_xbps_static_path="$t/usr/bin" | |
if [ ! -e "$_xbps_static_path/xbps-install" ]; then | |
mkdir -p "$t" | |
_url="$REPO_DEFAULT/static/xbps-static-latest.$XBPS_TARGET_ARCH.tar.xz" | |
curl -L "$_url" | | |
tar -J -x -f - -C "$t" | |
fi | |
# install foreign rootfs | |
XBPS_TARGET_ARCH=$XBPS_TARGET_ARCH xbps-install \ | |
--rootdir="$ROOT" \ | |
--repository="$REPO" \ | |
--cachedir="$CACHEDIR" \ | |
--sync \ | |
--yes \ | |
base-system ${PKG_EXTRA} | |
# reconfigure foreign rootfs | |
$QEMU_CMD $_xbps_static_path/xbps-reconfigure \ | |
--rootdir="$ROOT" \ | |
--all | |
$QEMU_CMD $_xbps_static_path/xbps-pkgdb \ | |
--rootdir="$ROOT" \ | |
--all | |
### install rpi specific stuff | |
# install rpi-base from remote repo to mimic what mvlive would have done | |
$QEMU_CMD $_xbps_static_path/xbps-install \ | |
--rootdir="$ROOT" \ | |
--cachedir="$CACHEDIR" \ | |
--repository=/binpkgs-extra \ | |
-S rpi-base | |
rsync -avP --delete "$REPO_EXTRA"/ "$ROOT"/binpkgs-extra | |
# check if the new rpi-kernel meta package will pull the actual rpiN-kernel | |
xbps-query \ | |
--rootdir="$ROOT" \ | |
--repository="$ROOT"/binpkgs-extra \ | |
--ignore-conf-repos \ | |
-M -x rpi-kernel | |
# update rpi-kernel from custom repo | |
$QEMU_CMD $_xbps_static_path/xbps-install \ | |
--rootdir="$ROOT" \ | |
--cachedir="$CACHEDIR" \ | |
--repository="$ROOT"/binpkgs-extra \ | |
-Su | |
# check pkgdb | |
$QEMU_CMD $_xbps_static_path/xbps-pkgdb \ | |
--rootdir="$ROOT" \ | |
-a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment