Skip to content

build: sid

build: sid #24

Workflow file for this run

name: DEV virtual machine
# auto-task.start-build-time = ?
env:
# DEBIAN_FRONTEND: noninteractive
# DEB_ENV: "DEBIAN_FRONTEND=noninteractive"
DEV_DIR: assets/vm-dev
VM_MIN_DIR: assets/vm-minimal
VM_SHUTDOWN: "ssh -F ssh/vm.sshconf vm poweroff ||:"
SSH_VM: "ssh -F ssh/vm.sshconf vm"
new_task: "tmux new-session -d"
#
# SID:
# RELEASE_TAG: unstable
# CODENAME: sid
# ROOTFS_REPO: "debian-sid:"
#
# BOOKWORM:
RELEASE_TAG: 12
CODENAME: "bookworm"
ROOTFS_REPO: "debian:bookworm-"
on:
# schedule:
# - cron: "0 11 28 */2 *"
push:
paths:
- .github/workflows/vm-dev.yml
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- arch: arm64
deb_arch: arm64
qemu_pkg_arch: arm
tty: ttyAMA0
net: enp0s1
- arch: x64
deb_arch: amd64
qemu_pkg_arch: x86
tty: ttyS0
net: enp0s2
runs-on: ubuntu-latest
env:
# non_x86: ${{ !contains(fromJSON('["x64", "x86"]'), matrix.arch) }}
enable_efi: ${{ contains(fromJSON('["arm64", "loong64", "rv64gc"]'), matrix.arch) }}
defaults:
run:
shell: zsh --pipefail -fex {0}
steps:
- name: install zsh
if: runner.arch == 'X64'
shell: sh -e {0}
run: ${{ vars.INSTALL_ZSH }}
- uses: actions/checkout@v4
- name: download qemu image
env:
url: "https://github.com/2cd/debian-museum/releases/download/${{env.RELEASE_TAG}}/vm-minimal_${{env.CODENAME}}_${{matrix.arch}}.tar.zst"
run: |
sudo cp -pv ${VM_MIN_DIR}/scripts/* /usr/local/bin
apt-install aria2
apt-install qemu-system-${{matrix.qemu_pkg_arch}} &
task=$!
aria2c -s5 -x5 -k1m --no-conf -o min.tzst "$url"
tar -xf min.tzst
mv -vf Readme.md Readme.minimal-vm.md ||:
cp -vf ${{env.DEV_DIR}}/* . ||:
unlink min.tzst
sed -E 's@(Port).*[0-9]$@\1 9023@' -i ssh/vm.sshconf
sed -E 's@^(integer\s+ssh_port)=.*@\1=9023@' -i run
cat ssh/vm.sshconf
wait $task
- name: create EFI BOOT disk
if: fromJson(env.enable_efi)
env:
disk: boot/FAT32-EFI.img
run: |
qemu-img create -f raw $disk 128M
print -R ',,U' | sudo sfdisk --label gpt $disk
sed -E 's@^(\s{2,})(disk.img)$@\1\2\n\1boot/FAT32-EFI.img@' -i run
loop_dev=$(sudo losetup -f)
sudo losetup $loop_dev $disk
sudo losetup --all
sudo kpartx -va $loop_dev
p1=/dev/mapper/${loop_dev:t}p1
sudo mkfs.vfat -F32 -n BOOT $p1
sudo kpartx -dv $loop_dev ||:
sudo losetup --detach $loop_dev ||:
cat run
- name: run vm
timeout-minutes: 5
run: |
qemu-img resize disk.img +2G
sudo chmod 666 -v /dev/kvm
${{env.new_task}} ./run
sleep 2
while {! ${{env.SSH_VM}} exit} {
sleep 1
}
- name: install kernel
uses: 2moe/local-ssh-action@v0
with:
host: vm
args: |
-F
ssh/vm.sshconf
run: |
cmt="# "
if { ${{env.enable_efi}} } {
cmt=""
}
>> /etc/fstab <<FSTAB
LABEL=rootfs / ext4 defaults,rw,noatime 0 1
${cmt}LABEL=BOOT /boot/efi vfat umask=0077 0 1
tmpfs /tmp tmpfs defaults,nofail 0 0
FSTAB
lsblk -f
apt-install
case ${{matrix.arch}} {
(arm64|x64) kernel=cloud-${{matrix.deb_arch}} ;;
(*) kernel=${{matrix.deb_arch}} ;;
}
apt-install linux-image-${kernel}
- name: reboot vm
if: fromJson(env.enable_efi)
timeout-minutes: 5
run: |
${{env.SSH_VM}} reboot
cat run | head -n10
sleep 7
while {! ${{env.SSH_VM}} exit} {
sleep 1
}
- name: install grub
uses: 2moe/local-ssh-action@v0
with:
host: vm
args: |
-F
ssh/vm.sshconf
run: |
lsblk -f
df -Th
if {! ${{env.enable_efi}} } {
apt-install grub2
grub-install /dev/vda
}
if { ${{env.enable_efi}} } {
apt-install grub-efi
grub-install
}
>> /etc/default/grub <<"APPEND_GRUB_CFG"
GRUB_TIMEOUT=1
GRUB_TERMINAL="console serial"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="console=tty0 console=${{matrix.tty}}"
GRUB_SERIAL_COMMAND="serial --speed=4000000"
APPEND_GRUB_CFG
update-grub
sed -E 's@^(Port)\s.*@\1 9023@' -i /etc/ssh/sshd_config.d/vm.conf
- name: change the config
timeout-minutes: 7
run: |
${{env.VM_SHUTDOWN}}
while {lsof disk.img} {
sleep 1
}
sed_args=(
-E
-e '/debian-vm-minimal/ s@(name)=.*@\1=debian-vm-dev@'
-e 's@^(external_kernel)=.*@\1=false@'
-e 's@^(integer\s+guest_ssh_port)=.*@\1=9023@'
-i run
)
sed $sed_args
${{env.new_task}} ./run
cat run
sleep 6
while {! ${{env.SSH_VM}} exit} {
sleep 1
}
- name: install docker & qemu-user
uses: 2moe/local-ssh-action@v0
with:
host: vm
args: |
-F
ssh/vm.sshconf
run: |
df -Th
apt-install docker.io
apt-install systemd-container tmux ||:
apt-install -t experimental qemu-user-static
systemctl disable systemd-networkd-wait-online.service
apt-get autopurge -y
apt-get clean
journalctl --rotate ||:
journalctl --vacuum-time=1s ||:
df -Th
ls -lh /var/cache/apt
rm -vf /var/lib/apt/lists/*.* ||:
dd if=/dev/zero of=/root/zero bs=1M || {
rm -vf /root/zero
}
- name: pack vm
run: |
${{env.VM_SHUTDOWN}}
apt-install b3sum
while {lsof disk.img} {
sleep 1
}
qemu-img convert -O qcow2 disk.img disk.qcow2
ls -lh disk.img disk.qcow2
unlink disk.img
sed_args=(
-E
-e 's@^(\s{2,})disk\.img$@\1disk.qcow2@'
-i run
)
sed $sed_args
unlink blake3.txt ||:
rm -fv boot/initrd.* ||:
rm -fv boot/System.map-* ||:
rm -fv boot/vmlinu* ||:
files=(
disk.qcow2
run
Readme.*
connect-to-ssh
get-file-from-vm
send-file-to-vm
)
for f ($files boot/* ssh/*) {
b3sum $f >> blake3.txt ||:
}
for f (boot ssh blake3.txt) {
files+=$f
}
args=(
--posix
--use-compress-program='zstdmt --long -18v'
-cf vm-dev_${{env.CODENAME}}_${{matrix.arch}}.tar.zst
$files
)
tar $args
- name: release
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
tag_name: unstable
files: |
*.tar.zst