Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/build-deb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,83 @@ jobs:

echo "All verification checks passed!"

# Ubuntu e2e convert/boot coverage for the DEB packages: run
# tests/test-convert.sh against the prepared noble test image (dracut
# pre-installed) with the freshly built cryptpilot-fde-guest deb, in both
# bootloader modes. grub exercises the DEB install path and grubenv
# creation; uki additionally exercises the small-ESP growth.
test-convert:
runs-on: ubuntu-latest
needs: [build, test]
strategy:
fail-fast: false
matrix:
bootloader: [grub, uki]
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: 'true'

- name: Load NBD kernel module
run: |
sudo modprobe nbd max_part=16
lsmod | grep nbd

# Minimal tool set for the test harness itself (wget, qemu-nbd,
# cryptsetup, lvm, mkfs.ext4, sgdisk) plus dosfstools for the UKI ESP
# re-creation. cryptpilot-convert installs anything else it needs.
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
wget \
qemu-utils \
cryptsetup-bin \
lvm2 \
e2fsprogs \
gdisk \
parted \
dosfstools

- name: Pull Ubuntu test image
run: |
docker pull ghcr.io/${{ github.repository_owner }}/cryptpilot-fde-test-image:noble-dracut-20260518

- name: Extract qcow2 from container
run: |
TEST_IMAGE="ghcr.io/${{ github.repository_owner }}/cryptpilot-fde-test-image:noble-dracut-20260518"
docker create --name temp-extract "$TEST_IMAGE" /bin/true
docker cp temp-extract:/image.qcow2 ./test-image.qcow2
docker rm temp-extract
docker rmi "$TEST_IMAGE"
ls -lh ./test-image.qcow2

- name: Download DEB packages
uses: actions/download-artifact@v8
with:
name: deb-packages-x86_64
path: ./deb-packages/

- name: Run conversion test
run: |
GUEST_DEB=$(ls ./deb-packages/cryptpilot-fde-guest_*.deb | head -1)
sudo ./tests/test-convert.sh \
--distro ubuntu \
--package "$GUEST_DEB" \
--bootloader ${{ matrix.bootloader }} \
--rootfs-enc \
--delta-location ram \
--input "${{ github.workspace }}/test-image.qcow2"

- name: Print convert diagnostic log
if: always()
run: |
sudo cat /tmp/.cryptpilot-convert.log 2>/dev/null || echo "(log file not available)"

release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
Expand Down
142 changes: 138 additions & 4 deletions .github/workflows/build-test-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ name: Build Test Image
on:
workflow_dispatch:
inputs:
url:
description: 'URL of the qcow2 image to download'
distro:
description: 'Distribution type: "direct" for a ready qcow2 image, "ubuntu" for a Noble cloud image that gets dracut pre-installed'
required: true
type: choice
default: direct
options:
- direct
- ubuntu
url:
description: 'URL of the qcow2 image to download (only used when distro is "direct")'
required: false
type: string
tag:
description: 'Tag for the resulting image (e.g., alinux3-20251030)'
description: 'Tag for the resulting image (e.g., alinux3-20251030, noble-dracut-20260518)'
required: true
type: string

Expand Down Expand Up @@ -38,13 +46,138 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# --- Direct mode: download a ready qcow2 image from a URL ---
- name: Download qcow2 image
if: inputs.distro == 'direct'
run: |
echo "Downloading image from: ${{ inputs.url }}"
mkdir -p /tmp/qcow2-image
wget -O /tmp/qcow2-image/test-image.qcow2 "${{ inputs.url }}"
ls -lh /tmp/qcow2-image/test-image.qcow2

# --- Ubuntu mode: prepare a Noble cloud image ---
- name: Install dependencies (ubuntu mode)
if: inputs.distro == 'ubuntu'
run: |
sudo apt-get update
sudo apt-get install -y \
qemu-utils \
parted \
util-linux \
kmod \
dosfstools \
e2fsprogs

- name: Download Ubuntu Noble cloud image (ubuntu mode)
if: inputs.distro == 'ubuntu'
run: |
mkdir -p /tmp/qcow2-image
# Pinned daily build so the kernel/dracut versions in the test
# image stay stable across rebuilds.
wget -O /tmp/qcow2-image/test-image.qcow2 \
https://cloud-images.ubuntu.com/noble/20260518/noble-server-cloudimg-amd64.img
ls -lh /tmp/qcow2-image/test-image.qcow2

# Prepare via qemu-nbd + chroot (no libguestfs): set a root password so
# the serial console is usable for debugging, grow the disk so the
# converted layout fits, and pre-install dracut plus the systemd UEFI
# stub needed for UKI builds.
- name: Prepare Ubuntu image (password, resize, GPT fix, install dracut)
if: inputs.distro == 'ubuntu'
run: |
IMAGE=/tmp/qcow2-image/test-image.qcow2
MOUNT_POINT=/tmp/img-mnt

# ---------- Step 1: Set root password ----------
sudo modprobe nbd max_part=16 || true
sudo qemu-nbd --connect=/dev/nbd0 --format=qcow2 "$IMAGE"
sleep 2
sudo partprobe /dev/nbd0 2>/dev/null || true
sleep 1

