1
0
forked from brl/citadel
citadel/scripts/build-user-rootfs-stage-one

57 lines
1.7 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2018-02-20 17:19:19 +00:00
DEBIAN_MIRROR="https://deb.debian.org/debian"
DEBIAN_RELEASE="buster"
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
2018-02-20 17:19:19 +00:00
run_debootstrap() {
[[ -d ${DBS_ROOT} ]] && rm -rf ${DBS_ROOT}
2018-02-20 17:19:19 +00:00
[[ -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
2018-02-20 17:19:19 +00:00
debootstrap --verbose --merged-usr --variant=minbase \
--include=systemd-sysv,locales \
--exclude=sysv-rc,initscripts,startpar,lsb-base,insserv \
${DEBIAN_RELEASE} ${DBS_ROOT} ${DEBIAN_MIRROR}
}
2018-02-20 17:19:19 +00:00
run_chroot_stage() {
mount chproc ${DBS_ROOT}/proc -t proc
mount chsys ${DBS_ROOT}/sys -t sysfs
2018-02-20 17:19:19 +00:00
cp --preserve=mode ${SCRIPT_DIR}/build-user-rootfs-stage-two ${DBS_ROOT}/root/install.sh
2018-02-20 17:19:19 +00:00
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot ${DBS_ROOT} /root/install.sh ${DEBIAN_RELEASE} ${DEBIAN_MIRROR}
rm -f ${DBS_ROOT}/root/install.sh
}
2018-02-20 17:19:19 +00:00
cleanup_chroot() {
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
}
2018-02-20 17:19:19 +00:00
generate_tarball() {
printf "\n\n----- Generating rootfs tarball -----\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
printf "\n\n"
}
run_debootstrap
run_chroot_stage
cleanup_chroot
generate_tarball