- name: Install
run: |
sudo apt-get update
- sudo apt-get install python3-pytest lvm2 cryptsetup-bin
+ sudo apt-get install python3-pytest lvm2 cryptsetup-bin btrfs-progs
# Make sure the latest changes from the pull request are used.
sudo ln -svf $PWD/bin/mkosi /usr/bin/mkosi
working-directory: ./
+ - name: Btrfs
+ run: |
+ truncate --size=20G btrfs.raw
+ mkfs.btrfs btrfs.raw
+ sudo mkdir -p /mnt/mkosi
+ LOOP="$(sudo losetup --find --show --direct-io=on btrfs.raw)"
+ sudo mount "$LOOP" /mnt/mkosi --options compress=zstd,user_subvol_rm_allowed
+ sudo chown "$(id -u):$(id -g)" /mnt/mkosi
+
- name: Configure
run: |
tee mkosi.local.conf <<EOF
[Output]
ManifestFormat=json
+ UseSubvolumes=yes
+
+ CacheDirectory=/mnt/mkosi/mkosi.cache
+ PackageCacheDirectory=/mnt/mkosi/mkosi.cache
+ WorkspaceDirectory=/mnt/mkosi
[Content]
KernelCommandLine=systemd.default_device_timeout_sec=180
- name: Run integration tests
run: |
- sudo timeout -k 30 1h python3 -m pytest \
+ sudo TMPDIR=/mnt/mkosi \
+ timeout -k 30 1h python3 -m pytest \
--tb=no \
--capture=no \
--verbose \
import os
import subprocess
import sys
-import tempfile
+import uuid
from collections.abc import Iterator, Sequence
+from pathlib import Path
from types import TracebackType
from typing import Any, NamedTuple, Optional
self.config = config
def __enter__(self) -> "Image":
- self.output_dir = tempfile.TemporaryDirectory(dir="/var/tmp")
- os.chown(self.output_dir.name, INVOKING_USER.uid, INVOKING_USER.gid)
+ self.output_dir = Path(os.getenv("TMPDIR", "/var/tmp")) / uuid.uuid4().hex[:16]
return self
),
*self.options,
*options,
- "--output-dir", self.output_dir.name,
- "--cache-dir", "mkosi.cache",
+ "--output-dir", self.output_dir,
*(f"--kernel-command-line={i}" for i in kcl),
"--qemu-vsock=yes",
verb,
with Image(
initrd.config,
options=[
- "--initrd", Path(initrd.output_dir.name) / "initrd",
+ "--initrd", Path(initrd.output_dir) / "initrd",
"--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
"--incremental",
"--ephemeral",
with Image(
initrd.config,
options=[
- "--initrd", Path(initrd.output_dir.name) / "initrd",
+ "--initrd", Path(initrd.output_dir) / "initrd",
"--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
"--kernel-command-line=root=LABEL=root",
"--kernel-command-line=rw",
) as image, contextlib.ExitStack() as stack:
image.build(["--format", "directory"])
- drive = Path(image.output_dir.name) / "image.raw"
+ drive = Path(image.output_dir) / "image.raw"
drive.touch()
os.truncate(drive, 5000 * 1024**2)
with tempfile.TemporaryDirectory() as mnt, mount(Path("/dev/vg_mkosi/lv0"), Path(mnt)):
# The image might have been built unprivileged so we need to fix the file ownership. Making all the
# files owned by root isn't completely correct but good enough for the purposes of the test.
- copy_tree(Path(image.output_dir.name) / "image", Path(mnt), preserve=False)
+ copy_tree(Path(image.output_dir) / "image", Path(mnt), preserve=False)
stack.close()
with Image(
initrd.config,
options=[
- "--initrd", Path(initrd.output_dir.name) / "initrd",
+ "--initrd", Path(initrd.output_dir) / "initrd",
"--repart-dir", repartd,
"--passphrase", passphrase,
"--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
with Image(
config,
options=[
- "--initrd", Path(initrd.output_dir.name) / "initrd",
+ "--initrd", Path(initrd.output_dir) / "initrd",
"--kernel-command-line=systemd.unit=mkosi-check-and-shutdown.service",
"--kernel-command-line=root=LABEL=root",
"--kernel-command-line=rw",
) as image, contextlib.ExitStack() as stack:
image.build(["--format", "directory"])
- drive = Path(image.output_dir.name) / "image.raw"
+ drive = Path(image.output_dir) / "image.raw"
drive.touch()
os.truncate(drive, 5000 * 1024**2)
with tempfile.TemporaryDirectory() as mnt, mount(Path("/dev/vg_mkosi/lv0"), Path(mnt)):
# The image might have been built unprivileged so we need to fix the file ownership. Making all the
# files owned by root isn't completely correct but good enough for the purposes of the test.
- copy_tree(Path(image.output_dir.name) / "image", Path(mnt), preserve=False)
+ copy_tree(Path(image.output_dir) / "image", Path(mnt), preserve=False)
stack.close()
Distribution.opensuse: 39,
}.get(initrd.config.distribution, 48)
- assert (Path(initrd.output_dir.name) / "initrd").stat().st_size <= maxsize
+ assert (Path(initrd.output_dir) / "initrd").stat().st_size <= maxsize