# Find root partition: look for ext4 partition
sudo mkdir -p $MOUNT_POINT
ROOT_PART=""
for p in /dev/nbd0p1 /dev/nbd0p2 /dev/nbd0p3 /dev/nbd0p4; do
if [ -e "$p" ]; then
FSTYPE=$(sudo blkid -s TYPE -o value "$p" 2>/dev/null || true)
if [ "$FSTYPE" = "ext4" ]; then
ROOT_PART="$p"
break
fi
fi
done
if [ -z "$ROOT_PART" ]; then
echo "ERROR: Cannot find ext4 root partition"
sudo blkid /dev/nbd0p* 2>/dev/null || true
sudo lsblk /dev/nbd0 2>/dev/null || true
exit 1
fi
echo "Root partition: $ROOT_PART"
sudo mount "$ROOT_PART" $MOUNT_POINT
sudo chroot $MOUNT_POINT /bin/bash -c 'echo "root:cryptpilot" | chpasswd'
sudo umount $MOUNT_POINT
sudo qemu-nbd --disconnect /dev/nbd0 >/dev/null 2>&1 || true
sleep 1

# ---------- Step 2: Resize disk ----------
qemu-img resize "$IMAGE" 10G

# ---------- Step 3: Fix GPT partition table ----------
sudo qemu-nbd --connect=/dev/nbd0 --format=qcow2 "$IMAGE"
sleep 2
sudo partprobe /dev/nbd0 2>/dev/null || true
sleep 1
sudo parted /dev/nbd0 print >/dev/null 2>&1 || true
sudo parted /dev/nbd0 resizepart 1 100% -s 2>/dev/null || true
sudo partprobe /dev/nbd0 2>/dev/null || true
sudo lsblk /dev/nbd0
sudo qemu-nbd --disconnect /dev/nbd0 >/dev/null 2>&1 || true
sleep 1

# ---------- Step 4: Install dracut and systemd-boot ----------
sudo modprobe nbd max_part=16 || true
sudo qemu-nbd --connect=/dev/nbd0 --format=qcow2 "$IMAGE"
sleep 2
sudo partprobe /dev/nbd0 2>/dev/null || true
sleep 1

ROOT_PART=""
for p in /dev/nbd0p1 /dev/nbd0p2 /dev/nbd0p3 /dev/nbd0p4; do
if [ -e "$p" ]; then
FSTYPE=$(sudo blkid -s TYPE -o value "$p" 2>/dev/null || true)
if [ "$FSTYPE" = "ext4" ]; then
ROOT_PART="$p"
break
fi
fi
done
if [ -z "$ROOT_PART" ]; then
echo "ERROR: Cannot find ext4 root partition after resize"
exit 1
fi
echo "Root partition (after resize): $ROOT_PART"
sudo mkdir -p $MOUNT_POINT
sudo mount "$ROOT_PART" $MOUNT_POINT

sudo mount --bind /dev $MOUNT_POINT/dev
sudo mount --bind /proc $MOUNT_POINT/proc
sudo mount --bind /sys $MOUNT_POINT/sys
sudo mount --bind /run $MOUNT_POINT/run 2>/dev/null || true

sudo chroot $MOUNT_POINT /bin/bash -c 'DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y dracut dracut-core systemd-boot-efi'

sudo umount $MOUNT_POINT/run 2>/dev/null || true
sudo umount $MOUNT_POINT/sys 2>/dev/null || true
sudo umount $MOUNT_POINT/proc 2>/dev/null || true
sudo umount $MOUNT_POINT/dev 2>/dev/null || true
sudo umount $MOUNT_POINT
sudo qemu-nbd --disconnect /dev/nbd0 >/dev/null 2>&1 || true
sleep 1

echo "Ubuntu image preparation complete!"

# --- Common: build container image ---
- name: Copy Dockerfile
run: |
cp tests/test-image.Dockerfile /tmp/qcow2-image/Dockerfile
Expand All @@ -58,7 +191,8 @@ jobs:
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.description=Test image with qcow2 for cryptpilot-convert integration tests
qcow2.source.url=${{ inputs.url }}
qcow2.source.distro=${{ inputs.distro }}
qcow2.source.url=${{ inputs.url || '' }}

- name: Output image reference
run: |
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ mount /dev/mapper/data0 /mnt/data0
- [Anolis OS 23](https://openanolis.cn/anolisos/23)
- [Alibaba Cloud Linux 3](https://www.aliyun.com/product/alinux)
- [Alibaba Cloud Linux 4](https://www.aliyun.com/product/alinux)
- [Ubuntu 24.04 LTS (Noble)](https://releases.ubuntu.com/noble/)

## Documentation

Expand Down
1 change: 1 addition & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ mount /dev/mapper/data0 /mnt/data0
- [Anolis OS 23](https://openanolis.cn/anolisos/23)
- [Alibaba Cloud Linux 3](https://www.aliyun.com/product/alinux)
- [Alibaba Cloud Linux 4](https://www.aliyun.com/product/alinux)
- [Ubuntu 24.04 LTS (Noble)](https://releases.ubuntu.com/noble/)

## 文档

Expand Down
Loading
Loading