1
0

feat(qemu images): generate all ubuntu images

This commit is contained in:
dump_stack() 2024-10-17 17:55:23 +00:00
parent 48854bf40d
commit 2daa111196
Signed by: dump_stack
GPG Key ID: C9905BA72B5E02BB
4 changed files with 11 additions and 63 deletions

View File

@ -14,6 +14,7 @@ on:
- ".github/workflows/macos.yml" - ".github/workflows/macos.yml"
- ".github/workflows/debian-cache.yml" - ".github/workflows/debian-cache.yml"
- "docs/**" - "docs/**"
- 'tools/**'
- ".readthedocs.yaml" - ".readthedocs.yaml"
- "README.md" - "README.md"

View File

@ -1,35 +0,0 @@
# Copyright 2018 Mikhail Klementev. All rights reserved.
# Use of this source code is governed by a AGPLv3 license
# (or later) that can be found in the LICENSE file.
#
# Usage:
#
# $ docker build -t gen-ubuntu1404-image .
# $ docker run --privileged -v $(pwd):/shared -t gen-ubuntu1404-image
#
# ubuntu1404.img will be created in current directory. You can change $(pwd) to
# different directory to use different destination for image.
#
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y debootstrap qemu
ENV TMPDIR=/tmp/ubuntu
ENV IMAGEDIR=/tmp/image
ENV IMAGE=/shared/out_of_tree_ubuntu_14__04.img
ENV REPOSITORY=http://archive.ubuntu.com/ubuntu
ENV RELEASE=trusty
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

@ -1,19 +0,0 @@
#!/bin/sh -eux
# Copyright 2018 Mikhail Klementev. All rights reserved.
# Use of this source code is governed by a AGPLv3 license
# (or later) that can be found in the LICENSE file.
TMPDIR=$1
chroot $TMPDIR /bin/sh -c 'useradd -m user'
sed -i 's/root:\*:/root::/' $TMPDIR/etc/shadow
sed -i 's/user:!!:/user::/' $TMPDIR/etc/shadow
echo auth sufficient pam_permit.so > $TMPDIR/etc/pam.d/sshd
sed -i '/PermitEmptyPasswords/d' $TMPDIR/etc/ssh/sshd_config
echo PermitEmptyPasswords yes >> $TMPDIR/etc/ssh/sshd_config
sed -i '/PermitRootLogin/d' $TMPDIR/etc/ssh/sshd_config
echo PermitRootLogin yes >> $TMPDIR/etc/ssh/sshd_config
sed -i '/UseDNS/d' $TMPDIR/etc/ssh/sshd_config
echo UseDNS no >> $TMPDIR/etc/ssh/sshd_config
echo '#!/bin/sh' > $TMPDIR/etc/rc.local
echo 'dhclient eth0' >> $TMPDIR/etc/rc.local
chmod +x $TMPDIR/etc/rc.local

View File

@ -7,13 +7,13 @@ script_dir = os.path.dirname(os.path.realpath(__file__))
os.chdir(script_dir) os.chdir(script_dir)
releases = [ releases = [
# ('12.04', 'precies'), ('12.04', 'precise', 'http://old-releases.ubuntu.com/ubuntu'),
# ('14.04', 'trusty'), ('14.04', 'trusty', 'http://archive.ubuntu.com/ubuntu'),
# ('16.04', 'xenial'), ('16.04', 'xenial', 'http://archive.ubuntu.com/ubuntu'),
# ('18.04', 'bionic'), ('18.04', 'bionic', 'http://archive.ubuntu.com/ubuntu'),
# ('20.04', 'focal'), ('20.04', 'focal', 'http://archive.ubuntu.com/ubuntu'),
# ('22.04', 'jammy'), ('22.04', 'jammy', 'http://archive.ubuntu.com/ubuntu'),
('24.04', 'noble'), ('24.04', 'noble', 'http://archive.ubuntu.com/ubuntu')
] ]
template = ''' template = '''
@ -27,7 +27,7 @@ RUN apt install -y linux-image-generic
ENV TMPDIR=/tmp/ubuntu ENV TMPDIR=/tmp/ubuntu
ENV IMAGEDIR=/tmp/image ENV IMAGEDIR=/tmp/image
ENV IMAGE=/shared/out_of_tree_ubuntu_{img_version}.img ENV IMAGE=/shared/out_of_tree_ubuntu_{img_version}.img
ENV REPOSITORY=http://archive.ubuntu.com/ubuntu ENV REPOSITORY={repository}
ENV RELEASE={codename} ENV RELEASE={codename}
RUN mkdir $IMAGEDIR RUN mkdir $IMAGEDIR
@ -47,7 +47,7 @@ def run_cmd(cmd):
print(f"+ {cmd}") print(f"+ {cmd}")
subprocess.run(cmd, shell=True, check=True, executable='/bin/bash') subprocess.run(cmd, shell=True, check=True, executable='/bin/bash')
for version, codename in releases: for version, codename, repository in releases:
numeric_version = version.replace('.', '') numeric_version = version.replace('.', '')
img_version=version.replace(".","__") img_version=version.replace(".","__")
@ -55,6 +55,7 @@ for version, codename in releases:
version=version, version=version,
img_version=img_version, img_version=img_version,
codename=codename, codename=codename,
repository=repository,
numeric_version=numeric_version) numeric_version=numeric_version)
os.makedirs(str(version), exist_ok=True) os.makedirs(str(version), exist_ok=True)