-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- [x] Add dracut-module example Containerfile and readme - [x] Add dracut-module example to main readme - [x] Add dracut-module github workflow file - [x] Test build dracut-module example
- Loading branch information
1 parent
d6606e8
commit 95f79b0
Showing
7 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: "Build image: dracut-module" | ||
|
||
env: | ||
IMAGE_NAME: "dracut-module" | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- dracut-module/* | ||
- .github/workflows/dracut-module.yml | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- dracut-module/* | ||
- .github/workflows/dracut-module.yml | ||
|
||
jobs: | ||
build-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build container image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
context: ${{ env.IMAGE_NAME }} | ||
containerfiles: ${{ env.IMAGE_NAME }}/Containerfile | ||
image: ${{ env.IMAGE_NAME }} | ||
layers: false | ||
oci: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Convert an Ubuntu Package and Install It | ||
|
||
This example converts an Ubuntu package into an rpm using [alien](https://wiki.debian.org/Alien) an then installs it using `rpm-ostree`. | ||
This example converts an Ubuntu package into an rpm using [alien](https://wiki.debian.org/Alien) and then installs it using `rpm-ostree`. | ||
|
||
This is useful for packages that are present in Ubuntu, but not in Fedora. This example installs Ubuntu's latest packaged version of gocryptfs, which is [no longer maintained in Fedora](https://discussion.fedoraproject.org/t/gocryptfs-not-available-on-fedora-36). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Install and run a dracut module | ||
FROM quay.io/fedora/fedora-coreos:stable | ||
|
||
# Install dracut module requirements | ||
RUN rpm-ostree install busybox rng-tools pcsc-tools bluez && \ | ||
ostree container commit | ||
|
||
# Add dracut module files | ||
COPY files/ /usr/lib/dracut/modules.d/10systemd-echo-here/ | ||
|
||
# Run dracut to build a new initrd | ||
RUN stock_arguments=$(lsinitrd /lib/modules/6.4.7-200.fc38.x86_64/initramfs.img | grep '^Arguments: ' | sed 's/^Arguments: //') && \ | ||
mkdir -p /tmp/dracut /var/roothome && \ | ||
bash <(/usr/bin/echo "dracut $stock_arguments") && \ | ||
rm -rf /var/* /tmp/* && \ | ||
ostree container commit | ||
|
||
# Move the new initrd into place while keeping the stock initrd in the image for reference. | ||
RUN export KERNEL_VERSION="$(rpm -qa kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')" && \ | ||
mv -v "/lib/modules/${KERNEL_VERSION}/initramfs.img" "/lib/modules/${KERNEL_VERSION}/initramfs.stock.img" && \ | ||
mv -v /boot/initramfs*.img "/lib/modules/${KERNEL_VERSION}/initramfs.img" && \ | ||
ostree container commit | ||
|
||
# Show that the initrd includes the echo-here service: | ||
RUN lsinitrd /lib/modules/*/initramfs.img | grep echo-here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Install and run a dracut module | ||
|
||
This example adds a dracut module to the container and calls dracut to build a new initrd using this module. | ||
|
||
This is useful when something needs to run inside of the initrd, which is very early in the boot process. | ||
|
||
This specific example registers a systemd service that prints out when it was executed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=Service to Echo Here During initrd Startup | ||
DefaultDependencies=no | ||
ConditionVirtualization=!container | ||
|
||
Requires=systemd-udev-settle.service | ||
After=systemd-udev-settle.service | ||
Before=cryptsetup.target | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/echo --------------------HERE-------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
depends() { | ||
echo systemd | ||
return 0 | ||
} | ||
|
||
install() { | ||
inst_simple "${moddir}/echo-here.service" "${systemdsystemunitdir}/echo-here.service" | ||
$SYSTEMCTL -q --root "$initdir" add-wants cryptsetup.target echo-here.service | ||
} |