#!/bin/bash # needed so we override whatever's set in python # alternatively, we can just mkdir -p $GNUPGHOME #export GNUPGHOME=/root/.gnupg unset GNUPGHOME mkdir -p /var/empty/.gnupg # set up a shell env source /etc/profile # Import settings. source /root/VARS.txt # Logging! exec 3>&1 4>&2 trap 'exec 2>&4 1>&3' 0 1 2 3 exec 1>/var/log/chroot_install.log 2>&1 # we need this fix before anything. dirmngr > /etc/sudoers.d/${REGUSR} # Set the password, if we need to. if [[ -n "${REGUSR_PASS}" && "${REGUSR_PASS}" != 'BLANK' ]]; then sed -i -e "s|^${REGUSR}::|${REGUSR}:${REGUSR_PASS}:|g" /etc/shadow elif [[ "${REGUSR_PASS}" == '{[BLANK]}' ]]; then passwd -d ${REGUSR} else usermod -L ${REGUSR} fi # Set the root password, if we need to. if [[ -n "${ROOT_PASS}" && "${ROOT_PASS}" != 'BLANK' ]]; then sed -i -e "s|^root::|root:${ROOT_PASS}:|g" /etc/shadow elif [[ "${ROOT_PASS}" == 'BLANK' ]]; then passwd -d root else usermod -L root fi cleanPacorigs # And install arch-specific extra packages, if there are any. #PKGLIST=$(sed -re '/^[[:space:]]*(#|$)/d' /root/packages.arch | tr '\n' ' ') PKGLIST=$(getPkgList /root/packages.arch) if [[ -n "${PKGLIST}" ]]; then #apacman --noconfirm --noedit --skipinteg -S --needed ${PKGLIST} for p in ${PKGLIST}; do apacman --noconfirm --noedit --skipinteg -S --needed ${PKGLIST} done apacman --gendb cleanPacorigs fi # Run any arch-specific tasks here. if [ -f '/root/pre-build.arch.sh' ]; then cnt=$(sed -re '/^[[:space:]]*(#|$)/d' /root/pre-build.arch.sh | wc -l) if [[ "${cnt}" -ge 1 ]]; then /root/pre-build.arch.sh fi rm -f /root/pre-build.arch.sh fi # Cleanup # TODO: look into https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Removing_unused_packages_.28orphans.29 mkinitcpio -p linux paccache -rk0 localepurge-config localepurge localepurge-config localepurge rm -f /root/.bash_history rm -f /root/.viminfo rm -f /root/apacman-*.pkg.tar.xz rm -f /root/pre-build.sh pkill -9 dirmngr pkill -9 gpg-agent