2024-09-21 06:27:28 +00:00
|
|
|
#!/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
|
|
|
|
|
2024-09-21 18:36:31 +00:00
|
|
|
# set USE flags for later
|
|
|
|
rm -rf /mnt/gentoo/etc/package.use
|
|
|
|
touch /mnt/gentoo/etc/package.use
|
|
|
|
cat package.use > /mnt/gentoo/etc/package.use
|
|
|
|
|
2024-09-21 06:27:28 +00:00
|
|
|
# configure portage (COMMON/USE)
|
2024-09-21 18:36:31 +00:00
|
|
|
cat make.conf > /mnt/gentoo/etc/make.conf
|
2024-09-21 06:27:28 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2024-09-21 18:36:31 +00:00
|
|
|
# set some makeopts and default opts
|
|
|
|
# WARNING: THE DEFAULT USES ALL THE THREADS IN THE SYSTEM!
|
|
|
|
# IF YOU DO NOT WANT THIS PLEASE CHANGE IT TO WHAT GENTOO RECOMMENDS
|
|
|
|
# https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Stage#MAKEOPTS
|
|
|
|
emerge --ask n cpuid2cpuflags
|
|
|
|
cpuid2cpuflags | sed 's/:\s/="/; s/$/"/' >> /etc/portage/make.conf
|
|
|
|
echo "EMERGE_DEFAULT_OPTS=\"--jobs=$(nproc) --load-average=$(nproc) --keep-going --verbose --quiet-build --with-bdeps=y --complete-graph=y --deep --ask\"" >> /etc/portage/make.conf
|
|
|
|
echo "MAKEOPTS=\"-j$(nproc) -l$(nproc)\"" >> /etc/portage/make.conf
|
|
|
|
|
|
|
|
# install custom compiler for firefox
|
|
|
|
mkdir -p /etc/portage/env
|
|
|
|
curl -L https://gist.githubusercontent.com/emrakyz/23bf6fe9c30aa0b1eb88021889750ace/raw/832a0160ac0d0383c4f600da5cf8af4290019ff6/compiler-firefox -o /etc/portage/env/compiler-firefox
|
|
|
|
echo "www-client/firefox compiler-firefox" > /etc/portage/package.env
|
|
|
|
|
2024-09-21 06:27:28 +00:00
|
|
|
# TODO: select profile
|
|
|
|
|
|
|
|
log_msg INFO "update @world set (@system and @selected)" >> /var/log/installer.log
|
|
|
|
emerge --ask n --update --deep --newuse @world
|
2024-09-21 18:36:31 +00:00
|
|
|
emerge --ask n @preserved-rebuild
|
|
|
|
emerge --ask n --depclean
|
2024-09-21 06:27:28 +00:00
|
|
|
|
|
|
|
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
|
2024-09-21 18:36:31 +00:00
|
|
|
emerge --ask n --config sys-libs/timezone-data
|
2024-09-21 06:27:28 +00:00
|
|
|
|
|
|
|
log_msg INFO "configure locales (glibc)" >> /var/log/installer.log
|
2024-09-21 18:36:31 +00:00
|
|
|
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
|
2024-09-21 06:27:28 +00:00
|
|
|
locale-gen
|
|
|
|
|
|
|
|
|
|
|
|
log_msg INFO "reload environment" >> /var/log/installer.log
|
|
|
|
env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
|
|
|
|
|
|
|
|
#
|
|
|
|
# firmware install
|
|
|
|
#
|
|
|
|
|
2024-09-21 18:36:31 +00:00
|
|
|
log_msg INFO "installing microcode and firmware" >> /var/log/installer.log
|
|
|
|
emerge --ask n intel-microcode
|
|
|
|
SIGNATURE=$(iucode_tool -S 2>&1 | grep -o "0.*$")
|
|
|
|
sed -i "s/MICROCODE_SIGNATURES=\"-S\"/MICROCODE_SIGNATURES=\"-s $SIGNATURE\"/" /etc/portage/make.conf
|
|
|
|
emerge --ask n intel-microcode
|
|
|
|
USE="-compress-xz" emerge --ask n linux-firmware
|
|
|
|
emerge --oneshot --ask n pciutils
|
|
|
|
GPU_CODE=$(lspci | grep -i 'vga\|3d\|2d' | awk -F'[[]' '{print $1}' | awk '{print $NF}' | tr '[:upper:]' '[:lower:]')
|
|
|
|
sed -i "/^nvidia\/\($GPU_CODE\)/!d" /etc/portage/savedconfig/sys-kernel/linux-firmware-*
|
|
|
|
USE="-harfbuzz" emerge --oneshot --ask n freetype
|
|
|
|
emerge --oneshot --ask n freetype
|
|
|
|
|
2024-09-21 06:27:28 +00:00
|
|
|
#
|
|
|
|
# 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
|