Files
debian-base/base-image-script/debian-build_pt3.sh
fithwum a1db1d32b5
Some checks failed
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-rootfs-archives (push) Failing after 1m48s
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / push-archives-to-repo (push) Has been skipped
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / build-and-push-docker-images (push) Has been skipped
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-changelogs (push) Has been skipped
Build, Upload RootFS, and Push Docker Images, update changelog, update build info. / generate-build-info (push) Has been skipped
test
2025-07-07 08:04:33 -07:00

100 lines
2.2 KiB
Bash

#!/bin/bash
# Copyright (c) 2025 fithwum
# All rights reserved
set -e
# Auto-detect a single debian-* directory if not passed
if [ -n "$1" ]; then
ROOTFS_DIR="$1"
else
ROOTFS_DIR=$(find . -maxdepth 1 -type d -name "debian-*" | sed 's|^\./||' | head -n 1)
if [ -z "$ROOTFS_DIR" ]; then
echo "[ERROR] No debian-* rootfs directory found!"
exit 1
fi
fi
VERSION_NAME="${ROOTFS_DIR#debian-}"
TARBALL_NAME="rootfs-${VERSION_NAME}.tar.bz2"
TARBALL_PATH="/output/${VERSION_NAME}/${TARBALL_NAME}"
CHECKSUM_PATH="/output/${VERSION_NAME}/sha256sums.txt"
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] Removing chroot script..."
rm -f "$ROOTFS_DIR/root/"*.sh 2>/dev/null || true
echo "[INFO] Rootfs size:"
du -sh "$ROOTFS_DIR"
echo "[INFO] Creating compressed base image..."
mkdir -p "$(dirname "$TARBALL_PATH")"
tar -cjf "$TARBALL_PATH" -C "$ROOTFS_DIR" .
echo "[INFO] Image archive size:"
du -sh "$TARBALL_PATH"
echo "[INFO] Calculating SHA256 checksum..."
sha256sum "$TARBALL_PATH" > "$CHECKSUM_PATH"
echo "[INFO] Tarball ready at: $TARBALL_PATH"
echo "[INFO] Checksum written to: $CHECKSUM_PATH"
# #!/bin/bash
# # Copyright (c) 2025 fithwum
# # All rights reserved
# set -e
# # Auto-detect a single debian-* directory if not passed
# if [ -n "$1" ]; then
# ROOTFS_DIR="$1"
# else
# ROOTFS_DIR=$(find . -maxdepth 1 -type d -name "debian-*" | sed 's|^\./||' | head -n 1)
# if [ -z "$ROOTFS_DIR" ]; then
# echo "[ERROR] No debian-* rootfs directory found!"
# exit 1
# fi
# fi
# TARBALL="/output/${ROOTFS_DIR}.tar.bz2"
# 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] Removing chroot script..."
# rm -f "$ROOTFS_DIR/root/${ROOTFS_DIR}_pt2.sh" 2>/dev/null || true
# echo "[INFO] Rootfs size:"
# du -sh "$ROOTFS_DIR"
# echo "[INFO] Creating compressed base image..."
# tar -cjf "$TARBALL" -C "$ROOTFS_DIR" .
# echo "[INFO] Image archive size:"
# du -sh "$TARBALL"
# echo "[INFO] Tarball ready for CI to upload: $TARBALL"