You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mmdebstrap/examples/mmdebstrap-autopkgtest-qemu

68 lines
2.8 KiB
Bash

#!/bin/sh
#
# © 2022 Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# The software is provided "as is", without warranty of any kind, express or
# implied, including but not limited to the warranties of merchantability,
# fitness for a particular purpose and noninfringement. In no event shall the
# authors or copyright holders be liable for any claim, damages or other
# liability, whether in an action of contract, tort or otherwise, arising
# from, out of or in connection with the software or the use or other dealings
# in the software.
set -eu
# This script creates debian-unstable.qcow2 in the current directory which can
# then be used by the autopkgtest qemu backend.
#
# Thanks to Francesco Poli for providing ideas and testing this.
nativearch="$(dpkg --print-architecture)"
case "$nativearch" in
amd64) include="linux-image-amd64 grub-pc" ;;
arm64) include="linux-image-arm64 grub-efi" ;;
armhf) include="linux-image-armmp-lpae grub-efi" ;;
i386) include="linux-image-686-pae grub-pc" ;;
ppc64el) include="linux-image-powerpc64le grub-ieee1275" ;;
*)
echo "architecture $nativearch not yet supported" >&2
exit 1
;;
esac
case "$nativearch" in
amd64|i386) ;;
*) echo "warning: architectures other than amd64 and i386 are untested" >&2 ;;
esac
mmdebstrap --variant=important --include="$include" \
--customize-hook='chroot "$1" passwd --delete root' \
--customize-hook='chroot "$1" useradd --home-dir /home/user --create-home user' \
--customize-hook='chroot "$1" passwd --delete user' \
--customize-hook='echo host > "$1/etc/hostname"' \
--customize-hook='echo "127.0.0.1 localhost host" > "$1/etc/hosts"' \
--customize-hook=/usr/share/autopkgtest/setup-commands/setup-testbed \
unstable - | \
guestfish -- \
disk-create debian-unstable.qcow2 qcow2 8G : \
add-drive debian-unstable.qcow2 format:qcow2 : \
launch : \
part-disk /dev/sda mbr : \
part-set-bootable /dev/sda 1 true : \
mkfs ext4 /dev/sda1 : mount /dev/sda1 / : \
tar-in - / xattrs:true : \
command "sh -c 'echo UUID=\$(blkid -c /dev/null -o value -s UUID /dev/sda1) / ext4 errors=remount-ro 0 1 > /etc/fstab'" : \
command "update-initramfs -u" : \
command "grub-install /dev/sda" : \
command update-grub : \
sync : umount / : shutdown