diff --git a/examples/bootc/build b/examples/bootc/build new file mode 100755 index 00000000..e078cab6 --- /dev/null +++ b/examples/bootc/build @@ -0,0 +1,27 @@ +#!/bin/sh + +set -eux + +cd "${0%/*}" +image="${1:-docker://quay.io/fedora/fedora-bootc:42}" + +cargo build --release +cp ../../target/release/cfsctl . +mkdir -p initrd/usr/bin +cp ../../target/release/composefs-setup-root initrd/usr/bin + +# rm -rf tmp +../common/install-systemd-boot + +mkdir -p tmp/sysroot/composefs +./cfsctl --repo tmp/sysroot/composefs oci pull "${image}" image +./cfsctl --repo tmp/sysroot/composefs oci prepare-boot refs/image --bootdir tmp/efi --cmdline rw --cmdline console=ttyS0,115200 --cmdline enforcing=0 --cmdline root=/dev/vda2 --entry-id example + +( + cd initrd + find -print0 | cpio --null -ov --format=newc +) | gzip -9 > tmp/efi/composefs-setup-root.img + +echo 'initrd /composefs-setup-root.img' >> tmp/efi/loader/entries/example.conf + +../common/make-image bootc-efi.qcow2 diff --git a/examples/bootc/initrd/usr/bin/.gitignore b/examples/bootc/initrd/usr/bin/.gitignore new file mode 100644 index 00000000..5cfbf3c3 --- /dev/null +++ b/examples/bootc/initrd/usr/bin/.gitignore @@ -0,0 +1 @@ +/composefs-setup-root diff --git a/examples/bootc/initrd/usr/lib/systemd/system/composefs-setup-root.service b/examples/bootc/initrd/usr/lib/systemd/system/composefs-setup-root.service new file mode 100644 index 00000000..ffc404d6 --- /dev/null +++ b/examples/bootc/initrd/usr/lib/systemd/system/composefs-setup-root.service @@ -0,0 +1,34 @@ +# Copyright (C) 2013 Colin Walters +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library. If not, see . + +[Unit] +DefaultDependencies=no +ConditionKernelCommandLine=composefs +ConditionPathExists=/etc/initrd-release +After=sysroot.mount +Requires=sysroot.mount +Before=initrd-root-fs.target +Before=initrd-switch-root.target + +OnFailure=emergency.target +OnFailureJobMode=isolate + +[Service] +Type=oneshot +ExecStart=/usr/bin/composefs-setup-root +StandardInput=null +StandardOutput=journal +StandardError=journal+console +RemainAfterExit=yes diff --git a/examples/bootc/initrd/usr/lib/systemd/system/initrd-root-fs.target.wants/composefs-setup-root.service b/examples/bootc/initrd/usr/lib/systemd/system/initrd-root-fs.target.wants/composefs-setup-root.service new file mode 120000 index 00000000..ddb2c063 --- /dev/null +++ b/examples/bootc/initrd/usr/lib/systemd/system/initrd-root-fs.target.wants/composefs-setup-root.service @@ -0,0 +1 @@ +../composefs-setup-root.service \ No newline at end of file diff --git a/src/bin/composefs-setup-root.rs b/src/bin/composefs-setup-root.rs index d756061b..3448d2cd 100644 --- a/src/bin/composefs-setup-root.rs +++ b/src/bin/composefs-setup-root.rs @@ -74,7 +74,7 @@ struct Args { #[arg( long, - default_value = "/usr/lib/ostree/prepare-root.conf", + default_value = "/usr/lib/composefs/setup-root.conf", help = "Config path (for testing)" )] config: PathBuf,