<commit_before>#!/usr/bin/env bash
# Based on https://raw2.github.com/tmc/docker/master/contrib/mkimage-arch.sh

set -e

# Hack to make TTY a thing (https://github.com/dotcloud/docker/issues/728)
exec >/dev/tty 2>/dev/tty </dev/tty

# chdir to the script path
cd $(dirname "${BASH_SOURCE[0]}")

if [ ! -e /etc/pacman.d/gnupg ] ; then
    echo 'Generating pacman keys on build system'
    pacman-key --init &>/dev/null
    pacman-key --populate &>/dev/null
fi

echo 'Installing packages on build system'
pacman -Syu --noconfirm arch-install-scripts tar base-devel &>/dev/null
echo 'Bootstrap new root FS with packages'
rootfs=$(mktemp -d /build-XXXXXXXXXX)
pacstrap -c -d -G $rootfs pacman gzip &>/dev/null

echo 'Copy over pacman configuration'
cp /etc/pacman.conf $rootfs/etc/pacman.conf
cp /etc/pacman.d/mirrorlist $rootfs/etc/pacman.d/mirrorlist

echo 'Generate image pacman keys'
arch-chroot $rootfs pacman-key --init &>/dev/null
arch-chroot $rootfs pacman-key --populate &>/dev/null

echo 'Set timezone and locale'
ln -s /usr/share/zoneinfo/US/Eastern $rootfs/etc/localtime
echo 'en_US.UTF-8 UTF-8' > $rootfs/etc/locale.gen
arch-chroot $rootfs locale-gen >/dev/null

echo 'Install runit'
git clone git://github.com/akerl/runit /opt/runit &>/dev/null
(cd /opt/runit && ./package/compile &>/dev/null)
cp /opt/runit/command/* $rootfs/sbin/
mkdir $rootfs/etc/runit $rootfs/etc/sv $rootfs/service
cp /opt/runit/etc/debian/{1,2,3,ctrlaltdel} $rootfs/etc/runit/
ln -s /sbin/runit-init $rootfs/sbin/init

echo 'Populate /dev on new root FS'
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
ln -s /proc/self/fd/0 $dev/stdin
ln -s /proc/self/fd/1 $dev/stdout<commit_msg>UTC is the only real timezone<commit_after>#!/usr/bin/env bash
# Based on https://raw2.github.com/tmc/docker/master/contrib/mkimage-arch.sh

set -e

# Hack to make TTY a thing (https://github.com/dotcloud/docker/issues/728)
exec >/dev/tty 2>/dev/tty </dev/tty

# chdir to the script path
cd $(dirname "${BASH_SOURCE[0]}")

if [ ! -e /etc/pacman.d/gnupg ] ; then
    echo 'Generating pacman keys on build system'
    pacman-key --init &>/dev/null
    pacman-key --populate &>/dev/null
fi

echo 'Installing packages on build system'
pacman -Syu --noconfirm arch-install-scripts tar base-devel &>/dev/null
echo 'Bootstrap new root FS with packages'
rootfs=$(mktemp -d /build-XXXXXXXXXX)
pacstrap -c -d -G $rootfs pacman gzip &>/dev/null

echo 'Copy over pacman configuration'
cp /etc/pacman.conf $rootfs/etc/pacman.conf
cp /etc/pacman.d/mirrorlist $rootfs/etc/pacman.d/mirrorlist

echo 'Generate image pacman keys'
arch-chroot $rootfs pacman-key --init &>/dev/null
arch-chroot $rootfs pacman-key --populate &>/dev/null

echo 'Set timezone and locale'
ln -s /usr/share/zoneinfo/Etc/UTC $rootfs/etc/localtime
echo 'en_US.UTF-8 UTF-8' > $rootfs/etc/locale.gen
arch-chroot $rootfs locale-gen >/dev/null

echo 'Install runit'
git clone git://github.com/akerl/runit /opt/runit &>/dev/null
(cd /opt/runit && ./package/compile &>/dev/null)
cp /opt/runit/command/* $rootfs/sbin/
mkdir $rootfs/etc/runit $rootfs/etc/sv $rootfs/service
cp /opt/runit/etc/debian/{1,2,3,ctrlaltdel} $rootfs/etc/runit/
ln -s /sbin/runit-init $rootfs/sbin/init

echo 'Populate /dev on new root FS'
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
ln -s /proc/self/fd/0 $dev/stdin
ln -s /proc/self/fd/1 $dev/stdout
{'fraction_non_alphanumeric': 0.1475941161805036, 'fraction_numerical': 0.0344053851907255, 'mean_word_length': 3.3703703703703702, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '590190', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1618, 'n_words': 488}