diff --git a/archlabs-installer b/archlabs-installer index ba049f1..6534052 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -5,210 +5,77 @@ # Some ideas and code reworked from other resources # AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due - -# linux distributor, if unset will be ArchLabs -# this can be set in the environment prior to install, eg. -# -# $ DIST="My Distro" archlabs-installer -# -# will result in "My Distro Linux" used where needed -: ${DIST="ArchLabs"} - -VER="2.0.71" # installer version -MNT="/mnt" # install mountpoint -ANS="/tmp/ans" # dialog answer file - -# ------------------------------------------------------ # -# When manually mounting your partitions, you need -# to set these values to avoid using the mount menu. -# ------------------------------------------------------ # - -# root partition, eg. /dev/sda2 -ROOT_PART='' - -# boot partition, required on UEFI eg. /dev/sda1 -BOOT_PART='' - -# boot device, used for some bootloaders eg. /dev/sda -BOOT_DEV='' - -# bootloader to use, can be: -# UEFI: grub, syslinux, efistub, systemd-boot, refind-efi -# BIOS: grub, syslinux -BOOTLDR='' - -# directory to mount the boot partition (if any) for most bootloaders -# this will need to be 'boot' however a popular one for grub is 'boot/efi' -BOOTDIR='boot' - -# ------------------------------------------------------ # +VER=2.0.72 # bulk default values { -# these values will be selected during the install, it is not recommended -# to edit them here unless you know what you're doing. +: ${DIST=ArchLabs} # distro name if not set +MNT=/mnt # install mountpoint +ANS=/tmp/ans # dialog answer file +BOOTDIR=boot # location to mount boot partition +FONT=ter-i16n # font used for the linux console +HOOKS=shutdown # list of additional mkinitcpio HOOKS +SEL=0 # currently selected menu item +SYS=Unknown # bios type to be determined: UEFI/BIOS +ERR=/tmp/errlog # error log used internally +DBG=/tmp/debuglog # debug log when passed -d +RUN=/run/archiso/bootmnt/arch/boot # path for live system /boot +VM="$(dmesg | grep -i hypervisor)" # system running in a virtual machine +export DIALOGOPTS="--cr-wrap" # see `man dialog` -SWAP_PART='' # swap partition or file path -SWAP_SIZE='' # swap size, only used when creating a swapfile - -EXMNT='' # holder for additional partitions while mounting -EXMNTS='' # when an extra partition is mounted append it's info - -FONT="ter-i16n" # font used for the linux console -HOOKS="shutdown" # list of additional HOOKS to add in /etc/mkinitcpio.conf - -LOGIN_TYPE='' # login manager can be: lightdm, xinit, ly -LOGIN_WM='' # default login session to be placed in ~/.xinitrc -LOGINRC='' # login shell rc file, eg. .zprofile, .bash_profile, .profile -AUTOLOGIN='' # enable autologin for xinit - -INSTALL_WMS='' # space separated list of chosen wm/de - -WM_PKGS='' # list of packages added during wm/de choice (not user edited) -PACKAGES='' # list of all packages to install including WM_PKGS (not user edited) -USER_PKGS='' # packages selected by the user during install - -NEWUSER='' # username for the new user -USER_PASS='' # new user's password -ROOT_PASS='' # root password - -KERNEL='' # linux kernel, can be: linux, linux-lts, linux-zen, or linux-hardened -MYSHELL='' # shell to use for the system, eg. zsh -UCODE='' # cpu microcode (if any), can be: amd-ucode, intel-ucode - -LUKS='' # empty when not using encryption -LUKS_DEV='' # boot parameter string for LUKS -LUKS_PART='' # partition used for encryption -LUKS_PASS='' # encryption password -LUKS_UUID='' # encrypted partition UUID -LUKS_NAME='' # name used for encryption - -LVM='' # empty when not using lvm -LVM_PARTS='' # partitions used for volume group -VGROUP_MB=0 # available space in volume group - -WARN='' # issued mounting/partitioning warning -SEP_BOOT='' # separate boot partition for BIOS -CONFIG_DONE='' # basic configuration is finished - -FORMATTED='' # partitions we formatted and should allow skipping -AUTO_ROOT_PART='' # root value from auto partition -AUTO_BOOT_PART='' # boot value from auto partition - -SEL=0 # currently selected menu item -ERR="/tmp/errlog" # error log used internally -DBG="/tmp/debuglog" # debug log when passed -d -RUN="/run/archiso/bootmnt/arch/boot" # path for live system /boot -VM="$(dmesg | grep -i "hypervisor")" # system running in a virtual machine -SYS='Unknown' # bios type to be determined: UEFI/BIOS -export DIALOGOPTS="--cr-wrap" # see `man dialog` - -# baseline BASE_PKGS="base-devel xorg xorg-drivers sudo git gvfs gtk3 libmad libmatroska " BASE_PKGS+="tumbler playerctl pulseaudio pulseaudio-alsa pavucontrol pamixer scrot " BASE_PKGS+="xdg-user-dirs ffmpeg gstreamer gst-libav gst-plugins-base gst-plugins-good" - -# archlabs base AL_BASE_PKGS="archlabs-skel-base archlabs-fonts archlabs-themes " AL_BASE_PKGS+="archlabs-icons archlabs-wallpapers archlabs-scripts archlabs-baph" - -# extras for window managers WM_BASE_PKGS="arandr archlabs-networkmanager-dmenu nitrogen polkit-gnome " WM_BASE_PKGS+="volumeicon xclip exo laptop-detect xdotool compton wmctrl feh " WM_BASE_PKGS+="gnome-keyring dunst gsimplecal xfce4-power-manager xfce4-settings" - -# } - -# giant ugly variable container :P { - -# system RAM in MB SYS_MEM="$(awk '/MemTotal/ {print int($2 / 1024) "M"}' /proc/meminfo)" - -# locales from /etc/locale.gen LOCALES="$(awk '/\.UTF-8/ {gsub(/# .*|#/, ""); if ($1) {print $1 " - "}}' /etc/locale.gen)" - -# console keyboard mappings CMAPS="$(find /usr/share/kbd/keymaps -name '*.map.gz' | awk '{gsub(/\.map\.gz|.*\//, ""); print $1 " - "}' | sort)" - -# terminal size [[ $LINES ]] || LINES=$(tput lines) [[ $COLUMNS ]] || COLUMNS=$(tput cols) -# associative arrays -# { +# } # commands used to install each bootloader, however most get modified during runtime { declare -A BCMDS=( -[refind-efi]='refind-install' # minor modification -[grub]='grub-install --recheck --force' # heavily modified -[syslinux]='syslinux-install_update -i -a -m' # modified on UEFI -[efistub]='efibootmgr -v -d /dev/sda -p 1 -c -l' # heavily modified -[systemd-boot]='bootctl --path=/boot install' # not modified +[refind-efi]='refind-install' +[grub]='grub-install --recheck --force' [syslinux]='syslinux-install_update -i -a -m' +[efistub]='efibootmgr -v -d /dev/sda -p 1 -c -l' [systemd-boot]='bootctl --path=/boot install' ) # } # executable name for each wm/de used in ~/.xinitrc { declare -A WM_SESSIONS=( -[dwm]='dwm' -[i3-gaps]='i3' -[bspwm]='bspwm' -[awesome]='awesome' -[plasma]='startkde' -[xfce4]='startxfce4' -[gnome]='gnome-session' -[fluxbox]='startfluxbox' -[openbox]='openbox-session' -[cinnamon]='cinnamon-session' +[dwm]='dwm' [i3-gaps]='i3' [bspwm]='bspwm' [awesome]='awesome' [plasma]='startkde' [xfce4]='startxfce4' +[gnome]='gnome-session' [fluxbox]='startfluxbox' [openbox]='openbox-session' [cinnamon]='cinnamon-session' ) # } # packages installed for each wm/de, most are depends of the skel packages { declare -A WM_EXT=( -[dwm]='' # NA -[gnome]='' # NA -[cinnamon]='gnome-terminal' # doesn't install a terminal on it's own -[plasma]='kdebase-meta' # base plasma application set -[awesome]='archlabs-skel-awesome' # see deps of archlabs-skel-awesome -[bspwm]='archlabs-skel-bspwm' # see deps of archlabs-skel-bspwm -[fluxbox]='archlabs-skel-fluxbox' # see deps of archlabs-skel-fluxbox -[i3-gaps]='archlabs-skel-i3-gaps' # see deps of archlabs-skel-i3-gaps -[openbox]='archlabs-skel-openbox' # see deps of archlabs-skel-openbox -[xfce4]='archlabs-skel-xfce4 xfce4-goodies' # see deps of archlabs-skel-xfce4 +[dwm]='' [gnome]='' [cinnamon]='gnome-terminal' [plasma]='kdebase-meta' +[awesome]='archlabs-skel-awesome' [bspwm]='archlabs-skel-bspwm' [fluxbox]='archlabs-skel-fluxbox' +[i3-gaps]='archlabs-skel-i3-gaps' [openbox]='archlabs-skel-openbox' [xfce4]='archlabs-skel-xfce4 xfce4-goodies' ) # } # files offered for editing after install is complete { declare -A EDIT_FILES=( [login]='' # login is populated once we know the username and shell -[fstab]='/etc/fstab' -[sudoers]='/etc/sudoers' -[crypttab]='/etc/crypttab' -[pacman]='/etc/pacman.conf' -[console]='/etc/vconsole.conf' -[mkinitcpio]='/etc/mkinitcpio.conf' -[hostname]='/etc/hostname /etc/hosts' +[fstab]='/etc/fstab' [sudoers]='/etc/sudoers' [crypttab]='/etc/crypttab' [pacman]='/etc/pacman.conf' +[console]='/etc/vconsole.conf' [mkinitcpio]='/etc/mkinitcpio.conf' [hostname]='/etc/hostname /etc/hosts' [bootloader]="/boot/loader/entries/$DIST.conf" # ** based on bootloader -[locale]='/etc/locale.conf /etc/default/locale' -[keyboard]='/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard' +[locale]='/etc/locale.conf /etc/default/locale' [keyboard]='/etc/X11/xorg.conf.d/00-keyboard.conf /etc/default/keyboard' ) # } -# mkfs command and flags for filesystem formatting { -declare -A FS_CMDS=( -[f2fs]='mkfs.f2fs' -[jfs]='mkfs.jfs -q' -[xfs]='mkfs.xfs -f' -[ntfs]='mkfs.ntfs -q' -[ext2]='mkfs.ext2 -q' -[ext3]='mkfs.ext3 -q' -[ext4]='mkfs.ext4 -q' -[vfat]='mkfs.vfat -F32' -[nilfs2]='mkfs.nilfs2 -q' -[reiserfs]='mkfs.reiserfs -q' +# mkfs command flags for filesystem formatting { +declare -A FS_CMD_FLAGS=( +[f2fs]='' [jfs]='-q' [xfs]='-f' [ntfs]='-q' [ext2]='-q' [ext3]='-q' [ext4]='-q' [vfat]='-F32' [nilfs2]='-q' [reiserfs]='-q' ) # } # mount options for each filesystem { declare -A FS_OPTS=( -[vfat]='' # NA -[ntfs]='' # NA -[ext2]='' # NA -[ext3]='' # NA +[vfat]='' [ntfs]='' [ext2]='' [ext3]='' # NA [jfs]='discard errors=continue errors=panic nointegrity' [reiserfs]='acl nolog notail replayonly user_xattr off' [ext4]='discard dealloc nofail noacl relatime noatime nobarrier nodelalloc' @@ -219,10 +86,7 @@ declare -A FS_OPTS=( # packages installed for each login option { declare -A LOGIN_PKGS=( -[xinit]='xorg-xinit' -[ly]='archlabs-ly' -[gdm]='gdm' -[sddm]='sddm' +[xinit]='xorg-xinit' [ly]='archlabs-ly' [gdm]='gdm' [sddm]='sddm' [lightdm]='lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice' ) # } @@ -230,27 +94,13 @@ declare -A LOGIN_PKGS=( # if a package requires additional packages that aren't already dependencies # they can be added here eg. [package]="extra" declare -A PKG_EXT=( -[vlc]='qt4' -[mpd]='mpc' -[mupdf]='mupdf-tools' -[qt5ct]='qt5-styleplugins' -[rxvt-unicode]='urxvt-pearls' -[vlc]='qt5ct qt5-styleplugins' -[zathura]='zathura-pdf-poppler' -[noto-fonts]='noto-fonts-emoji' -[cairo-dock]='cairo-dock-plug-ins' -[qutebrowser]='qt5ct qt5-styleplugins' -[qbittorrent]='qt5ct qt5-styleplugins' -[transmission-qt]='qt5ct qt5-styleplugins' -[bluez]='bluez-libs bluez-utils bluez-tools bluez-plugins bluez-hid2hci' -[kdenlive]='kdebase-meta dvdauthor frei0r-plugins breeze breeze-gtk qt5ct qt5-styleplugins' +[vlc]='qt4' [mpd]='mpc' [mupdf]='mupdf-tools' +[rxvt-unicode]='urxvt-pearls' [zathura]='zathura-pdf-poppler' [noto-fonts]='noto-fonts-emoji' [cairo-dock]='cairo-dock-plug-ins' [qt5ct]='qt5-styleplugins' +[vlc]='qt5ct qt5-styleplugins' [qutebrowser]='qt5ct qt5-styleplugins' [qbittorrent]='qt5ct qt5-styleplugins' [transmission-qt]='qt5ct qt5-styleplugins' +[bluez]='bluez-libs bluez-utils bluez-tools bluez-plugins bluez-hid2hci' [kdenlive]='kdebase-meta dvdauthor frei0r-plugins breeze breeze-gtk qt5ct qt5-styleplugins' ) # } -# } - -# dialog text variables -# { - +# dialog text variables { # Basics (somewhat in order) _welcome="\nThis will help you get $DIST installed and setup on your system.\n\nIf you are unsure about a section the default option will be listed or\nthe first selected item will be the default.\n\n\nMenu Navigation:\n\n - Select items with the arrow keys or the option number.\n - Use [Space] to toggle check boxes and [Enter] to accept.\n - Switch between fields using [Tab] or the arrow keys.\n - Use [Page Up] and [Page Down] to jump whole pages\n - Press the highlighted key of an option to select it.\n" _keymap="\nPick which keymap to use for the system from the list below\n\nThis is used once a graphical environment is running (Xorg).\n\nSystem default: us" @@ -307,8 +157,6 @@ _lvmerrlvsize="\nInvalid value Entered.\n\nMust be a numeric value with 'M' (meg # } -# } - ############################################################################### # selection menus # main is the entry point which calls functions including outside of its block @@ -961,8 +809,8 @@ part_format() local part="$1" fs="$2" delay="$3" msg "Format" "\nFormatting $part as $fs\n" 0 - ${FS_CMDS[$fs]} "$part" >/dev/null 2>$ERR - errshow "${FS_CMDS[$fs]} $part" || return 1 + mkfs.$fs ${FS_CMD_FLAGS[$fs]} "$part" >/dev/null 2>$ERR + errshow "mkfs.$fs ${FS_CMD_FLAGS[$fs]} "$part"" || return 1 FORMATTED+="$part " sleep "${delay:-0}" } @@ -1368,13 +1216,11 @@ install_base() { clear tput cnorm - while kill -0 "$RSYNC_PID" 2>/dev/null || kill -0 "$MIRROR_PID" 2>/dev/null; do - clear - printf "\nOne or more background install processes are still running...\n" - sleep 1 + while kill -0 $BG_PID 2>/dev/null; do + clear; printf "\nA background install process is still running...\n"; sleep 1 done trap - EXIT - unset RSYNC_PID MIRROR_PID + unset BG_PID rm -rf $MNT/etc/mkinitcpio-archiso.conf find $MNT/usr/lib/initcpio -name 'archiso*' -type f -delete @@ -1397,7 +1243,6 @@ install_base() fi [[ -e /run/archiso/sfs/airootfs && $KERNEL == 'linux' ]] && cp -vf $RUN/x86_64/vmlinuz $MNT/boot/vmlinuz-linux - [[ -d /etc/netctl ]] && cp -rfv /etc/netctl $MNT/etc/ [[ -f /etc/resolv.conf ]] && cp -fv /etc/resolv.conf $MNT/etc/ [[ -e /etc/NetworkManager/system-connections ]] && cp -rvf /etc/NetworkManager/system-connections $MNT/etc/NetworkManager/ @@ -1659,13 +1504,9 @@ install_mirrorlist() install_background() { - msg "Background Install" "\nInstall will now begin in the background\n" 1 - rsync -a /run/archiso/sfs/airootfs/ $MNT/ & - RSYNC_PID=$! - ( install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" ) & - MIRROR_PID=$! - # end the background processes before exiting - trap "kill $RSYNC_PID $MIRROR_PID 2>/dev/null" EXIT + ( rsync -a /run/archiso/sfs/airootfs/ $MNT/ && install_mirrorlist "$MNT/etc/pacman.d/mirrorlist" >/dev/null 2>&1 ) & + BG_PID=$! + trap "kill $BG_PID 2>/dev/null" EXIT } ############################################################################### @@ -2467,7 +2308,7 @@ net_connect() no_bg_install() { - [[ $RSYNC_PID || $MIRROR_PID ]] || return 0 + [[ $BG_PID ]] || return 0 msg "Install Running" "\nA background install process is currently running.\n" 2 return 1 }