From 3c37a64e15652eaba3b3db44957ddea5046729d8 Mon Sep 17 00:00:00 2001 From: natemaia Date: Sat, 18 Aug 2018 17:59:25 -0700 Subject: [PATCH] Only ignore usb device that is used for booting --- source/archlabs-installer | 43 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/source/archlabs-installer b/source/archlabs-installer index 8bcf7d2..f30c08e 100755 --- a/source/archlabs-installer +++ b/source/archlabs-installer @@ -15,29 +15,25 @@ # immutable variables { readonly DIST="Archlabs" # Linux distributor -readonly VER="1.6.31" # Installer version +readonly VER="1.6.33" # Installer version readonly LIVE="liveuser" # Live session user readonly TRN="/usr/share/archlabs-installer" # Translation path readonly MNT="/mnt/install" # Install mountpoint readonly ERR="/tmp/errlog" # Built-in error log -readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')" -readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}') -readonly SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE,TRAN | awk '/disk/ && !/usb/ {print "/dev/" $1 " " $2}')" -readonly DEV_COUNT="$(wc -l <<< "$SYS_DEVS")" +# create a regex string of all usb devices on the system +for dev in $(lsblk -lno NAME,TRAN | awk '/usb/ {print $1}'); do USB_DEVS="${dev}$([[ $USB_DEVS ]] && echo -n "|$USB_DEVS")"; done + +# determine which device was used for booting to ignore later during partition select +readonly IGNORE_DEV="$(lsblk -lno NAME,TYPE,TRAN,MOUNTPOINT | awk "/$USB_DEVS/"' && /\/run\/archiso\/bootmnt/ {sub(/[1-9]/, ""); print $1}')" +readonly SYS_DEVS="$(lsblk -lno NAME,SIZE,TYPE,TRAN | awk '/disk/ && !'"/$IGNORE_DEV/"' {print "/dev/" $1 " " $2}')" readonly LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if($1) print $1 " -"}' /etc/locale.gen)" +readonly SYS_MEM=$(grep 'MemTotal' /proc/meminfo | awk '{print int($2 / 1024)}') +readonly DEV_COUNT="$(wc -l <<< "$SYS_DEVS")" +readonly KBD="$(find /usr/share/kbd/keymaps -name '*.map.gz')" readonly CONSOLE_MAPS="$(awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " -"}' <<< "$KBD" | sort -r)" -# create a regex string of all usb devices on the system -# ignore these devices entirely during partition list creation -for dev in $(lsblk -lno NAME,TRAN | awk '/usb/ {print $1}'); do - USB_DEVS="${dev}$([[ $USB_DEVS ]] && echo -n "|$USB_DEVS")" -done - -# static string of zones to avoid loops and subprocess calls -readonly ZONES="America - Australia - Asia - Atlantic - Africa - Europe - Indian - Pacific - Arctic - Antarctica -" - -# create associative array for subzones, value is: 'subzone country_code' +# create associative array for SUBZONES[zone], value is: 'sub-zone country_code' declare -Ag SUBZONES for zone in America Australia Asia Atlantic Africa Europe Indian Pacific Arctic Antarctica; do SUBZONES[$zone]="$(awk "/$zone\// {gsub(/$zone\//, \"\"); print \$3 \" \"\$1}" /usr/share/zoneinfo/zone.tab)" @@ -181,9 +177,9 @@ chroot_cmd() { show_devices() { tput civis - if [[ $USB_DEVS != "" ]]; then + if [[ $IGNORE_DEV != "" ]]; then lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT | - awk "!/$USB_DEVS/"' && /disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist + awk "!/$IGNORE_DEV/"' && /disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist else lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT | awk '/disk|part|lvm|crypt|NAME/ {print $0}' > /tmp/.devlist @@ -441,7 +437,8 @@ set_timezone() { local zone zone="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \ - --title " $_TimeZTitle " --menu "$_TimeZBody" 20 70 10 $ZONES)" + --title " $_TimeZTitle " --menu "$_TimeZBody" 20 70 10 America - Australia - \ + Asia - Atlantic - Africa - Europe - Indian - Pacific - Arctic - Antarctica -)" local subzone subzone="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \ --title " $_TimeZTitle " --menu "$_TimeSubZBody" 20 70 12 ${SUBZONES[$zone]})" @@ -683,6 +680,8 @@ choose_window_manager() { [[ $LOGIN_WM == "" ]] && LOGIN_WM="$(awk '{print $1}' <<< "$INSTALL_WMS")" fi + [[ $LOGIN_WM == 'i3-gaps' ]] && LOGIN_WM="i3" + return 0 } @@ -764,10 +763,12 @@ find_partitions() { local err='NONE' # string of partitions as /TYPE/PART SIZE - if [[ $USB_DEVS != "" ]]; then - PARTS="$(lsblk -lno TYPE,NAME,SIZE | awk "/$str/"' && !'"/$USB_DEVS/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')" + if [[ $IGNORE_DEV != "" ]]; then + PARTS="$(lsblk -lno TYPE,NAME,SIZE | + awk "/$str/"' && !'"/$IGNORE_DEV/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')" else - PARTS="$(lsblk -lno TYPE,NAME,SIZE | awk "/$str/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')" + PARTS="$(lsblk -lno TYPE,NAME,SIZE | + awk "/$str/"' {sub(/^part/, "/dev/"); sub(/^lvm|^crypt/, "/dev/mapper/"); print $1$2 " " $3}')" fi # number of partitions total