diff --git a/scripts/build_image/build_alpine.bash b/scripts/build_image/build_alpine.bash index edea4e3..2931413 100755 --- a/scripts/build_image/build_alpine.bash +++ b/scripts/build_image/build_alpine.bash @@ -9,19 +9,19 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function cleanup { for f in "${jails[@]}"; do >&2 echo "Stopping jail $f" - sudo jail -r "$f" + jail -r "$f" done for (( idx=${#mountedfolders[@]}-1 ; idx>=0 ; idx-- )) ; do >&2 echo "Unmounting folder ${mountedfolders[idx]}" - sudo umount "${mountedfolders[idx]}" + umount "${mountedfolders[idx]}" done for f in "${memorydevices[@]}"; do >&2 echo "Removing memory device $f" - sudo mdconfig -d -u "$f" + mdconfig -d -u "$f" done for f in "${folders[@]}"; do >&2 echo "Deleting $f" - # sudo rm -rf "$f" + # rm -rf "$f" done } folders=() @@ -127,6 +127,10 @@ Mkc= function precheck { # Checks to run before building the image + if [ $(id -u) -ne 0 ]; then + die 1 "Must run as root." + fi + if ! grep -q 'linux.ko' <<<"$(kldstat)"; then die 1 "Need linux kernel module for building initramfs." fi @@ -165,21 +169,21 @@ function make_chroot { # Enter the jail # install mkinitfs - jid=$(sudo jail -c -i path="$chroot" ip4=inherit ip6=inherit host=inherit allow.raw_sockets=true persist) + jid=$(jail -c -i path="$chroot" ip4=inherit ip6=inherit host=inherit allow.raw_sockets=true persist) jails+=("$jid") - sudo jexec "$jid" apk add --no-cache mkinitfs docker linux-virt - sudo jexec "$jid" apk add --no-cache --repository 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' refind - sudo jexec "$jid" mkinitfs -c /etc/mkinitfs/mkinitfs.conf -b / 5.15.16-0-virt - sudo jexec "$jid" mkdir /boot/efi - sudo jexec "$jid" cp -r /usr/share/refind /boot/efi/boot - sudo jexec "$jid" cp /boot/efi/boot/refind_x64.efi /boot/efi/boot/bootx64.efi - (umask 022 && sudo tee "${chroot}/boot/refind_linux.conf" <