2014-01-22 01:21:56 +00:00
|
|
|
#!/usr/bin/env bash
|
2013-10-15 23:09:02 +00:00
|
|
|
# Generate a minimal filesystem for archlinux and load it into the local
|
|
|
|
# docker as "archlinux"
|
|
|
|
# requires root
|
|
|
|
set -e
|
|
|
|
|
2014-01-06 12:36:04 +00:00
|
|
|
hash pacstrap &>/dev/null || {
|
2013-10-15 23:09:02 +00:00
|
|
|
echo "Could not find pacstrap. Run pacman -S arch-install-scripts"
|
|
|
|
exit 1
|
|
|
|
}
|
2014-01-06 12:08:55 +00:00
|
|
|
|
2014-01-06 12:36:04 +00:00
|
|
|
hash expect &>/dev/null || {
|
2013-10-15 23:09:02 +00:00
|
|
|
echo "Could not find expect. Run pacman -S expect"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2014-01-06 12:08:55 +00:00
|
|
|
ROOTFS=$(mktemp -d /tmp/rootfs-archlinux-XXXXXXXXXX)
|
2014-02-02 13:50:54 +00:00
|
|
|
chmod 755 $ROOTFS
|
2013-10-15 23:09:02 +00:00
|
|
|
|
2014-01-06 12:11:16 +00:00
|
|
|
# packages to ignore for space savings
|
2013-10-15 23:09:02 +00:00
|
|
|
PKGIGNORE=linux,jfsutils,lvm2,cryptsetup,groff,man-db,man-pages,mdadm,pciutils,pcmciautils,reiserfsprogs,s-nail,xfsprogs
|
2014-01-06 12:13:19 +00:00
|
|
|
|
2013-10-18 05:34:29 +00:00
|
|
|
expect <<EOF
|
2013-10-15 23:09:02 +00:00
|
|
|
set timeout 60
|
2013-10-18 05:34:29 +00:00
|
|
|
set send_slow {1 1}
|
2014-01-06 13:25:36 +00:00
|
|
|
spawn pacstrap -C ./mkimage-arch-pacman.conf -c -d -G -i $ROOTFS base haveged --ignore $PKGIGNORE
|
2013-10-15 23:09:02 +00:00
|
|
|
expect {
|
2013-10-18 05:34:29 +00:00
|
|
|
"Install anyway?" { send n\r; exp_continue }
|
|
|
|
"(default=all)" { send \r; exp_continue }
|
|
|
|
"Proceed with installation?" { send "\r"; exp_continue }
|
|
|
|
"skip the above package" {send "y\r"; exp_continue }
|
|
|
|
"checking" { exp_continue }
|
|
|
|
"loading" { exp_continue }
|
|
|
|
"installing" { exp_continue }
|
|
|
|
}
|
|
|
|
EOF
|
2013-10-15 23:09:02 +00:00
|
|
|
|
|
|
|
arch-chroot $ROOTFS /bin/sh -c "haveged -w 1024; pacman-key --init; pkill haveged; pacman -Rs --noconfirm haveged; pacman-key --populate archlinux"
|
|
|
|
arch-chroot $ROOTFS /bin/sh -c "ln -s /usr/share/zoneinfo/UTC /etc/localtime"
|
2014-01-06 12:13:19 +00:00
|
|
|
echo 'en_US.UTF-8 UTF-8' > $ROOTFS/etc/locale.gen
|
2013-10-15 23:09:02 +00:00
|
|
|
arch-chroot $ROOTFS locale-gen
|
2014-02-19 23:11:04 +00:00
|
|
|
arch-chroot $ROOTFS /bin/sh -c 'echo "Server = https://mirrors.kernel.org/archlinux/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist'
|
2013-10-15 23:09:02 +00:00
|
|
|
|
|
|
|
# udev doesn't work in containers, rebuild /dev
|
2014-01-06 12:11:16 +00: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
|
2013-10-15 23:09:02 +00:00
|
|
|
|
2013-10-23 20:08:16 +00:00
|
|
|
tar --numeric-owner -C $ROOTFS -c . | docker import - archlinux
|
2013-10-15 23:09:02 +00:00
|
|
|
docker run -i -t archlinux echo Success.
|
|
|
|
rm -rf $ROOTFS
|