From 2dace79d5407aca519a5e27c5b02e32678a8feca Mon Sep 17 00:00:00 2001 From: Tobias Powalowski Date: Mon, 21 Mar 2022 22:25:15 +0100 Subject: [PATCH] break setup into functions --- usr/bin/archboot-aarch64-create-container.sh | 4 +- usr/bin/archboot-aarch64-create-repository.sh | 6 +- usr/bin/archboot-aarch64-iso.sh | 4 +- .../archboot-aarch64-pacman-chroot-tarball.sh | 4 +- usr/bin/archboot-aarch64-release.sh | 4 +- usr/bin/archboot-aarch64-server-release.sh | 4 +- usr/bin/archboot-bootloader.sh | 4 +- usr/bin/archboot-quickinst.sh | 2 +- usr/bin/archboot-setup.sh | 4443 +---------------- usr/bin/archboot-update-installer.sh | 27 +- usr/bin/archboot-x86_64-create-container.sh | 4 +- usr/bin/archboot-x86_64-create-repository.sh | 6 +- usr/bin/archboot-x86_64-iso.sh | 4 +- usr/bin/archboot-x86_64-release.sh | 4 +- usr/bin/archboot-x86_64-server-release.sh | 4 +- .../{bootloader_functions => bootloader.sh} | 0 usr/lib/archboot/{functions => common.sh} | 0 .../{container_functions => container.sh} | 0 .../archboot/installer/autoconfiguration.sh | 189 + usr/lib/archboot/installer/autoprepare.sh | 341 ++ usr/lib/archboot/installer/base.sh | 33 + usr/lib/archboot/installer/blockdevices.sh | 1073 ++++ usr/lib/archboot/installer/bootloader.sh | 1322 +++++ usr/lib/archboot/installer/btrfs.sh | 282 ++ .../common.sh} | 0 usr/lib/archboot/installer/configuration.sh | 84 + usr/lib/archboot/installer/mountpoints.sh | 432 ++ usr/lib/archboot/installer/network.sh | 150 + usr/lib/archboot/installer/pacman.sh | 185 + usr/lib/archboot/installer/partition.sh | 190 + usr/lib/archboot/installer/storage.sh | 156 + usr/lib/archboot/{iso_functions => iso.sh} | 0 .../{release_functions => release.sh} | 0 .../{repository_functions => repository.sh} | 0 .../archboot/{server_functions => server.sh} | 0 35 files changed, 4507 insertions(+), 4454 deletions(-) rename usr/lib/archboot/{bootloader_functions => bootloader.sh} (100%) rename usr/lib/archboot/{functions => common.sh} (100%) rename usr/lib/archboot/{container_functions => container.sh} (100%) create mode 100644 usr/lib/archboot/installer/autoconfiguration.sh create mode 100644 usr/lib/archboot/installer/autoprepare.sh create mode 100644 usr/lib/archboot/installer/base.sh create mode 100644 usr/lib/archboot/installer/blockdevices.sh create mode 100644 usr/lib/archboot/installer/bootloader.sh create mode 100644 usr/lib/archboot/installer/btrfs.sh rename usr/lib/archboot/{installer_common_functions => installer/common.sh} (100%) create mode 100644 usr/lib/archboot/installer/configuration.sh create mode 100644 usr/lib/archboot/installer/mountpoints.sh create mode 100644 usr/lib/archboot/installer/network.sh create mode 100644 usr/lib/archboot/installer/pacman.sh create mode 100644 usr/lib/archboot/installer/partition.sh create mode 100644 usr/lib/archboot/installer/storage.sh rename usr/lib/archboot/{iso_functions => iso.sh} (100%) rename usr/lib/archboot/{release_functions => release.sh} (100%) rename usr/lib/archboot/{repository_functions => repository.sh} (100%) rename usr/lib/archboot/{server_functions => server.sh} (100%) diff --git a/usr/bin/archboot-aarch64-create-container.sh b/usr/bin/archboot-aarch64-create-container.sh index 12add72b0..500940ae2 100755 --- a/usr/bin/archboot-aarch64-create-container.sh +++ b/usr/bin/archboot-aarch64-create-container.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # created by Tobias Powalowski -source /usr/lib/archboot/functions -source /usr/lib/archboot/container_functions +source /usr/lib/archboot/common.sh +source /usr/lib/archboot/container.sh _ARCHBOOT="archboot-arm" _KEYRING="archlinuxarm" [[ -z "${1}" ]] && _usage diff --git a/usr/bin/archboot-aarch64-create-repository.sh b/usr/bin/archboot-aarch64-create-repository.sh index 10bc169b4..3695f0a3c 100755 --- a/usr/bin/archboot-aarch64-create-repository.sh +++ b/usr/bin/archboot-aarch64-create-repository.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash # created by Tobias Powalowski -source /usr/lib/archboot/functions -source /usr/lib/archboot/container_functions -source /usr/lib/archboot/repository_functions +source /usr/lib/archboot/common.sh +source /usr/lib/archboot/container.sh +source /usr/lib/archboot/repository.sh _ARCHBOOT="archboot-arm" [[ -d "${1}" ]] || (echo "Create directory ${1} ..."; mkdir "${1}") _REPODIR="$(mktemp -d "${1}"/repository.XXX)" diff --git a/usr/bin/archboot-aarch64-iso.sh b/usr/bin/archboot-aarch64-iso.sh index 58e555ce6..f50bb5067 100755 --- a/usr/bin/archboot-aarch64-iso.sh +++ b/usr/bin/archboot-aarch64-iso.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # created by Tobias Powalowski -source /usr/lib/archboot/functions -source /usr/lib/archboot/iso_functions +source /usr/lib/archboot/common.sh +source /usr/lib/archboot/iso.sh [[ -z "${1}" ]] && _usage _parameters "$@" _root_check diff --git a/usr/bin/archboot-aarch64-pacman-chroot-tarball.sh b/usr/bin/archboot-aarch64-pacman-chroot-tarball.sh index 0b133f659..006df0f61 100755 --- a/usr/bin/archboot-aarch64-pacman-chroot-tarball.sh +++ b/usr/bin/archboot-aarch64-pacman-chroot-tarball.sh @@ -2,8 +2,8 @@ # created by Tobias Powalowski _ARCH="aarch64" source /etc/archboot/defaults -source /usr/lib/archboot/functions -source /usr/lib/archboot/container_functions +source /usr/lib/archboot/common.sh +source /usr/lib/archboot/container.sh _LATEST_ARM64="http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz" _KEYRING="archlinuxarm" diff --git a/usr/bin/archboot-aarch64-release.sh b/usr/bin/archboot-aarch64-release.sh index 0a689ce9e..2bd4a5968 100755 --- a/usr/bin/archboot-aarch64-release.sh +++ b/usr/bin/archboot-aarch64-release.sh @@ -2,8 +2,8 @@ # created by Tobias Powalowski _ARCH="aarch64" _ARCHBOOT="archboot-arm" -source /usr/lib/archboot/functions -source /usr/lib/archboot/release_functions +source /usr/lib/archboot/common.sh +source /usr/lib/archboot/release.sh [[ -z "${1}" ]] && _usage _root_check echo "Start release creation in $1 ..." diff --git a/usr/bin/archboot-aarch64-server-release.sh b/usr/bin/archboot-aarch64-server-release.sh index fa80f32e4..da53498ff 100755 --- a/usr/bin/archboot-aarch64-server-release.sh +++ b/usr/bin/archboot-aarch64-server-release.sh @@ -1,7 +1,7 @@ #! /bin/bash _ARCH="aarch64" -source /usr/lib/archboot/functions -source /usr/lib/archboot/server_functions +source /usr/lib/archboot/common.sh +source /usr/lib/archboot/server.sh _root_check _update_aarch64_pacman_chroot || exit 1 _update_source diff --git a/usr/bin/archboot-bootloader.sh b/usr/bin/archboot-bootloader.sh index 34f053a9c..75039f0c1 100755 --- a/usr/bin/archboot-bootloader.sh +++ b/usr/bin/archboot-bootloader.sh @@ -1,6 +1,6 @@ #!/bin/bash -source /usr/lib/archboot/functions -source /usr/lib/archboot/bootloader_functions +source /usr/lib/archboot/common.sh +source /usr/lib/archboot/bootloader.sh _SHIM=$(mktemp -d shim.XXX) _SHIM32=$(mktemp -d shim32.XXX) _SHIMAA64=$(mktemp -d shimaa64.XXX) diff --git a/usr/bin/archboot-quickinst.sh b/usr/bin/archboot-quickinst.sh index de66b34c5..c80686c71 100755 --- a/usr/bin/archboot-quickinst.sh +++ b/usr/bin/archboot-quickinst.sh @@ -1,5 +1,5 @@ #!/bin/bash -source /usr/lib/archboot/installer_common_functions +. /usr/lib/archboot/installer/common.sh DESTDIR="${1}" usage() { diff --git a/usr/bin/archboot-setup.sh b/usr/bin/archboot-setup.sh index b37700f47..07624cc8b 100755 --- a/usr/bin/archboot-setup.sh +++ b/usr/bin/archboot-setup.sh @@ -1,5 +1,17 @@ #!/bin/bash -source /usr/lib/archboot/installer_common_functions +. /usr/lib/archboot/installer/autoconfiguration.sh +. /usr/lib/archboot/installer/autoprepare.sh +. /usr/lib/archboot/installer/base.sh +. /usr/lib/archboot/installer/blockdevices.sh +. /usr/lib/archboot/installer/bootloader.sh +. /usr/lib/archboot/installer/btrfs.sh +. /usr/lib/archboot/installer/common.sh +. /usr/lib/archboot/installer/configuration.sh +. /usr/lib/archboot/installer/mountpoints.sh +. /usr/lib/archboot/installer/network.sh +. /usr/lib/archboot/installer/pacman.sh +. /usr/lib/archboot/installer/partition.sh +. /usr/lib/archboot/installer/storage.sh ANSWER="/tmp/.setup" # use the first VT not dedicated to a running console # don't use DESTDIR=/mnt because it's intended to mount other things there! @@ -12,8 +24,6 @@ else LOG="/dev/tty8" fi EDITOR="" -_BLKID="blkid -c /dev/null" -_LSBLK="lsblk -rpno" # name of the initramfs filesystem INITRAMFS="initramfs-${KERNELPKG}" # name of intel ucode initramfs image @@ -37,4011 +47,13 @@ S_CONFIG=0 # configuration editing # menu item tracker- autoselect the next item NEXTITEM="" -set_title() { - if [[ -e "${LOCAL_DB}" ]]; then - TITLE="Arch Linux Installation (Local mode) --> wiki.archlinux.org/title/Archboot" +set_keyboard() { + if [[ -e /usr/bin/km ]]; then + km --setup && NEXTITEM="1" + elif [[ -e /usr/bin/archboot-km.sh ]]; then + archboot-km.sh --setup && NEXTITEM="1" else - TITLE="Arch Linux Installation (Online mode) --> wiki.archlinux.org/title/Archboot" - fi -} - -# DIALOG() -# an el-cheapo dialog wrapper -# -# parameters: see dialog(1) -# returns: whatever dialog did -DIALOG() { - dialog --backtitle "${TITLE}" --aspect 15 "$@" - return $? -} - -getfstype() -{ - ${_LSBLK} FSTYPE "${1}" -} - -# getfsuuid() -# converts /dev devices to FSUUIDs -# -# parameters: device file -# outputs: FSUUID on success -# nothing on failure -# returns: nothing -getfsuuid() -{ - ${_LSBLK} UUID "${1}" -} - -# parameters: device file -# outputs: LABEL on success -# nothing on failure -# returns: nothing -getfslabel() -{ - ${_LSBLK} LABEL "${1}" -} - -getpartuuid() -{ - ${_LSBLK} PARTUUID "${1}" -} - -getpartlabel() -{ - ${_LSBLK} PARTLABEL "${1}" -} - -# list all net devices with mac adress -net_interfaces() { - find /sys/class/net/* -type l -printf '%f ' -exec cat {}/address \; -} - -# activate_dmraid() -# activate dmraid devices -activate_dmraid() -{ - if [[ -e /usr/bin/dmraid ]]; then - DIALOG --infobox "Activating dmraid arrays..." 0 0 - dmraid -ay -I -Z >/dev/null 2>&1 - fi -} - -# activate_lvm2 -# activate lvm2 devices -activate_lvm2() -{ - ACTIVATE_LVM2="" - if [[ -e /usr/bin/lvm ]]; then - OLD_LVM2_GROUPS=${LVM2_GROUPS} - OLD_LVM2_VOLUMES=${LVM2_VOLUMES} - DIALOG --infobox "Scanning logical volumes..." 0 0 - lvm vgscan --ignorelockingfailure >/dev/null 2>&1 - DIALOG --infobox "Activating logical volumes..." 0 0 - lvm vgchange --ignorelockingfailure --ignoremonitoring -ay >/dev/null 2>&1 - LVM2_GROUPS="$(vgs -o vg_name --noheading 2>/dev/null)" - LVM2_VOLUMES="$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)" - [[ "${OLD_LVM2_GROUPS}" = "${LVM2_GROUPS}" && "${OLD_LVM2_VOLUMES}" = "${LVM2_VOLUMES}" ]] && ACTIVATE_LVM2="no" - fi -} - -# activate_raid -# activate md devices -activate_raid() -{ - ACTIVATE_RAID="" - if [[ -e /usr/bin/mdadm ]]; then - DIALOG --infobox "Activating RAID arrays..." 0 0 - mdadm --assemble --scan >/dev/null 2>&1 || ACTIVATE_RAID="no" - fi -} - -# activate_luks -# activate luks devices -activate_luks() -{ - ACTIVATE_LUKS="" - if [[ -e /usr/bin/cryptsetup ]]; then - DIALOG --infobox "Scanning for luks encrypted devices..." 0 0 - if ${_LSBLK} FSTYPE | grep -q "crypto_LUKS"; then - for PART in $(${_LSBLK} NAME,FSTYPE | grep " crypto_LUKS$" | cut -d' ' -f 1); do - # skip already encrypted devices, device mapper! - if ! ${_LSBLK} TYPE "${PART}" | grep -q "crypt$"; then - RUN_LUKS="" - DIALOG --yesno "Setup detected luks encrypted device, do you want to activate ${PART} ?" 0 0 && RUN_LUKS="1" - [[ "${RUN_LUKS}" = "1" ]] && _enter_luks_name && _enter_luks_passphrase && _opening_luks - [[ "${RUN_LUKS}" = "" ]] && ACTIVATE_LUKS="no" - else - ACTIVATE_LUKS="no" - fi - done - else - ACTIVATE_LUKS="no" - fi - fi -} - -# activate_special_devices() -# activate special devices: -# activate dmraid, lvm2 and raid devices, if not already activated during bootup! -# run it more times if needed, it can be hidden by each other! -activate_special_devices() -{ - ACTIVATE_RAID="" - ACTIVATE_LUKS="" - ACTIVATE_LVM2="" - activate_dmraid - while ! [[ "${ACTIVATE_LVM2}" = "no" && "${ACTIVATE_RAID}" = "no" && "${ACTIVATE_LUKS}" = "no" ]]; do - activate_raid - activate_lvm2 - activate_luks - done -} - -# destdir_mounts() -# check if PART_ROOT is set and if something is mounted on ${DESTDIR} -destdir_mounts(){ - # Don't ask for filesystem and create new filesystems - ASK_MOUNTPOINTS="" - PART_ROOT="" - # check if something is mounted on ${DESTDIR} - PART_ROOT="$(mount | grep "${DESTDIR} " | cut -d' ' -f 1)" - # Run mountpoints, if nothing is mounted on ${DESTDIR} - if [[ "${PART_ROOT}" = "" ]]; then - DIALOG --msgbox "Setup couldn't detect mounted partition(s) in ${DESTDIR}, please set mountpoints first." 0 0 - detect_uefi_boot - mountpoints || return 1 - fi -} - -# lists linux blockdevices -blockdevices() { - # all available block disk devices - for dev in $(${_LSBLK} NAME,TYPE | grep "disk$" | cut -d' ' -f1); do - # exclude checks: - #- dmraid_devices - # ${_LSBLK} TYPE ${dev} | grep "dmraid" - #- iso9660 devices - # (${_LSBLK} FSTYPE ${dev} | grep "iso9660" - #- fakeraid isw devices - # ${_LSBLK} FSTYPE ${dev} | grep "isw_raid_member" - #- fakeraid ddf devices - # ${_LSBLK} FSTYPE ${dev} | grep "ddf_raid_member" - if ! ${_LSBLK} TYPE "${dev}" 2>/dev/null | grep -q "dmraid" || ${_LSBLK} FSTYPE "${dev}" 2>/dev/null | grep -q "iso9660" || ${_LSBLK} FSTYPE "${dev}" 2>/dev/null | grep -q "isw_raid_member" || ${_LSBLK} FSTYPE "${dev}" 2>/dev/null | grep -q "ddf_raid_member"; then - echo "${dev}" - [[ "${1}" ]] && echo "${1}" - fi - done -} - -# lists linux blockdevice partitions -blockdevices_partitions() { - # all available block devices partitions - # printk off needed cause of parted usage - printk off - for part in $(${_LSBLK} NAME,TYPE | grep -v '^/dev/md' | grep "part$"| cut -d' ' -f1); do - # exclude checks: - #- part of raid device - # ${_LSBLK} FSTYPE ${part} | grep "linux_raid_member" - #- part of lvm2 device - # ${_LSBLK} FSTYPE /dev/${part} | grep "LVM2_member" - #- part of luks device - # ${_LSBLK} FSTYPE /dev/${part} | grep "crypto_LUKS" - #- extended partition - # sfdisk -l 2>/dev/null | grep "${part}" | grep "Extended$" - # - extended partition (LBA) - # sfdisk -l 2>/dev/null | grep "${part}" | grep "(LBA)$" - #- bios_grub partitions - # "echo ${part} | grep "[a-z]$(parted -s $(${_LSBLK} PKNAME ${part}) print 2>/dev/null | grep bios_grub | cut -d " " -f 2)$" - #- iso9660 devices - # "${_LSBLK} FSTYPE -s ${part} | grep "iso9660" - if ! (${_LSBLK} FSTYPE "${part}" 2>/dev/null | grep -q "linux_raid_member" || ${_LSBLK} FSTYPE "${part}" 2>/dev/null | grep -q "LVM2_member" || ${_LSBLK} FSTYPE "${part}" 2>/dev/null | grep -q "crypto_LUKS" || sfdisk -l 2>/dev/null | grep "${part}" | grep -q "Extended$" || sfdisk -l 2>/dev/null | grep "${part}" | grep -q "(LBA)$" || echo "${part}" | grep -q "[a-z]$(parted -s "$(${_LSBLK} PKNAME "${part}" 2>/dev/null)" print 2>/dev/null | grep bios_grub | cut -d " " -f 2)$" || ${_LSBLK} FSTYPE -s "${part}" 2>/dev/null | grep -q "iso9660"); then - echo "${part}" - [[ "${1}" ]] && echo "${1}" - fi - done - printk on -} - -# list none partitionable raid md devices -raid_devices() { - for dev in $(${_LSBLK} NAME,TYPE | grep " raid.*$" | cut -d' ' -f 1 | sort -u); do - # exclude checks: - # - part of lvm2 device_found - # ${_LSBLK} FSTYPE ${dev} | grep "LVM2_member" - # - part of luks device - # ${_LSBLK} FSTYPE ${dev} | grep "crypto_LUKS" - # - part of isw fakeraid - # ${_LSBLK} FSTYPE ${dev} -s | grep "isw_raid_member" - # - part of ddf fakeraid - # ${_LSBLK} FSTYPE ${dev} -s | grep "ddf_raid_member" - if ! (${_LSBLK} FSTYPE "${dev}" 2>/dev/null | grep -q "LVM2_member" || ${_LSBLK} FSTYPE "${dev}" 2>/dev/null | grep -q "crypto_LUKS" || ${_LSBLK} FSTYPE "${dev}" -s 2>/dev/null | grep -q "isw_raid_member" || ${_LSBLK} FSTYPE "${dev}" -s 2>/dev/null | grep -q "ddf_raid_member" || find "$dev"*p* -type f -exec echo {} \; 2>/dev/null ); then - echo "${dev}" - [[ "${1}" ]] && echo "${1}" - fi - done -} - -# lists linux partitionable raid devices partitions -partitionable_raid_devices_partitions() { - for part in $(${_LSBLK} NAME,TYPE | grep "part$" | grep "^/dev/md.*p" 2>/dev/null | cut -d' ' -f 1 | sort -u) ; do - # exclude checks: - # - part of lvm2 device_found - # ${_LSBLK} FSTYPE ${part} | grep "LVM2_member" - # - part of luks device - # ${_LSBLK} FSTYPE ${part} | grep "crypto_LUKS" - # - extended partition - # sfdisk -l 2>/dev/null | grep "${part}" | grep "Extended$" - # - extended partition (LBA) - # sfdisk -l 2>/dev/null | grep "${part}" | grep "(LBA)$" - # - part of isw fakeraid - # ${_LSBLK} FSTYPE ${dev} -s | grep "isw_raid_member" - # - part of ddf fakeraid - # ${_LSBLK} FSTYPE ${dev} -s | grep "ddf_raid_member" - if ! (${_LSBLK} FSTYPE "${part}" 2>/dev/null | grep -q "LVM2_member" || ${_LSBLK} FSTYPE "${part}" 2>/dev/null | grep -q "crypto_LUKS" || sfdisk -l 2>/dev/null | grep "${part}" | grep -q "Extended$" || sfdisk -l 2>/dev/null | grep "${part}" | grep -q "(LBA)$" || ${_LSBLK} FSTYPE "${dev}" -s 2>/dev/null | grep -q "isw_raid_member" || ${_LSBLK} FSTYPE "${dev}" -s 2>/dev/null | grep -q "ddf_raid_member"); then - echo "${part}" - [[ "${1}" ]] && echo "${1}" - fi - done -} - -# lists dmraid devices -dmraid_devices() { - for dev in $(${_LSBLK} NAME,TYPE | grep "dmraid$" | cut -d' ' -f 1 | grep -v "_.*p.*$" | sort -u); do - echo "${dev}" - [[ "${1}" ]] && echo "${1}" - done - # isw_raid_member, managed by mdadm - for dev in $(${_LSBLK} NAME,TYPE 2>/dev/null | grep " raid.*$" | cut -d' ' -f 1 | sort -u); do - if ${_LSBLK} NAME,FSTYPE -s "${dev}" | grep "isw_raid_member$"; then - echo "${dev}" - [[ "${1}" ]] && echo "${1}" - fi - done - # ddf_raid_member, managed by mdadm - for dev in $(${_LSBLK} NAME,TYPE 2>/dev/null | grep " raid.*$" | cut -d' ' -f 1 | sort -u); do - if ${_LSBLK} NAME,FSTYPE -s "${dev}" | grep "ddf_raid_member$"; then - echo "${dev}" - [[ "${1}" ]] && echo "${1}" - fi - done -} - -# dmraid_partitions -# - show dmraid partitions -dmraid_partitions() { - for part in $(${_LSBLK} NAME,TYPE | grep "dmraid$" | cut -d' ' -f 1 | grep "_.*p.*$" | sort -u); do - # exclude checks: - # - part of lvm2 device - # ${_LSBLK} FSTYPE ${dev} | grep "LVM2_member" - # - part of luks device - # ${_LSBLK} FSTYPE ${dev} | grep "crypto_LUKS" - # - part of raid device - # ${_LSBLK} FSTYPE ${dev} | grep "linux_raid_member$" - # - extended partition - # $(sfdisk -l 2>/dev/null | grep "${part}" | grep "Extended$" - # - extended partition (LBA) - # sfdisk -l 2>/dev/null | grep "${part}" | grep "(LBA)$") - if ! (${_LSBLK} FSTYPE "${part}" 2>/dev/null | grep -q "crypto_LUKS$" || ${_LSBLK} FSTYPE "${part}" 2>/dev/null | grep -q "LVM2_member$" || ${_LSBLK} FSTYPE "${part}" 2>/dev/null | grep -q "linux_raid_member$" || sfdisk -l 2>/dev/null | grep "${part}" | grep -q "Extended$"|| sfdisk -l 2>/dev/null | grep "${part}" | grep -q "(LBA)$"); then - echo "${part}" - [[ "${1}" ]] && echo "${1}" - fi - done - # isw_raid_member, managed by mdadm - for dev in $(${_LSBLK} NAME,TYPE | grep " md$" | cut -d' ' -f 1 | sort -u); do - if ${_LSBLK} NAME,FSTYPE -s "${dev}" 2>/dev/null | grep "isw_raid_member$" | cut -d' ' -f 1; then - echo "${dev}" - [[ "${1}" ]] && echo "${1}" - fi - done - # ddf_raid_member, managed by mdadm - for dev in $(${_LSBLK} NAME,TYPE | grep " md$" | cut -d' ' -f 1 | sort -u); do - if ${_LSBLK} NAME,FSTYPE -s "${dev}" 2>/dev/null | grep "ddf_raid_member$" | cut -d' ' -f 1; then - echo "${dev}" - [[ "${1}" ]] && echo "${1}" - fi - done -} - -# dm_devices -# - show device mapper devices: -# lvm2 and cryptdevices -dm_devices() { - - for dev in $(${_LSBLK} NAME,TYPE | grep -e "lvm$" -e "crypt$" | cut -d' ' -f1 | sort -u); do - # exclude checks: - # - part of lvm2 device - # ${_LSBLK} FSTYPE ${dev} | grep "LVM2_member" - # - part of luks device - # ${_LSBLK} FSTYPE ${dev} | grep "crypto_LUKS" - # - part of raid device - # ${_LSBLK} FSTYPE ${dev} | grep "linux_raid_member$" - # - part of running raid on encrypted device - # ${_LSBLK} TYPE ${dev} | grep "raid.*$ - if ! (${_LSBLK} FSTYPE "${dev}" | grep -q "crypto_LUKS$" 2>/dev/null || ${_LSBLK} FSTYPE "${dev}" | grep -q "LVM2_member$" 2>/dev/null || ${_LSBLK} FSTYPE "${dev}" 2>/dev/null | grep -q "linux_raid_member$" || ${_LSBLK} TYPE "${dev}" 2>/dev/null | grep -q "raid.*$"); then - echo "${dev}" - [[ "${1}" ]] && echo "${1}" - fi - done -} - -finddisks() { - blockdevices "${1}" - dmraid_devices "${1}" -} - -findpartitions() { - blockdevices_partitions "${1}" - dm_devices "${1}" - dmraid_partitions "${1}" - raid_devices "${1}" - partitionable_raid_devices_partitions "${1}" -} - -# don't check on raid devices! -findbootloaderdisks() { - if ! [[ "${USE_DMRAID}" = "1" ]]; then - blockdevices "${1}" - else - dmraid_devices "${1}" - fi -} - -# don't list raid devices, lvm2 and devicemapper! -findbootloaderpartitions() { - if ! [[ "${USE_DMRAID}" = "1" ]]; then - blockdevices_partitions "${1}" - else - dmraid_partitions "${1}" - fi -} - -# find any gpt/guid formatted disks -find_gpt() { - GUID_DETECTED="" - for i in $(finddisks); do - [[ "$(${_BLKID} -p -i -o value -s PTTYPE "${i}")" == "gpt" ]] && GUID_DETECTED="1" - done -} - -# freeze and unfreeze xfs, as hack for grub(2) installing -freeze_xfs() { - sync - if [[ -x /usr/bin/xfs_freeze ]]; then - if grep -q "${DESTDIR}/boot " /proc/mounts | grep -q " xfs "; then - xfs_freeze -f ${DESTDIR}/boot >/dev/null 2>&1 - xfs_freeze -u ${DESTDIR}/boot >/dev/null 2>&1 - fi - if grep -q "${DESTDIR} " /proc/mounts | grep -q " xfs "; then - xfs_freeze -f ${DESTDIR} >/dev/null 2>&1 - xfs_freeze -u ${DESTDIR} >/dev/null 2>&1 - fi - fi -} - -printk() -{ - case ${1} in - "on") echo 4 >/proc/sys/kernel/printk ;; - "off") echo 0 >/proc/sys/kernel/printk ;; - esac -} - -getdest() { - [[ "${DESTDIR}" ]] && return 0 - DIALOG --inputbox "Enter the destination directory where your target system is mounted" 8 65 "${DESTDIR}" 2>${ANSWER} || return 1 - DESTDIR=$(cat ${ANSWER}) -} - -# geteditor() -# prompts the user to choose an editor -# sets EDITOR global variable -# -geteditor() { - if ! [[ "${EDITOR}" ]]; then - DIALOG --menu "Select a Text Editor to Use" 10 35 3 \ - "1" "nano (easier)" \ - "2" "vi" 2>${ANSWER} || return 1 - case $(cat ${ANSWER}) in - "1") EDITOR="nano" ;; - "2") EDITOR="vi" ;; - esac - fi -} - -# set device name scheme -set_device_name_scheme() { - NAME_SCHEME_PARAMETER="" - NAME_SCHEME_LEVELS="" - MENU_DESC_TEXT="" - - # check if gpt/guid formatted disks are there - find_gpt - - ## util-linux root=PARTUUID=/root=PARTLABEL= support - https://git.kernel.org/?p=utils/util-linux/util-linux.git;a=commitdiff;h=fc387ee14c6b8672761ae5e67ff639b5cae8f27c;hp=21d1fa53f16560dacba33fffb14ffc05d275c926 - ## mkinitcpio's init root=PARTUUID= support - https://projects.archlinux.org/mkinitcpio.git/tree/init_functions#n185 - - if [[ "${GUID_DETECTED}" == "1" ]]; then - NAME_SCHEME_LEVELS="${NAME_SCHEME_LEVELS} PARTUUID PARTUUID= PARTLABEL PARTLABEL=" - MENU_DESC_TEXT="\nPARTUUID and PARTLABEL are specific to GPT disks.\nIn GPT disks, PARTUUID is recommended.\nIn MBR/msdos disks," - fi - - NAME_SCHEME_LEVELS="${NAME_SCHEME_LEVELS} FSUUID UUID= FSLABEL LABEL=