Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fedora: Unpack from ISO #121

Merged
merged 4 commits into from
Feb 10, 2025
Merged

Conversation

MusicDin
Copy link
Member

Adds support to unpack Fedora ISO image, and some small cosmetic fixes.

@MusicDin MusicDin marked this pull request as ready for review January 23, 2025 14:18
@MusicDin MusicDin requested a review from tomponline as a code owner January 23, 2025 14:18
@MusicDin MusicDin requested a review from simondeziel January 23, 2025 14:18
// when the release version is equal or less than 40.
relNum, err := strconv.Atoi(s.definition.Image.Release)
if err == nil && relNum <= 40 {
baseURL := fmt.Sprintf("%s/packages/Fedora-Container-Base", s.definition.Source.URL)
Copy link
Member

Choose a reason for hiding this comment

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

I tend to prefer the more performant variant:

Suggested change
baseURL := fmt.Sprintf("%s/packages/Fedora-Container-Base", s.definition.Source.URL)
baseURL := s.definition.Source.URL + "/packages/Fedora-Container-Base"

But I understand that might not be relevant for this code base that is probably filled with fmt.Sprintf...


gpg_keys_official="file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-%[2]s-primary"

if [ -n "${GPG_KEYS}" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Since we know Fedora publishes package signing keys, would it make sense to require GPG keys to be provided?

Copy link
Member Author

@MusicDin MusicDin Feb 6, 2025

Choose a reason for hiding this comment

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

This is for the initial packages we mount on /mnt/cdrom/Packages, and as far as I understand they are not signed which is the reason there is no GPG keys for them. Packages that are downloaded later from the Fedora repositories are checked with GPG keys that are provided within the ISO file.

Here is a snippet what I have tried doing:

# Iterate over all subdirectories in /mnt/cdrom/Packages
for dir in /mnt/cdrom/Packages/*/; do
    if [[ -d "$dir" ]]; then
        echo "Checking RPMs in: $dir"
        rpm --checksig "$dir"*.rpm || true
	rpm --query --queryformat '%{NAME}-%{VERSION}-%{RELEASE} -> %{SIGPGP:pgpsig}\n' --package "$dir"*.rpm || true
    fi
done

Snippet of the entire output:

+ [[ -d /mnt/cdrom/Packages/j/ ]]
+ echo 'Checking RPMs in: /mnt/cdrom/Packages/j/'
Checking RPMs in: /mnt/cdrom/Packages/j/

+ rpm --checksig /mnt/cdrom/Packages/j/jansson-2.13.1-10.fc41.x86_64.rpm /mnt/cdrom/Packages/j/jbigkit-libs-2.1-30.fc41.i686.rpm /mnt/cdrom/Packages/j/jbigkit-libs-2.1-30.fc41.x86_64.rpm /mnt/cdrom/Packages/j/jemalloc-5.3.0-7.fc41.x86_64.rpm /mnt/cdrom/Packages/j/jomolhari-fonts-0.003-42.fc41.noarch.rpm /mnt/cdrom/Packages/j/jq-1.7.1-8.fc41.x86_64.rpm /mnt/cdrom/Packages/j/json-c-0.17-4.fc41.x86_64.rpm /mnt/cdrom/Packages/j/json-c-devel-0.17-4.fc41.x86_64.rpm /mnt/cdrom/Packages/j/json-glib-1.10.0-1.fc41.i686.rpm /mnt/cdrom/Packages/j/json-glib-1.10.0-1.fc41.x86_64.rpm
/mnt/cdrom/Packages/j/jansson-2.13.1-10.fc41.x86_64.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/jbigkit-libs-2.1-30.fc41.i686.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/jbigkit-libs-2.1-30.fc41.x86_64.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/jemalloc-5.3.0-7.fc41.x86_64.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/jomolhari-fonts-0.003-42.fc41.noarch.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/jq-1.7.1-8.fc41.x86_64.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/json-c-0.17-4.fc41.x86_64.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/json-c-devel-0.17-4.fc41.x86_64.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/json-glib-1.10.0-1.fc41.i686.rpm: digests SIGNATURES NOT OK
/mnt/cdrom/Packages/j/json-glib-1.10.0-1.fc41.x86_64.rpm: digests SIGNATURES NOT OK
+ true

+ echo 'Checking smth in: /mnt/cdrom/Packages/j/'
+ rpm --query --queryformat '%{NAME}-%{VERSION}-%{RELEASE} -> %{SIGPGP:pgpsig}\n' --package /mnt/cdrom/Packages/j/jansson-2.13.1-10.fc41.x86_64.rpm /mnt/cdrom/Packages/j/jbigkit-libs-2.1-30.fc41.i686.rpm /mnt/cdrom/Packages/j/jbigkit-libs-2.1-30.fc41.x86_64.rpm /mnt/cdrom/Packages/j/jemalloc-5.3.0-7.fc41.x86_64.rpm /mnt/cdrom/Packages/j/jomolhari-fonts-0.003-42.fc41.noarch.rpm /mnt/cdrom/Packages/j/jq-1.7.1-8.fc41.x86_64.rpm /mnt/cdrom/Packages/j/json-c-0.17-4.fc41.x86_64.rpm /mnt/cdrom/Packages/j/json-c-devel-0.17-4.fc41.x86_64.rpm /mnt/cdrom/Packages/j/json-glib-1.10.0-1.fc41.i686.rpm /mnt/cdrom/Packages/j/json-glib-1.10.0-1.fc41.x86_64.rpm

warning: /mnt/cdrom/Packages/j/jansson-2.13.1-10.fc41.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID e99d6ad1: NOKEY
jansson-2.13.1-10.fc41 -> (none)
jbigkit-libs-2.1-30.fc41 -> (none)
jbigkit-libs-2.1-30.fc41 -> (none)
jemalloc-5.3.0-7.fc41 -> (none)
jomolhari-fonts-0.003-42.fc41 -> (none)
jq-1.7.1-8.fc41 -> (none)
json-c-0.17-4.fc41 -> (none)
json-c-devel-0.17-4.fc41 -> (none)
json-glib-1.10.0-1.fc41 -> (none)
json-glib-1.10.0-1.fc41 -> (none)

If anyone has more understanding in this, I recommend myself for some help :)

simondeziel
simondeziel previously approved these changes Feb 7, 2025
simondeziel added a commit to canonical/lxd-ci that referenced this pull request Feb 7, 2025
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

@MusicDin just to confirm this is verifying the checksum of the downloaded iso against a separately stored value?

// getDownloadURL fetches JSON representation of current releases and
// extracts the download URL matching the given release, variant, arch,
// and filetype (.tar.xz, .iso, etc.).
func (s *fedora) getDownloadURL(release string, variant string, arch string, fileType string) (url string, checksum string, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

@MusicDin when does this ever return a checksum to be verified?

if err != nil {
return fmt.Errorf("Failed to unpack %q: %w", filepath.Join(fpath, fname), err)
// Verify checksum.
if checksum != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Why wouldnt a checksum be returned? This feels like it could introduce accidental issues in case the checksum is ever not returned we would not verify it?

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

Im not quite clear how we are verifying the downloaded iso file.

Which is critical because as far as I can see, we then go onto trust the GPG keys inside it.

@MusicDin MusicDin force-pushed the fix/img-builder branch 3 times, most recently from cd5ad8a to 564cf83 Compare February 10, 2025 09:28
Signed-off-by: Din Music <[email protected]>
@MusicDin
Copy link
Member Author

Fixed, now the checksum is required in order to proceed with unpacking ISO.

Passing build: https://github.com/MusicDin/lxd-ci/actions/runs/13237766213/job/36946163432

@MusicDin MusicDin requested a review from tomponline February 10, 2025 09:46
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

LGTM thanks

@tomponline tomponline merged commit 99947d7 into canonical:main Feb 10, 2025
9 of 10 checks passed
@MusicDin MusicDin deleted the fix/img-builder branch February 10, 2025 10:07
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.

None yet

3 participants