2021-09-10 20:21:23 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# created by Tobias Powalowski <tpowa@archlinux.org>
|
2021-09-23 09:22:27 +02:00
|
|
|
_PWD="$(pwd)"
|
2021-09-10 20:21:23 +02:00
|
|
|
_BASENAME="$(basename "${0}")"
|
2021-09-23 09:14:28 +02:00
|
|
|
_CACHEDIR=""$1"/var/cache/pacman/pkg"
|
|
|
|
|
2021-09-10 20:21:23 +02:00
|
|
|
usage () {
|
|
|
|
echo "${_BASENAME}: usage"
|
|
|
|
echo "CREATE ARCHBOOT CONTAINER"
|
|
|
|
echo "-----------------------------"
|
|
|
|
echo "Usage: ${_BASENAME} <directory>"
|
|
|
|
echo "This will create an archboot container for an archboot image."
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
[[ -z "${1}" ]] && usage
|
|
|
|
|
|
|
|
### check for root
|
|
|
|
if ! [[ ${UID} -eq 0 ]]; then
|
|
|
|
echo "ERROR: Please run as root user!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-09-23 09:14:28 +02:00
|
|
|
|
|
|
|
# prepare pacman dirs
|
|
|
|
mkdir -p "$1"/var/lib/pacman
|
|
|
|
mkdir -p "${_CACHEDIR}"
|
2021-09-21 19:40:33 +02:00
|
|
|
# install archboot
|
2021-09-24 13:42:02 +02:00
|
|
|
pacman --root "$1" -Sy base archboot archboot-linux-firmware --noconfirm --cachedir "${_PWD}"/"${_CACHEDIR}"
|
2021-09-21 19:40:33 +02:00
|
|
|
# generate locales
|
2021-09-23 09:14:28 +02:00
|
|
|
systemd-nspawn -D "$1" /bin/bash -c "echo 'en_US ISO-8859-1' >> /etc/locale.gen"
|
|
|
|
systemd-nspawn -D "$1" /bin/bash -c "echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen"
|
|
|
|
systemd-nspawn -D "$1" locale-gen
|
2021-09-21 19:40:33 +02:00
|
|
|
# generate pacman keyring
|
2021-09-23 09:14:28 +02:00
|
|
|
systemd-nspawn -D "$1" pacman-key --init
|
|
|
|
systemd-nspawn -D "$1" pacman-key --populate archlinux
|
2021-09-21 19:40:33 +02:00
|
|
|
# add genneral mirror
|
2021-09-23 09:14:28 +02:00
|
|
|
systemd-nspawn -D "$1" /bin/bash -c "echo 'Server = https://mirror.rackspace.com/archlinux/\$repo/os/\$arch' >> /etc/pacman.d/mirrorlist"
|
2021-09-21 19:40:33 +02:00
|
|
|
# disable checkspace option in pacman.conf, to allow to install packages in environment
|
2021-09-23 09:14:28 +02:00
|
|
|
systemd-nspawn -D "$1" /bin/bash -c "sed -i -e 's:^CheckSpace:#CheckSpace:g' /etc/pacman.conf"
|
2021-09-22 15:00:43 +02:00
|
|
|
# enable parallel downloads
|
2021-09-23 09:14:28 +02:00
|
|
|
systemd-nspawn -D "$1" /bin/bash -c "sed -i -e 's:^#ParallelDownloads:ParallelDownloads:g' /etc/pacman.conf"
|
2021-09-22 14:30:28 +02:00
|
|
|
# reinstall kernel to get files in /boot
|
2021-09-23 09:14:28 +02:00
|
|
|
systemd-nspawn -D "$1" pacman -Sy linux --noconfirm
|
|
|
|
# clean cache
|
|
|
|
systemd-nspawn -D "$1" pacman -Scc --noconfirm
|
|
|
|
# clean container from not needed files
|
|
|
|
rm -r "$1"/usr/include
|
|
|
|
rm -r "$1"/usr/share/{man,doc}
|
2021-09-24 13:42:02 +02:00
|
|
|
|
2021-09-24 09:34:07 +02:00
|
|
|
|