From 0cd2fa661e5c1c009cfd26d84e41063958f28659 Mon Sep 17 00:00:00 2001 From: langfingaz Date: Sat, 1 May 2021 17:04:27 +0200 Subject: [PATCH] installer script: work in progress (8) --- README.md | 2 +- build-archiso.sh | 2 +- pkg/de-p1st-installer/de-p1st-installer.sh | 33 ++++++++++++++++------ pkg/de-p1st-installer/installer.cfg | 2 +- pkg/de-p1st-installer/lib/util.sh | 12 ++++++++ 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index bc24864..8e3b70f 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Files from `/etc/skel` are copied to `/home/$USER` when new users are created. Example: [pkg/de-p1st-gnupg/PKGBUILD](pkg/de-p1st-gnupg/PKGBUILD) -### enabling services +### Enabling services * systemd.preset - Service enablement presets * [man 5 systemd.preset](https://www.systutorials.com/docs/linux/man/5-systemd.preset/) diff --git a/build-archiso.sh b/build-archiso.sh index 72a8366..950052a 100755 --- a/build-archiso.sh +++ b/build-archiso.sh @@ -12,7 +12,7 @@ # -> git # BUILD_DIR=./archlive -PKGS=('git' 'de-p1st-keyboard' 'de-p1st-nano' 'de-p1st-pacman' 'de-p1st-pacman-mirrorlist' 'de-p1st-systemd') +PKGS=('git' 'de-p1st-keyboard' 'de-p1st-nano' 'de-p1st-pacman' 'de-p1st-systemd') PACMAN_CFG_ADDITION='pkg/de-p1st-pacman/pacman.d/de-p1st' # will be used to extend the builder's pacman.conf diff --git a/pkg/de-p1st-installer/de-p1st-installer.sh b/pkg/de-p1st-installer/de-p1st-installer.sh index 74bac6b..2cd48cd 100755 --- a/pkg/de-p1st-installer/de-p1st-installer.sh +++ b/pkg/de-p1st-installer/de-p1st-installer.sh @@ -125,7 +125,7 @@ function get_default_mount_options() { function choose_mount_options() { # return: the following variables: - # FS_MOUNT_OPTIONS (array) + # FS_CHOSEN_MOUNT_OPTIONS (array) case "${FS}" in BTRFS) @@ -149,7 +149,7 @@ function choose_mount_options() { ;; esac - get_multi_choice FS_MOUNT_OPTIONS "Select mount options" TMP1 || return $? + get_multi_choice FS_CHOSEN_MOUNT_OPTIONS "Select mount options" TMP1 || return $? } function main() { @@ -163,15 +163,30 @@ function main() { partition "${TARGET_BLOCK_DEVICE}" "$BIOS_TYPE" || return $? format "$BIOS_TYPE" "${BOOT_PART}" "${LUKS_PART}" "${LUKS_PWD}" "${FS}" DATA_PART || return $? - # TODO: use FS_DEFAULT_MOUNT_OPTIONS and FS_MOUNT_OPTIONS in combination - mount "$DATA_PART" /mnt || return $? - mkdir /mnt/boot && mount "$BOOT_PART" /mnt/boot || return $? + # Combine default and chosen mount options + TMP1=("${FS_DEFAULT_MOUNT_OPTIONS[@]}" "${FS_CHOSEN_MOUNT_OPTIONS[@]}") || return $? + # Join array elements by "," + join_by "," TMP1 FS_MOUNT_OPTIONS || return $? + echo "Mounting data partition with options: ${FS_MOUNT_OPTIONS}" + mount -o "${FS_MOUNT_OPTIONS}" "$DATA_PART" /mnt || return $? + # mount boot partition + mkdir /mnt/boot || return $? + mount "$BOOT_PART" /mnt/boot || return $? + case "${BIOS_TYPE}" in + uefi) + pacstrap /mnt "${KERNEL}" "${KERNEL}-headers" de-p1st-base-efi || return $? + ;; + bios) + echo "Not yet implemented" + return 1 + ;; + *) + echo "Not yet implemented!" + return 1 + ;; + esac - # TODO: testing - # if bios type is bios then ... :/ - # amd/intel-ucode - pacstrap /mnt "${KERNEL}" "${KERNEL}-headers" de-p1st-base-efi } main "$@" diff --git a/pkg/de-p1st-installer/installer.cfg b/pkg/de-p1st-installer/installer.cfg index 6aa3cd4..e089042 100644 --- a/pkg/de-p1st-installer/installer.cfg +++ b/pkg/de-p1st-installer/installer.cfg @@ -11,7 +11,7 @@ KERNEL=linux TARGET_BLOCK_DEVICE=/dev/sda BOOT_PART_SIZE=500 # MiB FS=BTRFS -FS_MOUNT_OPTIONS=('noatime') +FS_CHOSEN_MOUNT_OPTIONS=('noatime') CPU_VENDOR=none BIOS_TYPE=uefi diff --git a/pkg/de-p1st-installer/lib/util.sh b/pkg/de-p1st-installer/lib/util.sh index c7a3711..9feefeb 100644 --- a/pkg/de-p1st-installer/lib/util.sh +++ b/pkg/de-p1st-installer/lib/util.sh @@ -1,3 +1,15 @@ +function join_by() { + # Join array elements with character $1 + # $1: delimiter + # $2: name of source array + # $3: variable name to store result + + local -n ptr=$2 || return $? + local -n ptr2=$3 || return $? + ptr2=$(printf ",%s" "${ptr[@]}") + ptr2=${ptr2:1} +} + function newline_to_space() { # Replaces all newlines with spaces # $1: name of variable