From 39cc904c0f2bf0e3aee3742358126cd754f15587 Mon Sep 17 00:00:00 2001 From: fithwum Date: Sat, 20 Dec 2025 11:20:30 -0800 Subject: [PATCH] test --- .gitea/workflows/base-build.yml | 292 +++++++++++++------------- base-image-script/bootstrap-rootfs.sh | 2 +- 2 files changed, 147 insertions(+), 147 deletions(-) diff --git a/.gitea/workflows/base-build.yml b/.gitea/workflows/base-build.yml index c227583..43a4be4 100644 --- a/.gitea/workflows/base-build.yml +++ b/.gitea/workflows/base-build.yml @@ -27,172 +27,172 @@ env: OUTPUT_DIR: ./output jobs: - build-and-push-rootfs-archives: - runs-on: vm-docker-build2 - outputs: - archives_changed: ${{ steps.commit_archives.outputs.archives_changed }} - steps: - - name: Checkout source - uses: actions/checkout@v3 - - - name: Create output directory - run: mkdir -p ./output - - - name: Build all Debian rootfs versions into volumes and extract - run: | - versions=($VERSIONS) - for version in "${versions[@]}"; do - echo "[INFO] Building $version..." - volume_name="build_output_$version" - docker volume create "$volume_name" - - docker build --build-arg VERSION=$version -t fithwum/debian-$version-base . - - docker run --rm --privileged \ - -v "$volume_name:/output" \ - -e VERSION="$version" \ - fithwum/debian-$version-base \ - bash -c "/scripts/bootstrap-rootfs.sh \"$version\"" - - # Extract the output file from the volume - container_id=$(docker create -v "$volume_name:/output" debian) - mkdir -p ./output/$version - docker cp "$container_id:/output/$version/debian-$version.tar.bz2" ./output/$version/ - docker rm "$container_id" - done - - - name: Validate that archives exist for each version - run: | - IFS=' ' read -r -a versions <<< "$VERSIONS" - for version in "${versions[@]}"; do - path="./output/$version/debian-$version.tar.bz2" - if [[ ! -f "$path" ]]; then - echo "[ERROR] Missing archive: $path" - exit 1 - else - echo "[OK] Found: $path" - fi - done - - - name: Clone upload repo - run: | - GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}" - git clone --depth=1 "https://${{ env.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/debian-base.git" upload-repo - - - name: Clean old archives in upload-repo - run: rm -rfv upload-repo/*/*.tar.bz2 - - - name: Copy new archives to upload-repo - run: | - for filepath in ./output/*/debian-*.tar.bz2; do - version_dir=$(basename "$(dirname "$filepath")") - mkdir -p "upload-repo/$version_dir" - cp "$filepath" "upload-repo/$version_dir/" - done - - - name: Calculate and store sha256sums in upload-repo - run: | - cd upload-repo - rm -f sha256sums.txt - for tarball in */debian-*.tar.bz2; do - echo "[INFO] Processing: $tarball" - checksum=$(sha256sum "$tarball" | awk '{print $1}') - echo "$checksum $tarball" >> sha256sums.txt - done - echo "[INFO] SHA256 contents:" - cat sha256sums.txt - - - name: Commit and push files if changed - id: commit_archives - run: | - cd upload-repo - git config --global user.name "${{ env.GIT_USERNAME }}" - git config --global user.email "${{ env.GIT_EMAIL }}" - - if git status --porcelain | grep .; then - git add **/*.tar.bz2 sha256sums.txt || true - git commit -m "Update base images and checksum on $(date -u +'%Y-%m-%dT%H:%M:%SZ') [skip ci]" - git push - echo "archives_changed=true" >> $GITHUB_OUTPUT - else - echo "[INFO] No changes to commit." - echo "archives_changed=false" >> $GITHUB_OUTPUT - fi - - # build-rootfs: - # name: Build rootfs (${{ matrix.version }}) + # build-and-push-rootfs-archives: # runs-on: vm-docker-build2 - - # strategy: - # fail-fast: false - # matrix: - # version: [bullseye, bookworm, trixie] - + # outputs: + # archives_changed: ${{ steps.commit_archives.outputs.archives_changed }} # steps: - # - uses: actions/checkout@v3 + # - name: Checkout source + # uses: actions/checkout@v3 # - name: Create output directory - # run: mkdir -p ${{ env.OUTPUT_DIR }}/${{ matrix.version }} + # run: mkdir -p ./output - # - name: Build rootfs Docker image + # - name: Build all Debian rootfs versions into volumes and extract # run: | - # VERSION=${{ matrix.version }} - # docker build \ - # --build-arg VERSION="$VERSION" \ - # -t rootfs-$VERSION . + # versions=($VERSIONS) + # for version in "${versions[@]}"; do + # echo "[INFO] Building $version..." + # volume_name="build_output_$version" + # docker volume create "$volume_name" - # - name: Run rootfs bootstrap + # docker build --build-arg VERSION=$version -t fithwum/debian-$version-base . + + # docker run --rm --privileged \ + # -v "$volume_name:/output" \ + # -e VERSION="$version" \ + # fithwum/debian-$version-base \ + # bash -c "/scripts/bootstrap-rootfs.sh \"$version\"" + + # # Extract the output file from the volume + # container_id=$(docker create -v "$volume_name:/output" debian) + # mkdir -p ./output/$version + # docker cp "$container_id:/output/$version/debian-$version.tar.bz2" ./output/$version/ + # docker rm "$container_id" + # done + + # - name: Validate that archives exist for each version # run: | - # VERSION=${{ matrix.version }} - # OUTPUT_DIR=${{ env.OUTPUT_DIR }}/$VERSION - - # docker run --rm \ - # -v "$PWD/$OUTPUT_DIR:/output" \ - # rootfs-$VERSION \ - # bash -c "/scripts/bootstrap-rootfs.sh $VERSION /output" - - # # Verify tarball exists - # TAR="$OUTPUT_DIR/debian-$VERSION.tar.bz2" - # if [[ ! -f "$TAR" ]]; then - # echo "[ERROR] Rootfs tarball missing: $TAR" - # exit 1 - # else - # echo "[OK] Created $TAR" - # fi + # IFS=' ' read -r -a versions <<< "$VERSIONS" + # for version in "${versions[@]}"; do + # path="./output/$version/debian-$version.tar.bz2" + # if [[ ! -f "$path" ]]; then + # echo "[ERROR] Missing archive: $path" + # exit 1 + # else + # echo "[OK] Found: $path" + # fi + # done # - name: Clone upload repo # run: | - # git clone --depth=1 \ - # https://${GIT_USERNAME}:${GIT_TOKEN}@gitea.fithwum.tech/fithwum/debian-base.git upload + # GIT_CREDENTIAL="${{ secrets.GIT_TOKEN || secrets.GIT_PASSWORD }}" + # git clone --depth=1 "https://${{ env.GIT_USERNAME }}:${GIT_CREDENTIAL}@gitea.fithwum.tech/fithwum/debian-base.git" upload-repo - # - name: Update archive + sha256 + # - name: Clean old archives in upload-repo + # run: rm -rfv upload-repo/*/*.tar.bz2 + + # - name: Copy new archives to upload-repo # run: | - # VERSION=${{ matrix.version }} - # OUTPUT_DIR=${{ env.OUTPUT_DIR }}/$VERSION + # for filepath in ./output/*/debian-*.tar.bz2; do + # version_dir=$(basename "$(dirname "$filepath")") + # mkdir -p "upload-repo/$version_dir" + # cp "$filepath" "upload-repo/$version_dir/" + # done - # mkdir -p upload/$VERSION - # cp "$OUTPUT_DIR/debian-$VERSION.tar.bz2" upload/$VERSION/ - - # cd upload - # # Remove old checksum for this version - # sed -i "/debian-$VERSION.tar.bz2/d" sha256sums.txt 2>/dev/null || true - # # Add new checksum - # sha256sum "$VERSION/debian-$VERSION.tar.bz2" >> sha256sums.txt - - # - name: Commit if changed + # - name: Calculate and store sha256sums in upload-repo # run: | - # VERSION=${{ matrix.version }} + # cd upload-repo + # rm -f sha256sums.txt + # for tarball in */debian-*.tar.bz2; do + # echo "[INFO] Processing: $tarball" + # checksum=$(sha256sum "$tarball" | awk '{print $1}') + # echo "$checksum $tarball" >> sha256sums.txt + # done + # echo "[INFO] SHA256 contents:" + # cat sha256sums.txt - # cd upload - # git config user.name "$GIT_USERNAME" - # git config user.email "$GIT_EMAIL" + # - name: Commit and push files if changed + # id: commit_archives + # run: | + # cd upload-repo + # git config --global user.name "${{ env.GIT_USERNAME }}" + # git config --global user.email "${{ env.GIT_EMAIL }}" # if git status --porcelain | grep .; then - # git add "$VERSION/debian-$VERSION.tar.bz2" sha256sums.txt - # git commit -m "Update rootfs for $VERSION [skip ci]" + # git add **/*.tar.bz2 sha256sums.txt || true + # git commit -m "Update base images and checksum on $(date -u +'%Y-%m-%dT%H:%M:%SZ') [skip ci]" # git push + # echo "archives_changed=true" >> $GITHUB_OUTPUT # else - # echo "[INFO] No changes for $VERSION" + # echo "[INFO] No changes to commit." + # echo "archives_changed=false" >> $GITHUB_OUTPUT + # fi + + build-rootfs: + name: Build rootfs (${{ matrix.version }}) + runs-on: vm-docker-build2 + + strategy: + fail-fast: false + matrix: + version: [bullseye, bookworm, trixie] + + steps: + - uses: actions/checkout@v3 + + - name: Create output directory + run: mkdir -p ${{ env.OUTPUT_DIR }}/${{ matrix.version }} + + - name: Build rootfs Docker image + run: | + VERSION=${{ matrix.version }} + docker build \ + --build-arg VERSION="$VERSION" \ + -t rootfs-$VERSION . + + - name: Run rootfs bootstrap + run: | + VERSION=${{ matrix.version }} + OUTPUT_DIR=${{ env.OUTPUT_DIR }}/$VERSION + + docker run --rm \ + -v "$PWD/$OUTPUT_DIR:/output" \ + rootfs-$VERSION \ + bash -c "/scripts/bootstrap-rootfs.sh $VERSION /output" + + # Verify tarball exists + TAR="$OUTPUT_DIR/debian-$VERSION.tar.bz2" + if [[ ! -f "$TAR" ]]; then + echo "[ERROR] Rootfs tarball missing: $TAR" + exit 1 + else + echo "[OK] Created $TAR" + fi + + - name: Clone upload repo + run: | + git clone --depth=1 \ + https://${GIT_USERNAME}:${GIT_TOKEN}@gitea.fithwum.tech/fithwum/debian-base.git upload + + - name: Update archive + sha256 + run: | + VERSION=${{ matrix.version }} + OUTPUT_DIR=${{ env.OUTPUT_DIR }}/$VERSION + + mkdir -p upload/$VERSION + cp "$OUTPUT_DIR/debian-$VERSION.tar.bz2" upload/$VERSION/ + + cd upload + # Remove old checksum for this version + sed -i "/debian-$VERSION.tar.bz2/d" sha256sums.txt 2>/dev/null || true + # Add new checksum + sha256sum "$VERSION/debian-$VERSION.tar.bz2" >> sha256sums.txt + + - name: Commit if changed + run: | + VERSION=${{ matrix.version }} + + cd upload + git config user.name "$GIT_USERNAME" + git config user.email "$GIT_EMAIL" + + if git status --porcelain | grep .; then + git add "$VERSION/debian-$VERSION.tar.bz2" sha256sums.txt + git commit -m "Update rootfs for $VERSION [skip ci]" + git push + else + echo "[INFO] No changes for $VERSION" # build-and-push-docker-images: # needs: build-and-push-rootfs-archives diff --git a/base-image-script/bootstrap-rootfs.sh b/base-image-script/bootstrap-rootfs.sh index 0742d2e..623589c 100644 --- a/base-image-script/bootstrap-rootfs.sh +++ b/base-image-script/bootstrap-rootfs.sh @@ -11,7 +11,7 @@ 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,software-properties-common,bash,wget,curl,nano,locales --arch=amd64 "$DEBIAN_RELEASE" "$ROOTFS_DIR" \ + --include=apt,ca-certificates,software-properties-common,bash,wget,curl,nano,locales,python3,python3-pip,libffi-dev --arch=amd64 "$DEBIAN_RELEASE" "$ROOTFS_DIR" \ http://deb.debian.org/debian/ for dir in dev dev/pts proc sys; do