2014-01-21 20:21:56 -05:00
|
|
|
#!/usr/bin/env bash
|
2013-10-15 19:09:02 -04:00
|
|
|
# Generate a minimal filesystem for archlinux and load it into the local
|
|
|
|
# docker as "archlinux"
|
|
|
|
# requires root
|
|
|
|
set -e
|
|
|
|
|
2014-01-06 07:36:04 -05:00
|
|
|
hash pacstrap &>/dev/null || {
|
2014-07-09 11:38:13 -04:00
|
|
|
echo "Could not find pacstrap. Run pacman -S arch-install-scripts"
|
|
|
|
exit 1
|
2013-10-15 19:09:02 -04:00
|
|
|
}
|
2014-01-06 07:08:55 -05:00
|
|
|
|
2014-07-09 11:08:17 -04:00
|
|
|
hash expect &>/dev/null || {
|
2014-07-09 11:38:13 -04:00
|
|
|
echo "Could not find expect. Run pacman -S expect"
|
|
|
|
exit 1
|
2014-07-09 11:08:17 -04:00
|
|
|
}
|
|
|
|
|
2015-03-28 00:33:24 -04:00
|
|
|
export LANG="C.UTF-8"
|
|
|
|
|
2014-06-27 08:43:12 -04:00
|
|
|
ROOTFS=$(mktemp -d ${TMPDIR:-/var/tmp}/rootfs-archlinux-XXXXXXXXXX)
|
2014-02-02 08:50:54 -05:00
|
|
|
chmod 755 $ROOTFS
|
2013-10-15 19:09:02 -04:00
|
|
|
|
2014-01-06 07:11:16 -05:00
|
|
|
# packages to ignore for space savings
|
2014-12-20 19:16:19 -05:00
|
|
|
PKGIGNORE=(
|
|
|
|
cryptsetup
|
|
|
|
device-mapper
|
|
|
|
dhcpcd
|
|
|
|
iproute2
|
|
|
|
jfsutils
|
|
|
|
linux
|
|
|
|
lvm2
|
|
|
|
man-db
|
|
|
|
man-pages
|
|
|
|
mdadm
|
|
|
|
nano
|
|
|
|
netctl
|
|
|
|
openresolv
|
|
|
|
pciutils
|
|
|
|
pcmciautils
|
|
|
|
reiserfsprogs
|
|
|
|
s-nail
|
|
|
|
systemd-sysvcompat
|
|
|
|
usbutils
|
|
|
|
vi
|
|
|
|
xfsprogs
|
|
|
|
)
|
|
|
|
IFS=','
|
|
|
|
PKGIGNORE="${PKGIGNORE[*]}"
|
|
|
|
unset IFS
|
2014-01-06 07:13:19 -05:00
|
|
|
|
2014-07-09 11:08:17 -04:00
|
|
|
expect <<EOF
|
2014-07-09 11:38:13 -04:00
|
|
|
set send_slow {1 .1}
|
|
|
|
proc send {ignore arg} {
|
|
|
|
sleep .1
|
|
|
|
exp_send -s -- \$arg
|
|
|
|
}
|
|
|
|
set timeout 60
|
|
|
|
|
|
|
|
spawn pacstrap -C ./mkimage-arch-pacman.conf -c -d -G -i $ROOTFS base haveged --ignore $PKGIGNORE
|
|
|
|
expect {
|
|
|
|
-exact "anyway? \[Y/n\] " { send -- "n\r"; exp_continue }
|
|
|
|
-exact "(default=all): " { send -- "\r"; exp_continue }
|
|
|
|
-exact "installation? \[Y/n\]" { send -- "y\r"; exp_continue }
|
|
|
|
}
|
2014-07-09 11:08:17 -04:00
|
|
|
EOF
|
2013-10-15 19:09:02 -04:00
|
|
|
|
2014-12-20 19:25:15 -05:00
|
|
|
arch-chroot $ROOTFS /bin/sh -c 'rm -r /usr/share/man/*'
|
2014-12-11 21:25:14 -05:00
|
|
|
arch-chroot $ROOTFS /bin/sh -c "haveged -w 1024; pacman-key --init; pkill haveged; pacman -Rs --noconfirm haveged; pacman-key --populate archlinux; pkill gpg-agent"
|
2013-10-15 19:09:02 -04:00
|
|
|
arch-chroot $ROOTFS /bin/sh -c "ln -s /usr/share/zoneinfo/UTC /etc/localtime"
|
2014-01-06 07:13:19 -05:00
|
|
|
echo 'en_US.UTF-8 UTF-8' > $ROOTFS/etc/locale.gen
|
2013-10-15 19:09:02 -04:00
|
|
|
arch-chroot $ROOTFS locale-gen
|
2014-02-19 18:11:04 -05:00
|
|
|
arch-chroot $ROOTFS /bin/sh -c 'echo "Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist'
|
2013-10-15 19:09:02 -04:00
|
|
|
|
|
|
|
# udev doesn't work in containers, rebuild /dev
|
2014-01-06 07:11:16 -05:00
|
|
|
DEV=$ROOTFS/dev
|
|
|
|
rm -rf $DEV
|
|
|
|
mkdir -p $DEV
|
|
|
|
mknod -m 666 $DEV/null c 1 3
|
|
|
|
mknod -m 666 $DEV/zero c 1 5
|
|
|
|
mknod -m 666 $DEV/random c 1 8
|
|
|
|
mknod -m 666 $DEV/urandom c 1 9
|
|
|
|
mkdir -m 755 $DEV/pts
|
|
|
|
mkdir -m 1777 $DEV/shm
|
|
|
|
mknod -m 666 $DEV/tty c 5 0
|
|
|
|
mknod -m 600 $DEV/console c 5 1
|
|
|
|
mknod -m 666 $DEV/tty0 c 4 0
|
|
|
|
mknod -m 666 $DEV/full c 1 7
|
|
|
|
mknod -m 600 $DEV/initctl p
|
|
|
|
mknod -m 666 $DEV/ptmx c 5 2
|
2014-04-19 03:57:17 -04:00
|
|
|
ln -sf /proc/self/fd $DEV/fd
|
2013-10-15 19:09:02 -04:00
|
|
|
|
2014-10-06 04:23:56 -04:00
|
|
|
tar --numeric-owner --xattrs --acls -C $ROOTFS -c . | docker import - archlinux
|
2015-11-22 06:46:13 -05:00
|
|
|
docker run --rm -t archlinux echo Success.
|
2013-10-15 19:09:02 -04:00
|
|
|
rm -rf $ROOTFS
|