Large cleanup.

- Merge pacstrap and copy iso code path, most of it was the same.

- Use systemd-detect-virt for VM detection instead of dmesg hacks.

- Add AMD microcode back to the install process *(still not sure if it's
actually needed)*.

- Make sure cryptsetup is installed for when using pacstrap.

- Remove signal file if we've reached the background bit, the output
from pacman is better *(and maybe faster)* when running in the
foreground.

- General cleanup.
This commit is contained in:
natemaia 2020-05-02 23:25:41 -07:00
parent 3aac0aeaf8
commit 87ffbdcb42

View File

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