#!/bin/bash set -e source funcs.sh # # stage3 install # # sync time ntpd -q -g || true # download & unpack stage3 tarball links https://www.gentoo.org/downloads/mirrors/ LINKS_RUNNING="true" while [[ $LINKS_RUNNING == "true" ]]; do log_msg INFO "Waiting for user to quit links ..." LINKS_RUNNING=$(ps -aux | (grep -o '[l]inks') || true) sleep 5s done tar xpvf stage3-*.tar.xz --xattrs-include="*.*" --numeric-owner rm stage3-*.tar.xz # configure portage (COMMON/USE) PROMPT_PORTAGE=$(prompt_accept "Configure /etc/portage/make.conf COMMON/USE/MAKE/etc flags") if [[ "$PROMPT_PORTAGE" == "y" ]]; then nano -w ./etc/portage/make.conf NANO_RUNNING="true" while [[ $NANO_RUNNING == "true" ]]; do log_msg INFO "Waiting for user to quit nano ..." NANO_RUNNING=$(ps -aux | (grep -o '[n]ano') || true) sleep 5s done fi # make sure DNS works after chroot cp --dereference /etc/resolv.conf /mnt/gentoo/etc/ # mount filesystems mount --types proc /proc /mnt/gentoo/proc mount --rbind /sys /mnt/gentoo/sys mount --make-rslave /mnt/gentoo/sys mount --rbind /dev /mnt/gentoo/dev mount --make-rslave /mnt/gentoo/dev mount --bind /run /mnt/gentoo/run mount --make-slave /mnt/gentoo/run # change root! chroot /mnt/gentoo /bin/bash << EOF set -e source funcs.sh source /etc/profile export PS1="(chroot) ${PS1}" log_msg INFO "mount boot partition (EFI)" >> /var/log/installer.log mkdir -p /boot/efi mount ${CFG_BLOCK_PART}1 /boot/efi log_msg INFO "synchronize gentoo ebuild repo" >> /var/log/installer.log emerge --ask n --sync # TODO: select profile log_msg INFO "update @world set (@system and @selected)" >> /var/log/installer.log emerge --ask n --update --deep --newuse @world log_msg INFO "configure licenses" >> /var/log/installer.log echo "ACCEPT_LICENSE=\"*\"" >> /etc/portage/make.conf log_msg INFO "configure timezone (glibc)" >> /var/log/installer.log echo ${CFG_TIMEZONE} > /etc/timezone emerge --ask n sys-libs/timezone-data log_msg INFO "configure locales (glibc)" >> /var/log/installer.log echo "fi_FI.UTF-8 UTF-8" >> /etc/locale.gen echo "fi_FI ISO-8859-1" >> /etc/locale.gen echo "en_GB.UTF-8 UTF-8" >> /etc/locale.gen locale-gen log_msg INFO "reload environment" >> /var/log/installer.log env-update && source /etc/profile && export PS1="(chroot) ${PS1}" # # firmware install # # # kernel install # log_msg INFO "install kernel sources" >> /var/log/installer.log emerge --ask n sys-kernel/gentoo-sources log_msg INFO "select kernel sources" >> /var/log/installer.log eselect kernel list eselect kernel set 1 log_msg INFO "install genkernel" >> /var/log/installer.log emerge --ask n sys-kernel/genkernel log_msg INFO "set /boot/efi in fstab" >> /var/log/installer.log echo "${CFG_BLOCK_PART}1 /boot/efi vfat defaults 0 2" >> /etc/fstab if [[ "${CFG_LLVM}" == "y" ]]; then log_msg INFO "compile kernel sources (llvm)" >> /var/log/installer.log LLVM=1 LLVM_IAS=1 genkernel all \ --kernel-as=llvm-as \ --kernel-ar=llvm-ar \ --kernel-cc=clang \ --kernel-ld=ld.lld \ --kernel-nm=llvm-nm \ --utils-as=llvm-as \ --utils-ar=llvm-ar \ --utils-cc=clang \ --utils-cxx=clang++ \ --utils-ld=ld.lld \ --utils-nm=llvm-nm else log_msg INFO "compile kernel sources (gcc)" >> /var/log/installer.log genkernel all fi # # filesystem install # log_msg INFO "set swap, / and cdrom in fstab" >> /var/log/installer.log mkdir -p /mnt/cdrom echo "${CFG_BLOCK_PART}"2 none swap sw 0 0 >> /etc/fstab echo "${CFG_BLOCK_PART}"3 / ext4 noatime 0 1 >> /etc/fstab echo /dev/cdrom /mnt/cdrom auto noauto,user 0 0 >> /etc/fstab # # networking install # log_msg INFO "set hostname" >> /var/log/installer.log echo "hostname=\"${CFG_HOSTNAME}\"" > /etc/conf.d/hostname log_msg INFO "install networkmanager" >> /var/log/installer.log emerge --ask n --noreplace net-misc/networkmanager log_msg INFO "install dhcpcd" >> /var/log/installer.log emerge --ask n net-misc/dhcpcd log_msg INFO "install wireless" >> /var/log/installer.log emerge --ask n net-wireless/iw net-wireless/wpa_supplicant log_msg INFO "configure networking" >> /var/log/installer.log log_msg INFO "configure hosts" >> /var/log/installer.log echo "127.0.0.1 ${CFG_HOSTNAME} localhost" >> /etc/hosts # # system install # log_msg INFO "set root password" >> /var/log/installer.log echo "root:${CFG_ROOT_PASSWORD}" | chpasswd log_msg INFO "set keymap" >> /var/log/installer.log sed -i '/^keymap/s/=.*$/=$"'"fi"'"/' /etc/conf.d/keymaps rc-update add keymaps boot rc-service keymaps restart log_msg INFO "install syslog" >> /var/log/installer.log emerge --ask n app-admin/sysklogd rc-update add sysklogd default log_msg INFO "install crond" >> /var/log/installer.log emerge --ask n sys-process/cronie rc-update add cronie default log_msg INFO "install file indexer" >> /var/log/installer.log emerge --ask n sys-apps/mlocate log_msg INFO "install filesystem tools" >> /var/log/installer.log emerge --ask n sys-fs/e2fsprogs emerge --ask n sys-fs/dosfstools # # bootloader install # log_msg INFO "install grub2 with efi" >> /var/log/installer.log echo "GRUB_PLATFORMS=\"efi-64\"" >> /etc/portage/make.conf emerge --ask n sys-boot/grub log_msg INFO "install EFI bootloader" >> /var/log/installer.log grub-install --target=x86_64-efi --efi-directory=/boot/efi log_msg INFO "configure bootloader" >> /var/log/installer.log grub-mkconfig -o /boot/grub/grub.cfg EOF