citadel/scripts/build-user-rootfs-stage-one

41 lines
1.4 KiB
Plaintext
Raw Normal View History

#!/bin/bash
#SCRIPT=$(realpath ${BASH_SOURCE})
SCRIPT_DIR=$(dirname $(realpath ${BASH_SOURCE}))
DBS_BASE=$(realpath ${SCRIPT_DIR}/../build/debootstrap)
DBS_ROOT=${DBS_BASE}/rootfs
CACHE_DIR=${DBS_BASE}/var-cache-apt-archives
[[ -d ${DBS_ROOT} ]] && rm -rf ${DBS_ROOT}
[[ -f ${CACHE_DIR}/lock ]] && rm -f ${CACHE_DIR}/lock
mkdir -p ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
mount --bind ${CACHE_DIR} ${DBS_ROOT}/var/cache/apt/archives
debootstrap --verbose --merged-usr --variant=minbase --include=systemd-sysv,locales \
--exclude=sysv-rc,initscripts,startpar,lsb-base,insserv \
buster ${DBS_ROOT}
mount chproc ${DBS_ROOT}/proc -t proc
mount chsys ${DBS_ROOT}/sys -t sysfs
cp --preserve=mode ${SCRIPT_DIR}/build-user-rootfs-stage-two ${DBS_ROOT}/root/install.sh
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot ${DBS_ROOT} /root/install.sh
rm -f ${DBS_ROOT}/root/install.sh
umount ${DBS_ROOT}/proc
umount ${DBS_ROOT}/sys
umount ${DBS_ROOT}/var/cache/apt/archives
rm -f ${DBS_ROOT}/var/cache/apt/pkgcache.bin
rm -f ${DBS_ROOT}/var/cache/apt/srcpkgcache.bin
printf "\n\n----- Generating compressed tarball (this will take a couple of minutes) -----\n\n"
tar -C ${DBS_ROOT} -c --xattrs --xattrs-include=* -f ${DBS_BASE}/user-rootfs.tar .
xz --force --threads=0 ${DBS_BASE}/user-rootfs.tar
ls -al ${DBS_BASE}/user-rootfs.tar.xz
printf "\n\n"