diff --git a/archlabs-installer b/archlabs-installer index be30e8e..4794ace 100755 --- a/archlabs-installer +++ b/archlabs-installer @@ -7,7 +7,7 @@ # shellcheck disable=SC2086,SC2046,SC2254 -VER=2.1.39 +VER=2.1.40 # default values { @@ -23,9 +23,9 @@ BG=/tmp/bgout # output from background process ERR=/tmp/errlog # stderr log used internally by errshow() DBG=/tmp/debuglog # debug log file 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 EXMNTS="" # extra partitions that were mounted, used to verify mountpoint and show user USER_CMD="" # optional command(s) entered by the user to run in the chroot +VM="$(systemd-detect-virt)" # system running in a virtual machine export DIALOGOPTS="--cr-wrap" # dialog environment variable to hold default options, see `man dialog` @@ -1499,22 +1499,22 @@ install_base() clear tput cnorm if [[ $BG_PID ]] && kill -0 $BG_PID 2> /dev/null; then + [[ -e /tmp/wmlist ]] && rm /tmp/wmlist printf "\nA background install process is still running, tailing the output...\n" tail -f --pid=$BG_PID "$BG" trap - EXIT unset BG_PID fi - if [[ $PACSTRAP == 1 ]]; then + if (( PACSTRAP )); then + cp -vf /etc/modprobe.d/* "$MNT/etc/modprobe.d/" + cp -vf /etc/X11/xorg.conf.d/* "$MNT/etc/X11/xorg.conf.d/" # we have some customizations in /etc on the iso we want to preserve if [[ $DIST == "ArchLabs" ]]; then cp -vf /etc/dialogrc "$MNT/etc/dialogrc" cp -vf /etc/os-release "$MNT/etc/os-release" cp -vf /etc/lsb-release "$MNT/etc/lsb-release" cp -vf /etc/skel/.zshrc "$MNT/etc/skel/.zshrc" - cp -vf /etc/pacman.conf "$MNT/etc/pacman.conf" - cp -vf /etc/modprobe.d/* "$MNT/etc/modprobe.d/" - cp -vf /etc/X11/xorg.conf.d/* "$MNT/etc/X11/xorg.conf.d/" fi else # remove archiso files when copying iso @@ -1789,10 +1789,10 @@ install_packages() errshow 1 "chrun 'pacman -S efibootmgr --needed --noconfirm'" fi - if [[ $VM ]] && dmesg | grep -qi 'vbox'; then + if [[ $VM == 'oracle' ]]; then case "$KERNEL" in linux) chrun "pacman -S virtualbox-guest-utils virtualbox-guest-modules-arch --needed --noconfirm" ;; - *) chrun "pacman -S virtualbox-guest-utils virtualbox-guest-modules-dkms ${KERNEL}-headers --needed --noconfirm" ;; + *) chrun "pacman -S ${KERNEL}-headers virtualbox-guest-utils virtualbox-guest-modules-dkms --needed --noconfirm" ;; esac fi @@ -1829,7 +1829,7 @@ install_tearfree() { local xpath="$1" - if [[ $VM ]]; then + if [[ $VM != 'none' ]]; then echo "Virtual machine detected, removing xorg configs" find "$xpath/" -name '*.conf' -delete -printf "remove %p\n" elif [[ $TEARFREE ]]; then @@ -1956,37 +1956,44 @@ install_mirrorlist() install_background() { - local net="networkmanager" - [[ ! -d /etc/NetworkManager/system-connections ]] && net="netctl" + local luks net="networkmanager" - if yesno "Background Install" "$_bginstall" "Pacstrap" "Copy ISO"; then - ( - install_mirrorlist "/etc/pacman.d/mirrorlist" > /tmp/bgout 2>&1 && - pacman -Syy >> /tmp/bgout 2>&1 && - pacstrap /mnt base ${ISO_PKGS[*]} $net >> /tmp/bgout 2>&1 && - cp /etc/pacman.d/mirrorlist "$MNT/etc/pacman.d/mirrorlist" && - cp /etc/pacman.conf "$MNT/etc/pacman.conf" && - al_repo "$MNT/etc/pacman.conf" && - [[ $net == "networkmanager" ]] && chrun "systemctl enable NetworkManager.service" >> /tmp/bgout 2>&1 - [[ -e /tmp/wmlist ]] && chrun "pacman -S ${BASE_PKGS[*]} --noconfirm --needed" >> /tmp/bgout 2>&1 - ) & - BG_PID=$! - PACSTRAP=1 - else - ( - rsync -avh /run/archiso/sfs/airootfs/ "$MNT/" > /tmp/bgout 2>&1 && - install_mirrorlist "/etc/pacman.d/mirrorlist" >> /tmp/bgout 2>&1 && - pacman -Syy >> /tmp/bgout 2>&1 && - cp /etc/pacman.d/mirrorlist "$MNT/etc/pacman.d/mirrorlist" && - cp /etc/pacman.conf "$MNT/etc/pacman.conf" && - al_repo "$MNT/etc/pacman.conf" && - chrun "pacman -Syyu $net --noconfirm --needed" >> /tmp/bgout 2>&1 && - [[ $net == "networkmanager" ]] && chrun "systemctl enable NetworkManager.service" >> /tmp/bgout 2>&1 - [[ -e /tmp/wmlist ]] && chrun "pacman -S ${BASE_PKGS[*]} --noconfirm --needed" >> /tmp/bgout 2>&1 - ) & - BG_PID=$! - PACSTRAP=0 - fi + [[ ! -d /etc/NetworkManager/system-connections ]] && net="netctl" + [[ $LUKS ]] && luks="cryptsetup" + + yesno "Background Install" "$_bginstall" "Pacstrap" "Copy ISO" || PACSTRAP=0 + + ( + install_mirrorlist "/etc/pacman.d/mirrorlist" > /tmp/bgout 2>&1 + if (( PACSTRAP )); then + pacstrap /mnt >> /tmp/bgout 2>&1 + else + rsync -avh /run/archiso/sfs/airootfs/ "$MNT/" >> /tmp/bgout 2>&1 + fi + + pacman -Sy >> /tmp/bgout 2>&1 + cp /etc/pacman.conf "$MNT/etc/pacman.conf" + cp /etc/pacman.d/mirrorlist "$MNT/etc/pacman.d/mirrorlist" + al_repo "$MNT/etc/pacman.conf" + + if (( PACSTRAP )); then + chrun "pacman -S ${ISO_PKGS[*]} $net $luks --noconfirm --needed" >> /tmp/bgout 2>&1 + else + chrun "pacman -Syyu $net --noconfirm --needed" >> /tmp/bgout 2>&1 + fi + + if [[ $net == "networkmanager" ]]; then + chrun "systemctl enable NetworkManager.service" >> /tmp/bgout 2>&1 + else + chrun "systemctl enable netctl.service" >> /tmp/bgout 2>&1 + fi + + if [[ -e /tmp/wmlist ]]; then + chrun "pacman -S ${BASE_PKGS[*]} --noconfirm --needed" >> /tmp/bgout 2>&1 + fi + ) & + + BG_PID=$! # shellcheck disable=SC2064 trap "kill $BG_PID 2> /dev/null" EXIT } @@ -2720,7 +2727,7 @@ live() dwm) { pacman -S git --needed --noconfirm || die 1; }; install_suckless "/root" nochroot ;; esac rm -rf /var/cache/pacman/pkg/* - [[ $VM ]] && dmesg | grep -qi 'vbox' && pacman -S virtualbox-guest-utils virtualbox-guest-modules-arch --needed --noconfirm + [[ $VM == 'oracle' ]] && pacman -S virtualbox-guest-utils virtualbox-guest-modules-arch --needed --noconfirm pacman -Scc --noconfirm rm -rf /var/cache/pacman/pkg/* cp -rfT /etc/skel /root @@ -2925,7 +2932,7 @@ umount_dir() chk_connect() { msg "Network Connect" "\nVerifying network connection\n" 0 - if [[ $VM ]] && hash nm-online > /dev/null 2>&1; then + if [[ $VM != 'none' ]] && hash nm-online > /dev/null 2>&1; then nm-online > /dev/null 2>&1 else ping -qc1 'archlinux.org' > /dev/null 2>&1 @@ -2988,11 +2995,10 @@ system_devices() system_identify() { - if [[ $VM ]]; then + if [[ $VM != 'none' ]]; then UCODE='' - # amd-ucode is not needed it's provided by linux-firmware - # elif grep -q 'AuthenticAMD' /proc/cpuinfo; then - # UCODE="amd-ucode" + elif grep -q 'AuthenticAMD' /proc/cpuinfo; then + UCODE="amd-ucode" elif grep -q 'GenuineIntel' /proc/cpuinfo; then UCODE="intel-ucode" fi