37 lines
1.1 KiB
Bash
37 lines
1.1 KiB
Bash
|
#!/bin/bash
|
||
|
set -euo pipefail
|
||
|
shopt -s inherit_errexit
|
||
|
if [ ! "${UID}" == "0" ]; then
|
||
|
echo ":: Error: root user required"
|
||
|
exit 1
|
||
|
fi
|
||
|
DISTRIBUTION=archlinux
|
||
|
ARCH=x86_64
|
||
|
echo ":: Generating rootfs for ${DISTRIBUTION}-${ARCH}"
|
||
|
if [ -f "./${DISTRIBUTION}-${ARCH}.tar.gz" ]; then
|
||
|
echo ":: Removing ${DISTRIBUTION}-${ARCH}.tar.gz"
|
||
|
rm -rf "./${DISTRIBUTION}-${ARCH}.tar.gz"
|
||
|
fi
|
||
|
if [ -f "./${DISTRIBUTION}-${ARCH}.tar" ]; then
|
||
|
echo ":: Removing ${DISTRIBUTION}-${ARCH}.tar"
|
||
|
rm -rf "./${DISTRIBUTION}-${ARCH}.tar"
|
||
|
fi
|
||
|
if [ -d "./${DISTRIBUTION}-${ARCH}" ]; then
|
||
|
echo ":: Removing ${DISTRIBUTION}-${ARCH}"
|
||
|
rm -rf "./${DISTRIBUTION}-${ARCH}"
|
||
|
fi
|
||
|
mkdir -p "./${DISTRIBUTION}-${ARCH}"
|
||
|
cd "./${DISTRIBUTION}-${ARCH}"
|
||
|
echo ":: Installing system"
|
||
|
pacstrap -c -G -K -M -P . base
|
||
|
echo ":: Unmounting (safety measure)"
|
||
|
bash -c "umount ./{dev/pts,dev/shm,dev,sys,proc,run};exit 0"
|
||
|
echo ":: Archiving rootfs"
|
||
|
tar --acls -cpf "../${DISTRIBUTION}-${ARCH}.tar" ./*
|
||
|
cd ..
|
||
|
rm -rf "./${DISTRIBUTION}-${ARCH}"
|
||
|
echo ":: Compressing rootfs"
|
||
|
gzip --best ${DISTRIBUTION}-${ARCH}.tar
|
||
|
rm -rf "./${DISTRIBUTION}-${ARCH}.tar"
|
||
|
echo ":: Generated rootfs for ${DISTRIBUTION}-${ARCH}"
|