2021-03-26 18:03:50 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-02-16 11:48:21 +01:00
|
|
|
# Dependencies: curl tar gzip grep sha256sum
|
2021-03-26 18:03:50 +01:00
|
|
|
# Root rights are required
|
|
|
|
|
|
|
|
if [ $EUID != 0 ]; then
|
|
|
|
echo "Root rights are required!"
|
2021-03-27 10:04:21 +01:00
|
|
|
|
2021-03-26 18:03:50 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-02-16 11:48:21 +01:00
|
|
|
if ! command -v curl 1>/dev/null; then
|
|
|
|
echo "curl is required!"
|
2021-05-27 22:16:50 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! command -v gzip 1>/dev/null; then
|
|
|
|
echo "gzip is required!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-04-11 12:08:42 +02:00
|
|
|
if ! command -v grep 1>/dev/null; then
|
|
|
|
echo "grep is required!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! command -v sha256sum 1>/dev/null; then
|
|
|
|
echo "sha256sum is required!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-03-26 18:03:50 +01:00
|
|
|
script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
|
|
|
|
|
|
|
mount_chroot () {
|
|
|
|
# First unmount just in case
|
|
|
|
umount -Rl "${bootstrap}"
|
2021-03-27 10:04:21 +01:00
|
|
|
|
2021-03-26 18:03:50 +01:00
|
|
|
mount --bind "${bootstrap}" "${bootstrap}"
|
2021-05-27 22:07:34 +02:00
|
|
|
mount -t proc /proc "${bootstrap}"/proc
|
2021-05-28 13:29:17 +02:00
|
|
|
mount --bind /sys "${bootstrap}"/sys
|
2021-05-28 12:14:00 +02:00
|
|
|
mount --make-rslave "${bootstrap}"/sys
|
2021-05-28 13:29:17 +02:00
|
|
|
mount --bind /dev "${bootstrap}"/dev
|
|
|
|
mount --bind /dev/pts "${bootstrap}"/dev/pts
|
|
|
|
mount --bind /dev/shm "${bootstrap}"/dev/shm
|
2021-05-28 12:14:00 +02:00
|
|
|
mount --make-rslave "${bootstrap}"/dev
|
2021-05-27 22:07:34 +02:00
|
|
|
|
|
|
|
rm -f "${bootstrap}"/etc/resolv.conf
|
|
|
|
cp /etc/resolv.conf "${bootstrap}"/etc/resolv.conf
|
2021-05-28 13:29:17 +02:00
|
|
|
|
|
|
|
mkdir -p "${bootstrap}"/run/shm
|
2021-03-26 18:03:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
unmount_chroot () {
|
2021-05-28 13:29:17 +02:00
|
|
|
umount -l "${bootstrap}"
|
|
|
|
umount "${bootstrap}"/proc
|
|
|
|
umount "${bootstrap}"/sys
|
|
|
|
umount "${bootstrap}"/dev/pts
|
|
|
|
umount "${bootstrap}"/dev/shm
|
|
|
|
umount "${bootstrap}"/dev
|
2021-03-26 18:03:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
run_in_chroot () {
|
|
|
|
chroot "${bootstrap}" /usr/bin/env LANG=en_US.UTF-8 TERM=xterm PATH="/bin:/sbin:/usr/bin:/usr/sbin" "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_localegen () {
|
|
|
|
cat <<EOF > locale.gen
|
2021-03-27 10:04:21 +01:00
|
|
|
ar_EG.UTF-8 UTF-8
|
|
|
|
en_US.UTF-8 UTF-8
|
2021-05-27 15:19:07 +02:00
|
|
|
en_GB.UTF-8 UTF-8
|
|
|
|
en_CA.UTF-8 UTF-8
|
2023-05-28 13:52:18 +02:00
|
|
|
en_SG.UTF-8 UTF-8
|
2021-03-27 10:04:21 +01:00
|
|
|
es_MX.UTF-8 UTF-8
|
2021-05-27 15:19:07 +02:00
|
|
|
zh_CN.UTF-8 UTF-8
|
2021-03-27 10:04:21 +01:00
|
|
|
fr_FR.UTF-8 UTF-8
|
2021-05-27 15:19:07 +02:00
|
|
|
ru_RU.UTF-8 UTF-8
|
|
|
|
ru_UA.UTF-8 UTF-8
|
|
|
|
es_ES.UTF-8 UTF-8
|
|
|
|
de_DE.UTF-8 UTF-8
|
|
|
|
pt_BR.UTF-8 UTF-8
|
2021-03-27 10:04:21 +01:00
|
|
|
it_IT.UTF-8 UTF-8
|
2023-05-28 13:52:18 +02:00
|
|
|
id_ID.UTF-8 UTF-8
|
2021-03-27 10:04:21 +01:00
|
|
|
ja_JP.UTF-8 UTF-8
|
2021-05-27 15:19:07 +02:00
|
|
|
bg_BG.UTF-8 UTF-8
|
2021-03-27 10:04:21 +01:00
|
|
|
pl_PL.UTF-8 UTF-8
|
2021-05-27 15:19:07 +02:00
|
|
|
da_DK.UTF-8 UTF-8
|
|
|
|
ko_KR.UTF-8 UTF-8
|
2021-03-27 10:04:21 +01:00
|
|
|
tr_TR.UTF-8 UTF-8
|
2021-05-27 15:19:07 +02:00
|
|
|
hu_HU.UTF-8 UTF-8
|
|
|
|
cs_CZ.UTF-8 UTF-8
|
|
|
|
bn_IN UTF-8
|
2023-05-28 13:52:18 +02:00
|
|
|
hi_IN UTF-8
|
2021-03-26 18:03:50 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_mirrorlist () {
|
|
|
|
cat <<EOF > mirrorlist
|
2023-04-07 21:23:24 +02:00
|
|
|
Server = https://mirror.sunred.org/archlinux/\$repo/os/\$arch
|
|
|
|
Server = https://mirror.lcarilla.de/archlinux/\$repo/os/\$arch
|
2023-06-07 10:53:20 +02:00
|
|
|
Server = https://theswissbay.ch/archlinux/\$repo/os/\$arch
|
|
|
|
Server = https://archimonde.ts.si/archlinux/\$repo/os/\$arch
|
|
|
|
Server = https://mirror.f4st.host/archlinux/\$repo/os/\$arch
|
|
|
|
Server = https://america.mirror.pkgbuild.com/\$repo/os/\$arch
|
2023-04-07 21:23:24 +02:00
|
|
|
Server = https://archlinux.thaller.ws/\$repo/os/\$arch
|
2023-06-07 10:53:20 +02:00
|
|
|
Server = https://mirror.tux.si/arch/\$repo/os/\$arch
|
|
|
|
Server = https://mirror.cyberbits.eu/archlinux/\$repo/os/\$arch
|
|
|
|
Server = https://archlinux.uk.mirror.allworldit.com/archlinux/\$repo/os/\$arch
|
2021-03-26 18:03:50 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
cd "${script_dir}" || exit 1
|
|
|
|
|
|
|
|
bootstrap="${script_dir}"/root.x86_64
|
|
|
|
|
2021-06-17 14:55:38 +02:00
|
|
|
# Package groups
|
|
|
|
|
|
|
|
audio_pkgs="alsa-lib lib32-alsa-lib alsa-plugins lib32-alsa-plugins libpulse \
|
|
|
|
lib32-libpulse jack2 lib32-jack2 alsa-tools alsa-utils"
|
|
|
|
|
|
|
|
video_pkgs="mesa lib32-mesa vulkan-radeon lib32-vulkan-radeon \
|
|
|
|
vulkan-intel lib32-vulkan-intel nvidia-utils lib32-nvidia-utils \
|
|
|
|
vulkan-icd-loader lib32-vulkan-icd-loader vulkan-mesa-layers \
|
|
|
|
lib32-vulkan-mesa-layers libva-mesa-driver lib32-libva-mesa-driver \
|
|
|
|
libva-intel-driver lib32-libva-intel-driver intel-media-driver \
|
2022-09-11 08:59:22 +02:00
|
|
|
mesa-utils vulkan-tools nvidia-prime libva-utils lib32-mesa-utils"
|
2021-06-17 14:55:38 +02:00
|
|
|
|
2021-11-28 12:43:50 +01:00
|
|
|
wine_pkgs="wine-staging winetricks-git wine-nine wineasio \
|
2021-06-17 14:55:38 +02:00
|
|
|
giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap \
|
|
|
|
gnutls lib32-gnutls mpg123 lib32-mpg123 openal lib32-openal \
|
|
|
|
v4l-utils lib32-v4l-utils libpulse lib32-libpulse alsa-plugins \
|
|
|
|
lib32-alsa-plugins alsa-lib lib32-alsa-lib libjpeg-turbo \
|
|
|
|
lib32-libjpeg-turbo libxcomposite lib32-libxcomposite libxinerama \
|
|
|
|
lib32-libxinerama libxslt lib32-libxslt libva lib32-libva gtk3 \
|
|
|
|
lib32-gtk3 vulkan-icd-loader lib32-vulkan-icd-loader sdl2 lib32-sdl2 \
|
|
|
|
vkd3d lib32-vkd3d libgphoto2 ffmpeg gst-plugins-good gst-plugins-bad \
|
2023-04-02 15:11:30 +02:00
|
|
|
gst-plugins-ugly gst-plugins-base lib32-gst-plugins-good lib32-gst-plugins-base gst-libav"
|
2021-06-17 14:55:38 +02:00
|
|
|
|
2021-05-25 16:00:49 +02:00
|
|
|
# List of packages to install
|
|
|
|
# You can remove packages that you don't need
|
2021-05-28 13:15:56 +02:00
|
|
|
# Besides packages from the official Arch repos, you can list
|
|
|
|
# packages from the Chaotic-AUR repo here
|
2022-04-05 12:52:53 +02:00
|
|
|
export packagelist="${audio_pkgs} ${video_pkgs} ${wine_pkgs} \
|
2021-06-17 14:55:38 +02:00
|
|
|
base-devel nano ttf-dejavu ttf-liberation lutris steam firefox \
|
|
|
|
mpv geany pcmanfm ppsspp dolphin-emu git wget htop qbittorrent \
|
2022-04-05 10:03:48 +02:00
|
|
|
speedcrunch gpicview file-roller xorg-xwayland steam-native-runtime \
|
2021-06-17 14:55:38 +02:00
|
|
|
meson mingw-w64-gcc gamemode lib32-gamemode cmake jre-openjdk \
|
2022-05-26 16:09:49 +02:00
|
|
|
lxterminal steamtinkerlaunch mangohud lib32-mangohud qt6-wayland \
|
2023-01-12 11:02:15 +01:00
|
|
|
wayland lib32-wayland qt5-wayland retroarch xorg-server-xephyr \
|
|
|
|
openbox obs-studio gamehub minigalaxy legendary gamescope \
|
2023-04-02 16:21:30 +02:00
|
|
|
pcsx2-git multimc5 yt-dlp bottles playonlinux minizip duckstation-git"
|
2021-03-29 22:57:54 +02:00
|
|
|
|
2023-02-16 11:48:21 +01:00
|
|
|
curl -#LO 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst'
|
|
|
|
curl -#LO 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
|
2022-04-05 12:52:53 +02:00
|
|
|
|
|
|
|
if [ ! -s chaotic-keyring.pkg.tar.zst ] || [ ! -s chaotic-mirrorlist.pkg.tar.zst ]; then
|
2022-07-17 16:02:39 +02:00
|
|
|
echo "Seems like Chaotic-AUR keyring or mirrorlist is currently unavailable"
|
|
|
|
echo "Please try again later"
|
2022-04-05 12:52:53 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-05-23 16:39:24 +02:00
|
|
|
bootstrap_urls=("mirror.f4st.host" \
|
|
|
|
"arch.hu.fo" \
|
|
|
|
"mirror.cyberbits.eu" \
|
|
|
|
"mirror.osbeck.com" \
|
|
|
|
"mirror.lcarilla.de" \
|
|
|
|
"mirror.moson.org")
|
2022-04-11 11:58:19 +02:00
|
|
|
|
2022-08-10 14:52:24 +02:00
|
|
|
echo "Downloading Arch Linux bootstrap"
|
2022-04-11 11:58:19 +02:00
|
|
|
|
2023-02-15 20:57:05 +01:00
|
|
|
for link in "${bootstrap_urls[@]}"; do
|
2023-02-16 11:48:21 +01:00
|
|
|
curl -#LO "https://${link}/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz"
|
|
|
|
curl -#LO "https://${link}/archlinux/iso/latest/sha256sums.txt"
|
2022-04-11 11:58:19 +02:00
|
|
|
|
|
|
|
if [ -s sha256sums.txt ]; then
|
2023-02-15 20:57:05 +01:00
|
|
|
grep bootstrap-x86_64 sha256sums.txt > sha256.txt
|
2022-04-11 11:58:19 +02:00
|
|
|
|
|
|
|
echo "Verifying the integrity of the bootstrap"
|
|
|
|
if sha256sum -c sha256.txt &>/dev/null; then
|
|
|
|
bootstrap_is_good=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Download failed, trying again with different mirror"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "${bootstrap_is_good}" ]; then
|
|
|
|
echo "Bootstrap download failed or its checksum is incorrect"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-05-23 16:39:24 +02:00
|
|
|
rm -rf "${bootstrap}"
|
2022-08-10 14:52:24 +02:00
|
|
|
tar xf archlinux-bootstrap-x86_64.tar.gz
|
|
|
|
rm archlinux-bootstrap-x86_64.tar.gz sha256sums.txt sha256.txt
|
2021-03-26 18:03:50 +01:00
|
|
|
|
|
|
|
mount_chroot
|
|
|
|
|
|
|
|
generate_localegen
|
2021-05-12 23:58:34 +02:00
|
|
|
|
|
|
|
if command -v reflector 1>/dev/null; then
|
|
|
|
reflector --protocol https --score 5 --sort rate --save mirrorlist
|
|
|
|
else
|
|
|
|
generate_mirrorlist
|
|
|
|
fi
|
2021-03-26 18:03:50 +01:00
|
|
|
|
|
|
|
rm "${bootstrap}"/etc/locale.gen
|
2022-04-05 12:52:53 +02:00
|
|
|
mv locale.gen "${bootstrap}"/etc/locale.gen
|
2021-03-26 18:03:50 +01:00
|
|
|
|
|
|
|
rm "${bootstrap}"/etc/pacman.d/mirrorlist
|
2022-04-05 12:52:53 +02:00
|
|
|
mv mirrorlist "${bootstrap}"/etc/pacman.d/mirrorlist
|
2021-03-26 18:03:50 +01:00
|
|
|
|
2023-02-15 20:57:05 +01:00
|
|
|
{
|
|
|
|
echo
|
|
|
|
echo "[multilib]"
|
|
|
|
echo "Include = /etc/pacman.d/mirrorlist"
|
|
|
|
} >> "${bootstrap}"/etc/pacman.conf
|
2021-03-26 18:03:50 +01:00
|
|
|
|
|
|
|
run_in_chroot pacman-key --init
|
2021-06-23 10:23:43 +02:00
|
|
|
echo "keyserver hkps://keyserver.ubuntu.com" >> "${bootstrap}"/etc/pacman.d/gnupg/gpg.conf
|
2021-03-26 18:03:50 +01:00
|
|
|
run_in_chroot pacman-key --populate archlinux
|
2021-05-28 13:15:56 +02:00
|
|
|
|
|
|
|
# Add Chaotic-AUR repo
|
2021-11-26 18:03:50 +01:00
|
|
|
run_in_chroot pacman-key --recv-key FBA220DFC880C036
|
|
|
|
run_in_chroot pacman-key --lsign-key FBA220DFC880C036
|
2022-04-05 12:52:53 +02:00
|
|
|
|
|
|
|
mv chaotic-keyring.pkg.tar.zst chaotic-mirrorlist.pkg.tar.zst "${bootstrap}"/opt
|
|
|
|
run_in_chroot pacman --noconfirm -U /opt/chaotic-keyring.pkg.tar.zst /opt/chaotic-mirrorlist.pkg.tar.zst
|
|
|
|
rm "${bootstrap}"/opt/chaotic-keyring.pkg.tar.zst "${bootstrap}"/opt/chaotic-mirrorlist.pkg.tar.zst
|
2021-05-28 13:15:56 +02:00
|
|
|
|
2023-02-15 20:57:05 +01:00
|
|
|
{
|
|
|
|
echo
|
|
|
|
echo "[chaotic-aur]"
|
|
|
|
echo "Include = /etc/pacman.d/chaotic-mirrorlist"
|
|
|
|
} >> "${bootstrap}"/etc/pacman.conf
|
2021-05-28 13:15:56 +02:00
|
|
|
|
2021-09-11 12:09:16 +02:00
|
|
|
# The ParallelDownloads feature of pacman
|
|
|
|
# Speeds up packages installation, especially when there are many small packages to install
|
|
|
|
sed -i 's/#ParallelDownloads = 5/ParallelDownloads = 3/g' "${bootstrap}"/etc/pacman.conf
|
2021-06-17 14:46:35 +02:00
|
|
|
|
2022-07-28 10:58:34 +02:00
|
|
|
run_in_chroot pacman -Sy archlinux-keyring --noconfirm
|
|
|
|
run_in_chroot pacman -Su --noconfirm
|
2021-05-25 16:19:37 +02:00
|
|
|
|
2021-10-27 21:52:32 +02:00
|
|
|
date -u +"%d-%m-%Y %H:%M (DMY UTC)" > "${bootstrap}"/version
|
|
|
|
|
2021-05-25 16:19:37 +02:00
|
|
|
# These packages are required for the self-update feature to work properly
|
2021-05-27 16:21:37 +02:00
|
|
|
run_in_chroot pacman --noconfirm --needed -S base reflector squashfs-tools fakeroot
|
|
|
|
|
2022-04-05 12:52:53 +02:00
|
|
|
cat <<EOF > "${bootstrap}"/opt/install_packages.sh
|
|
|
|
echo "Checking if packages are present in the repos, please wait..."
|
|
|
|
for p in \${packagelist}; do
|
|
|
|
if pacman -Sp "\${p}" &>/dev/null; then
|
|
|
|
good_pkglist="\${good_pkglist} \${p}"
|
|
|
|
else
|
|
|
|
bad_pkglist="\${bad_pkglist} \${p}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "\${bad_pkglist}" ]; then
|
|
|
|
echo \${bad_pkglist} > /opt/bad_pkglist.txt
|
|
|
|
fi
|
|
|
|
|
2023-05-23 16:39:24 +02:00
|
|
|
pacman --noconfirm --needed -S \${good_pkglist} || pacman --noconfirm --needed -S \${good_pkglist} || echo > /opt/pacman_failed.txt
|
2022-04-05 12:52:53 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod +x "${bootstrap}"/opt/install_packages.sh
|
2022-04-05 16:47:19 +02:00
|
|
|
run_in_chroot bash /opt/install_packages.sh
|
2022-04-05 12:52:53 +02:00
|
|
|
rm "${bootstrap}"/opt/install_packages.sh
|
2021-03-26 18:03:50 +01:00
|
|
|
|
2023-05-23 16:39:24 +02:00
|
|
|
if [ -f "${bootstrap}"/opt/pacman_failed.txt ]; then
|
|
|
|
unmount_chroot
|
|
|
|
echo "Pacman failed to install some packages"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-05-25 16:19:37 +02:00
|
|
|
run_in_chroot locale-gen
|
|
|
|
|
2021-09-22 13:15:48 +02:00
|
|
|
# Generate a list of installed packages
|
|
|
|
run_in_chroot pacman -Qn > "${bootstrap}"/pkglist.x86_64.txt
|
|
|
|
|
2021-04-06 21:18:13 +02:00
|
|
|
unmount_chroot
|
|
|
|
|
2021-05-22 11:54:24 +02:00
|
|
|
# Clear pacman package cache
|
2021-04-11 21:32:56 +02:00
|
|
|
rm -f "${bootstrap}"/var/cache/pacman/pkg/*
|
2021-05-22 11:54:24 +02:00
|
|
|
|
|
|
|
# Create some empty files and directories
|
|
|
|
# This is needed for bubblewrap to be able to bind real files/dirs to them
|
|
|
|
# later in the conty-start.sh script
|
2021-03-27 12:59:35 +01:00
|
|
|
mkdir "${bootstrap}"/media
|
2021-09-12 12:40:14 +02:00
|
|
|
mkdir -p "${bootstrap}"/usr/share/steam/compatibilitytools.d
|
2021-04-06 21:18:13 +02:00
|
|
|
touch "${bootstrap}"/etc/asound.conf
|
2021-05-22 11:54:24 +02:00
|
|
|
touch "${bootstrap}"/etc/localtime
|
2021-05-28 13:36:11 +02:00
|
|
|
chmod 755 "${bootstrap}"/root
|
2021-03-26 18:03:50 +01:00
|
|
|
|
2021-06-09 23:03:50 +02:00
|
|
|
# Enable full font hinting
|
|
|
|
rm -f "${bootstrap}"/etc/fonts/conf.d/10-hinting-slight.conf
|
|
|
|
ln -s /usr/share/fontconfig/conf.avail/10-hinting-full.conf "${bootstrap}"/etc/fonts/conf.d
|
|
|
|
|
2021-03-26 18:03:50 +01:00
|
|
|
clear
|
|
|
|
echo "Done"
|
2022-04-05 12:52:53 +02:00
|
|
|
|
|
|
|
if [ -f "${bootstrap}"/opt/bad_pkglist.txt ]; then
|
|
|
|
echo
|
|
|
|
echo "These packages are not in the repos and have not been installed:"
|
|
|
|
cat "${bootstrap}"/opt/bad_pkglist.txt
|
|
|
|
rm "${bootstrap}"/opt/bad_pkglist.txt
|
|
|
|
fi
|