Skip to content

Conversation

@travier
Copy link
Member

@travier travier commented Jan 15, 2026

Build the sysext from Fedora RPMs and from scratch as part of the test to make this work on all releases and independently of the unofficial sysext project.

Only test on x86_64 & aarch64 for now.


Fixes: coreos/fedora-coreos-tracker#1940

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request reworks the systemd sysext test to build the extension from RPMs locally, rather than downloading pre-built ones. This is a great improvement for test reliability and independence. My review includes several suggestions to enhance the robustness, security, and efficiency of the new build script. Key areas for improvement include proper temporary directory management, safer package repository handling, correct version sorting, and more robust file operations.

dnf download --resolve --arch=noarch --arch="$(arch)" "${rpm}"

# Figure out version to use
pkg="$(ls ${rpm}-*.rpm | sort -h | head -1)"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The sort -h command is for sorting human-readable numbers (e.g., 2K, 1G), not version strings. For correct version sorting, you should use sort -V. To get the latest version, you should select the last item after sorting, not the first. Using ls -1 is also recommended in scripts to ensure one file per line.

Suggested change
pkg="$(ls ${rpm}-*.rpm | sort -h | head -1)"
pkg="$(ls -1 ${rpm}-*.rpm | sort -V | tail -n 1)"

Comment on lines +25 to +26
tmpdir="/tmp/sysext-${rpm}"
mkdir "${tmpdir}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a fixed temporary directory name can lead to conflicts and is a security risk. It's better to use mktemp -d to create a unique and secure temporary directory.

Suggested change
tmpdir="/tmp/sysext-${rpm}"
mkdir "${tmpdir}"
tmpdir=$(mktemp -d "/tmp/sysext-${rpm}.XXXXXX")

mkfs.erofs -zlz4 "${name}" rootfs
mv "${name}" /tmp

popd > /dev/null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The temporary directory created for the build is not removed, which will leave files in /tmp. It's important to clean up this directory after it's no longer needed.

Suggested change
popd > /dev/null
popd > /dev/null
rm -rf "${tmpdir}"

Comment on lines +106 to +113
mv "/tmp/${name}"*".raw" "/var/lib/extensions.d"
ln -snf "/var/lib/extensions.d/${name}"*".raw" "/var/lib/extensions/${name}.raw"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using globs (*) with mv and ln can be risky. If the glob expands to zero, or more than one file, these commands can fail or have unintended consequences. It's safer to verify that the glob matches exactly one file before proceeding.

For example:

local files=(/path/to/"${name}"*.raw)
if [ "${#files[@]}" -ne 1 ]; then
    fatal "Expected 1 file, found ${#files[@]}"
fi
# Now use "${files[0]}"
safely

Please apply this pattern to both the mv and ln commands.

Comment on lines +89 to +98
# Create the EROFS image
name="${rpm}-${version}-${version_id}-${arch}.raw"
mkfs.erofs -zlz4 "${name}" rootfs
mv "${name}" /tmp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't have to make it a .raw image (it can just be a directory/fs tree of files.

I think you know this and your intent here was to test the .raw because that's more like what users are going to be using (i.e. downloading a .raw and using that extension), but just in case wanted to point it out that this step may not be needed if you didn't have testing that use case specifically in mind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Maybe I should test both. I'll do that in a followup.

dustymabe
dustymabe previously approved these changes Jan 19, 2026
Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - a few comments

Build the sysext from Fedora RPMs and from scratch as part of the test
to make this work on all releases and independently of the unofficial
sysext project.

Only test on x86_64 & aarch64 for now.
--resolve \
--arch="noarch" \
--arch="$(arch)" \
-disablerepo=fedora-cisco-openh264 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-disablerepo=fedora-cisco-openh264 \
--disablerepo=fedora-cisco-openh264 \

@dustymabe
Copy link
Member

as part of this PR you should drop the denylist entry added in 5d5b319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a test for systemd system extensions (sysexts)

2 participants