build: use 64bit RaspiOS image

Signed-off-by: nachoparker <nacho@ownyourbits.com>
This commit is contained in:
nachoparker 2020-11-24 20:01:49 -07:00
parent 92156694f6
commit a335b5e2bf
3 changed files with 16 additions and 19 deletions

View File

@ -77,7 +77,7 @@ cleanup() {
trap "" EXIT
exit $RET
}
trap cleanup EXIT
trap cleanup EXIT
# get new code
####################

View File

@ -11,6 +11,7 @@
set -e
source buildlib.sh
URL="https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2020-08-24/2020-08-20-raspios-buster-arm64-lite.zip"
SIZE=3G # Raspbian image size
#CLEAN=0 # Pass this envvar to skip cleaning download cache
IMG="NextCloudPi_RPi_$( date "+%m-%d-%y" ).img"
@ -27,7 +28,7 @@ IMG=tmp/"$IMG"
trap clean_chroot_raspbian EXIT
prepare_dirs # tmp cache output
download_raspbian "$IMG"
download_raspbian "$URL" "$IMG"
resize_image "$IMG" "$SIZE"
update_boot_uuid "$IMG" # PARTUUID has changed after resize
@ -46,9 +47,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
sudo chroot raspbian_root /bin/bash <<'EOFCHROOT'
set -e
# avoid constant annoying spam due to qemu bug - ERROR: ld.so: object '/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so' from /etc/ld.so.preload
mv /etc/ld.so.preload /
# mark the image as an image build
touch /.ncp-image
@ -93,8 +91,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
echo "$cfg" > /usr/local/etc/ncp-config.d/SSH.cfg
rm -rf /tmp/ncp-build
mv /ld.so.preload /etc
EOFCHROOT
trap '' EXIT

View File

@ -23,7 +23,7 @@ function launch_install_qemu()
IMGOUT="$IMG-$( date +%s )"
cp --reflink=auto -v "$IMG" "$IMGOUT" || return 1
pgrep qemu-system-arm &>/dev/null && { echo -e "QEMU instance already running. Abort..."; return 1; }
pgrep qemu-system-aarch64 &>/dev/null && { echo -e "QEMU instance already running. Abort..."; return 1; }
launch_qemu "$IMGOUT" &
sleep 10
wait_SSH "$IP"
@ -135,7 +135,7 @@ function mount_raspbian()
local OFFSET=$(( SECTOR * 512 ))
mkdir -p "$MP"
sudo mount $IMG -o offset=$OFFSET "$MP" || return 1
echo "Raspbian image mounted"
echo "RaspiOS image mounted"
}
function mount_raspbian_boot()
@ -150,7 +150,7 @@ function mount_raspbian_boot()
local OFFSET=$(( SECTOR * 512 ))
mkdir -p "$MP"
sudo mount $IMG -o offset=$OFFSET "$MP" || return 1
echo "Raspbian image mounted"
echo "RaspiOS image mounted"
}
function umount_raspbian()
@ -158,7 +158,7 @@ function umount_raspbian()
[[ -d raspbian_root ]] || [[ -d raspbian_boot ]] || { echo "Nothing to umount"; return 0; }
[[ -d raspbian_root ]] && { sudo umount -l raspbian_root; rmdir raspbian_root || return 1; }
[[ -d raspbian_boot ]] && { sudo umount -l raspbian_boot; rmdir raspbian_boot || return 1; }
echo "Raspbian image umounted"
echo "RaspiOS image umounted"
}
function prepare_chroot_raspbian()
@ -170,7 +170,7 @@ function prepare_chroot_raspbian()
sudo mount -o bind /dev raspbian_root/dev/
sudo mount -o bind /dev/pts raspbian_root/dev/pts
sudo cp /usr/bin/qemu-arm-static raspbian_root/usr/bin
sudo cp /usr/bin/qemu-aarch64-static raspbian_root/usr/bin
# Prevent services from auto-starting
sudo bash -c "echo -e '#!/bin/sh\nexit 101' > raspbian_root/usr/sbin/policy-rc.d"
@ -179,7 +179,7 @@ function prepare_chroot_raspbian()
function clean_chroot_raspbian()
{
sudo rm -f raspbian_root/usr/bin/qemu-arm-static
sudo rm -f raspbian_root/usr/bin/qemu-aarch64-static
sudo rm -f raspbian_root/usr/sbin/policy-rc.d
sudo umount -l raspbian_root/{proc,sys,dev/pts,dev}
umount_raspbian
@ -268,11 +268,12 @@ function deactivate_unattended_upgrades()
function download_raspbian()
{
local IMGFILE=$1
local IMG_CACHE=cache/raspbian_lite.img
local ZIP_CACHE=cache/raspbian_lite.zip
local URL=$1
local IMGFILE=$2
local IMG_CACHE=cache/raspios_lite.img
local ZIP_CACHE=cache/raspios_lite.zip
echo -e "\n\e[1m[ Download Raspbian ]\e[0m"
echo -e "\n\e[1m[ Download RaspiOS ]\e[0m"
mkdir -p cache
test -f $IMG_CACHE && \
echo -e "INFO: $IMG_CACHE already exists. Skipping download ..." && \
@ -282,11 +283,11 @@ function download_raspbian()
test -f "$ZIP_CACHE" && {
echo -e "INFO: $ZIP_CACHE already exists. Skipping download ..."
} || {
wget https://downloads.raspberrypi.org/raspbian_lite_latest -O "$ZIP_CACHE" || return 1
wget "$URL" -O "$ZIP_CACHE" || return 1
}
unzip -o "$ZIP_CACHE" && \
mv *-raspbian-*.img $IMG_CACHE && \
mv *-raspios-*.img $IMG_CACHE && \
cp -v --reflink=auto $IMG_CACHE "$IMGFILE"
}