debian-base/build-rootfs.sh

46 lines
1.5 KiB
Bash

#!/bin/bash
set -eu
VERS="${VERS:-bullseye}"
CACHEDIR="${CACHEDIR:-/cache}"
DESTDIR="${DESTDIR:-.}"
ROOTFS="${ROOTFS:-./rootfs}"
# in case the user passes a relative path
CACHEDIR="$(realpath ${CACHEDIR})"
apt update -y
apt install -y debootstrap
rm -rf "${ROOTFS}"
mkdir -p "${CACHEDIR}"
debootstrap --variant=minbase --cache-dir="${CACHEDIR}" "${VERS}" "${ROOTFS}"
cat > "${ROOTFS}/etc/apt/source.list" <<EOM
deb http://deb.debian.org/debian ${VERS} main contrib non-free
deb http://deb.debian.org/debian ${VERS}-updates main contrib non-free
deb http://security.debian.org/debian-security ${VERS}-security main contrib non-free
deb http://ftp.debian.org/debian ${VERS}-backports main contrib non-free
#deb-src http://deb.debian.org/debian ${VERS} main contrib
#deb-src http://deb.debian.org/debian ${VERS}-updates main contrib
#deb-src http://security.debian.org/debian-security ${VERS}-security main contrib
#deb-src http://ftp.debian.org/debian ${VERS}-backports main contrib
EOM
rm -rf "${ROOTFS}"/usr/share/doc/*
# we need to keep copyright files for legal reasons
#path-include /usr/share/doc/*/copyright
rm -rf "${ROOTFS}"/usr/share/man/*
rm -rf "${ROOTFS}"/usr/share/groff/*
rm -rf "${ROOTFS}"/usr/share/info/*
# lintian stuff is small, but really unnecessary
rm -rf "${ROOTFS}"/usr/share/lintian/*
rm -rf "${ROOTFS}"/usr/share/linda/*
rm -rf "${ROOTFS}"/var/cache/apt/archives/*
rm -rf "${ROOTFS}"/var/lib/apt/lists/*
tar -zcvf "${DESTDIR}/rootfs.tar.gz" -C "${ROOTFS}" .