1
0

Add generator for debian images

This commit is contained in:
dump_stack() 2023-05-12 00:59:36 +00:00
parent 183b4698dd
commit 2910ce17c7
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
4 changed files with 97 additions and 0 deletions

20
.github/workflows/images.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: Generate Images
on:
workflow_dispatch:
jobs:
debian-images:
name: Debian Images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: debootstrap
run: ./tools/qemu-debian-img/generate-images.sh
- name: Archive images
uses: actions/upload-artifact@v3
with:
name: debian-images
path: /home/runner/work/out-of-tree/out-of-tree/tools/qemu-debian-img/*.tar.gz

4
tools/qemu-debian-img/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*
!.gitignore
!Dockerfile.template
!generate-images.sh

View File

@ -0,0 +1,29 @@
FROM debian:_VERSION_
ENV DEBIAN_FRONTEND=noninteractive
RUN echo 'deb [check-valid-until=no trusted=yes] _REPOSITORY_ _RELEASE_ main contrib' > /etc/apt/sources.list
RUN echo 'deb [check-valid-until=no trusted=yes] _REPOSITORY_ _RELEASE_-updates main contrib' >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get remove -y iputils-ping
RUN apt-get autoremove -y
RUN apt-get install -y debootstrap qemu-utils
ENV TMPDIR=/tmp/debian
ENV IMAGEDIR=/tmp/image
ENV IMAGE=/shared/out_of_tree_debian__VERSION_.img
ENV REPOSITORY=_REPOSITORY_
ENV RELEASE=_RELEASE_
RUN mkdir $IMAGEDIR
# Must be executed with --privileged because of /dev/loop
CMD debootstrap --include=openssh-server,policykit-1 \
$RELEASE $TMPDIR $REPOSITORY && \
/shared/setup.sh $TMPDIR && \
qemu-img create $IMAGE 2G && \
mkfs.ext4 -F $IMAGE && \
mount -o loop $IMAGE $IMAGEDIR && \
cp -a $TMPDIR/* $IMAGEDIR/ && \
umount $IMAGEDIR

View File

@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -eux
cd $(dirname $(realpath $0))
for version in 7 8 9 10 11; do
if [[ $version -eq 7 ]]; then
release=wheezy
last_version=7.11.0
fi
if [[ $version -eq 8 ]]; then
release=jessie
last_version=8.11.1
fi
if [[ $version -eq 9 ]]; then
release=stretch
last_version=9.13.0
fi
if [[ $version -eq 10 ]]; then
release=buster
last_version=10.13.0
fi
if [[ $version -eq 11 ]]; then
release=bullseye
last_version=11.6.0
fi
mkdir $version
sed "s/_VERSION_/${version}/" Dockerfile.template >> $version/Dockerfile
sed -i "s/_RELEASE_/${release}/" $version/Dockerfile
repository=$(wget -q -O - https://cdimage.debian.org/mirror/cdimage/archive/${last_version}/amd64/jigdo-bd/debian-${last_version}-amd64-BD-1.jigdo | gunzip | awk -F= '/snapshot.debian.org/ {print $2}' | cut -d ' ' -f 1)
sed -i "s;_REPOSITORY_;${repository};" $version/Dockerfile
docker build -t gen-debian${version}-image $version
rm -rf $version
docker run --privileged -v $(pwd):/shared -t gen-debian${version}-image
tar -Szcf out_of_tree_debian_${version}.img.tar.gz out_of_tree_debian_${version}.img
done