minor fixes and improvements

This commit is contained in:
Andreas Grapentin 2019-05-02 23:34:27 +02:00
parent 5447c151a7
commit 46ad14a48e
No known key found for this signature in database
GPG Key ID: 7171986E4B745536
2 changed files with 19 additions and 9 deletions

@ -137,7 +137,6 @@ main() {
sudo tar -c -f "$output" -C "$workdir" -X - . << EOF sudo tar -c -f "$output" -C "$workdir" -X - . << EOF
./boot/lost+found ./boot/lost+found
./etc/.updated ./etc/.updated
./etc/pacman.d/empty.conf
./etc/pacman.d/gnupg ./etc/pacman.d/gnupg
./lost+found ./lost+found
./root/.bash_history ./root/.bash_history

@ -22,7 +22,7 @@
. "$(librelib messages)" . "$(librelib messages)"
usage() { usage() {
print "usage: %s [-h] [-s SIZE] [-M MIRROR] [-H HOOK]... IMG ARCH" "${0##*/}" print "usage: %s [-hO] [-s SIZE] [-M MIRROR] [-H HOOK]... IMG ARCH" "${0##*/}"
prose "Produce preconfigured parabola GNU/Linux-libre virtual machine instances." prose "Produce preconfigured parabola GNU/Linux-libre virtual machine instances."
echo echo
prose "The produced image file is written to IMG, and is configured and prose "The produced image file is written to IMG, and is configured and
@ -32,6 +32,7 @@ usage() {
custom package mirrors)" custom package mirrors)"
echo echo
echo "Supported options:" echo "Supported options:"
echo " -O bootstrap an openrc system instead of a systemd one"
echo " -s SIZE Set the size of the VM image (default: 64GiB)" echo " -s SIZE Set the size of the VM image (default: 64GiB)"
echo " -M MIRROR Choose a different mirror to pacstrap from" echo " -M MIRROR Choose a different mirror to pacstrap from"
echo " default: <https://repo.parabola.nu/\$repo/os/\$arch>" echo " default: <https://repo.parabola.nu/\$repo/os/\$arch>"
@ -180,10 +181,14 @@ Server = $mirror
EOF EOF
# prepare lists of packages # prepare lists of packages
local pkg=(base haveged openssh openresolv ldns net-tools) local pkg=("base$init" "openssh$init" openresolv ldns)
case "$arch" in case "$arch" in
i686|x86_64) pkg+=(grub) ;; i686|x86_64) pkg+=(grub) ;;
esac esac
case "$arch" in
riscv64) ;;
*) pkg+=("haveged$init" net-tools) ;;
esac
local pkg_guest_cache=(ca-certificates-utils) local pkg_guest_cache=(ca-certificates-utils)
# pacstrap! :) # pacstrap! :)
@ -191,11 +196,15 @@ EOF
sudo pacstrap -GM -C "$pacconf" "$workdir" "${pkg_guest_cache[@]}" || return sudo pacstrap -GM -C "$pacconf" "$workdir" "${pkg_guest_cache[@]}" || return
# create an fstab # create an fstab
sudo swapoff --all case "$arch" in
sudo swapon "$swapdev" riscv64) ;;
genfstab -U "$workdir" | sudo tee "$workdir"/etc/fstab *)
sudo swapoff "$swapdev" sudo swapoff --all
sudo swapon --all sudo swapon "$swapdev"
genfstab -U "$workdir" | sudo tee "$workdir"/etc/fstab
sudo swapoff "$swapdev"
sudo swapon --all ;;
esac
# produce a hostname # produce a hostname
echo "parabola" | sudo tee "$workdir"/etc/hostname echo "parabola" | sudo tee "$workdir"/etc/hostname
@ -353,10 +362,12 @@ main() {
local size="64G" local size="64G"
local mirror="https://repo.parabola.nu/\$repo/os/\$arch" local mirror="https://repo.parabola.nu/\$repo/os/\$arch"
local hooks=() local hooks=()
local init
# parse options # parse options
while getopts 'hs:M:H:' arg; do while getopts 'hOs:M:H:' arg; do
case "$arg" in case "$arg" in
O) init="-openrc";;
h) usage; return "$EXIT_SUCCESS";; h) usage; return "$EXIT_SUCCESS";;
s) size="$OPTARG";; s) size="$OPTARG";;
M) mirror="$OPTARG";; M) mirror="$OPTARG";;