Files
debian-base/base-image-script/bootstrap-rootfs.sh
fithwum 1dd36ffafe
Some checks failed
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-and-push-rootfs-archives (push) Has been cancelled
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-and-push-docker-images (push) Has been cancelled
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-changelogs (push) Has been cancelled
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-build-info (push) Has been cancelled
dsfhsd
2025-07-08 20:45:24 -07:00

52 lines
1.5 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
DEBIAN_RELEASE="${VERSION:-}"
ROOTFS_DIR="debian-${DEBIAN_RELEASE}"
OUTPUT_DIR="/output"
TARBALL="${OUTPUT_DIR}/$DEBIAN_RELEASE/debian-${DEBIAN_RELEASE}.tar.bz2"
echo "[INFO] Bootstrapping Debian $DEBIAN_RELEASE rootfs..."
apt-get update
apt-get install -y --no-install-recommends debootstrap bzip2
debootstrap --verbose --variant=minbase --components=main,contrib,non-free \
--include=apt,ca-certificates --arch=amd64 "$DEBIAN_RELEASE" "$ROOTFS_DIR" \
http://deb.debian.org/debian/
for dir in dev dev/pts proc sys; do
mount --bind "/$dir" "$ROOTFS_DIR/$dir"
done
echo "[CHROOT] Configuring Debian system..."
chroot "$ROOTFS_DIR" /bin/bash <<'EOF'
echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/10-assume_yes
apt-get update
apt-get upgrade
apt-get install --no-install-recommends software-properties-common bash wget curl nano locales
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen
locale-gen
update-locale LANG=en_US.UTF-8
apt-get remove --purge --allow-remove-essential pinentry-curses whiptail kmod iptables iproute2 dmidecode || true
apt-get clean
find /var/lib/apt/lists/ -type f -delete
EOF
echo "[INFO] Unmounting system directories (ignore errors)..."
for dir in sys proc dev/pts dev; do
umount -lf "$ROOTFS_DIR/$dir" 2>/dev/null || true
done
echo "[INFO] Rootfs size:"
du -sh "$ROOTFS_DIR"
echo "[INFO] Creating compressed base image..."
mkdir -p "$OUTPUT_DIR/$DEBIAN_RELEASE"
tar -cjf "$TARBALL" -C "$ROOTFS_DIR" .
ls -lh "$TARBALL"
du -sh "$TARBALL"
echo "[INFO] Tarball ready: $TARBALL"