-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkroots.sh
More file actions
64 lines (50 loc) · 1.42 KB
/
mkroots.sh
File metadata and controls
64 lines (50 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
set -euxo pipefail
[ $(id -u) -eq 0 ] || exec sudo bash $0 "$@"
[ -e /usr/share/devtools/pacman.conf.d/extra.conf ] || {
echo "Missing 'devtools' on this system. Please 'pacman -S devtools'."
exit 1
}
# Packages required for the minimal system
packages=(
archlinux-keyring
awk
gzip
pacman
sed
systemd
)
# In case more packages were passed add them to the package list
if [ $# -gt 0 ]; then
packages+=("$@")
fi
# Build in a tempdir
tmpdir=$(mktemp -d)
function rm_temp() {
umount ${tmpdir}
rm -rf ${tmpdir}
}
trap rm_temp EXIT
# Create a bind-mount to avoid side-effects on the host system
mount --bind ${tmpdir} ${tmpdir}
# Pacstrap the requested packages
env -i pacstrap -C /usr/share/devtools/pacman.conf.d/extra.conf -c -G -M ${tmpdir} "${packages[@]}"
# Add local configurations
cp --recursive --preserve=timestamps --backup --suffix=.pacnew rootfs/* ${tmpdir}/
# Initialize locales and pacman-keys
arch-chroot ${tmpdir} bash -ex <<EOF
# Generate locales
locale-gen
# Initialize pacman-key keyring
pacman-key --init
pacman-key --populate archlinux
# Disable sandboxes for Container pacman
sed -i 's/#DisableSandbox/DisableSandbox/' /etc/pacman.conf
# Stop agent to free /dev mount
export GNUPGHOME=/etc/pacman.d/gnupg
gpgconf --kill gpg-agent
# Give the agent some time to die
sleep 5
EOF
# Pack rootfs
tar --numeric-owner --xattrs --acls --exclude-from=exclude -C ${tmpdir} -c . -f archlinux.tar