Skip to content

[BUG] YUM repos with file:// are using image-build's root instead of container's root #30

@synackd

Description

@synackd

Describe the bug
When building an image using the image-build container and when a YUM repo from a parent image has file:// absolute file path in its URL directive, the image-builder searches the image-build container's root instead of the image container's root.

I believe this is caused by the way dnf is being run. For example, with a parent image that has NVIDIA DOCA drivers installed and has had the doca-kernel-support script has run, the following repo gets added:

[doca-kernel-4.18.0-553.51.1.el8_10.x86_64]            
name=DOCA kernel (kernel 4.18.0-553.51.1.el8_10.x86_64)
baseurl=file:///usr/share/doca-host-25.04-0.6.1.0/Modules/4.18.0-553.51.1.el8_10.x86_64
enabled=1                                                           
gpgcheck=0

When building a child image, it fails at the package installation step:

INFO - PACKAGES: Installing these packages to compute-zfs-2.2.720250717214608
INFO - zfs
nvme-cli
htop
iftop
ack
tmux
INFO - created by dnf config-manager from http://172.1  85 MB/s | 211 kB     00:00
INFO - created by dnf config-manager from http://172.1  77 MB/s |  89 kB     00:00
INFO - created by dnf config-manager from http://dl.fe  16 MB/s |  14 MB     00:00
INFO - created by dnf config-manager from http://dl.ro 2.7 MB/s |  19 MB     00:07
INFO - created by dnf config-manager from http://dl.ro  40 MB/s |  27 MB     00:00
INFO - created by dnf config-manager from http://dl.ro 7.5 MB/s | 4.5 MB     00:00
INFO - DOCA kernel (kernel 4.18.0-553.51.1.el8_10.x86_ 0.0  B/s |   0  B     00:00
ERROR - Errors during downloading metadata for repository 'doca-kernel-4.18.0-553.51.1.el8_10.x86_64':
ERROR -   - Curl error (37): Couldn't read a file:// file for file:///usr/share/doca-host-25.04-0.6.1.0/Modules/4.18.0-553.51.1.el8_10.x86_64/repodata/repomd.xml [Couldn't open file /usr/share/doca-host-25.04-0.6.1.0/Modules/4.18.0-553.51.1.el8_10.x86_64/repodata/repomd.xml
]
ERROR - Error: Failed to download metadata for repo 'doca-kernel-4.18.0-553.51.1.el8_10.x86_64': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
ERROR - Error installing packages: Command '['dnf', '--setopt=reposdir=/home/builder/.local/share/containers/storage/overlay/8b12b97afdedd1db9a4fd2f76b17ec615144d4cb969c2bccab7a0fb1943a478c/merged/etc/yum.repos.d', '--setopt=logdir=/var/tmp/image-build-kzcwfd_x/dnf/log', '-
-setopt=cachedir=/var/tmp/image-build-kzcwfd_x/dnf/cache', 'install', '-y', '--nogpgcheck', '--installroot', '/home/builder/.local/share/containers/storage/overlay/8b12b97afdedd1db9a4fd2f76b17ec615144d4cb969c2bccab7a0fb1943a478c/merged', 'zfs', 'nvme-cli', 'htop', 'iftop',
'ack', 'tmux']' returned non-zero exit status 1.
INFO - 32bf2b0b929e8c9521c76815d2b7de5d01de5c0989f335f16778cf490bfda802
 
-------------------BUILD LAYER--------------------
Exiting now ...

/usr/share/doca-host-25.04-0.6.1.0/Modules/4.18.0-553.51.1.el8_10.x86_64/repodata/repomd.xml exists in the image, but not in the image-build container.

To Reproduce
Steps to reproduce the behavior:

  1. Run image-build container:
    podman run -it --rm --device /dev/fuse ghcr.io/openchami/image-build:v0.1.0 bash
    
  2. Create dummy repo:
    mkdir -p testrepo/repodata
    touch testrepo/repodata/repomd.xml
    
  3. Create config:
    cat <<EOF > config.yaml
    options:
      layer_type: 'base'
      name: 'test'
      publish_tags:
        - 'rocky8.10'
      pkg_manager: 'dnf'
      parent: 'scratch'
      registry_opts_pull:
        - '--tls-verify=false'
    
    repos:
      - alias: test
        url: 'file:///home/builder/testrepo'
    
    packages:
      - fortune
    EOF
    
  4. Build using config:
    image-build --config ./config.yaml
    

The output emitted is:

WARNING:root:No publish options passed, not storing image anywhere!
WARNING:root:Use one or more of --publish-local, --publish-s3, or --publish-registry
WARNING:root:to store in one or more of those locations.

-------------------BUILD LAYER--------------------
WARNING:root:PACKAGE MODULES: no modules passed to install

WARNING:root:PACKAGE GROUPS: no package groups passed to install

ERROR:root:Unable to detect release version (use '--releasever' to specify release version)
ERROR:root:Error: Failed to download metadata for repo 'home_builder_testrepo': repomd.xml parser error: Parse error at line: 1 (Extra content at the end of the document
ERROR:root:)
ERROR:layer:Error installing packages: Command '['dnf', '--setopt=reposdir=/home/builder/.local/share/containers/storage/overlay/7260f115e6d18f9786a5800d4c9d326f9df1b7dfcca069c256634c9594e71c65/merged/etc/yum.repos.d', '--setopt=logdir=/var/tmp/image-build-6o41_xxm/dnf/log', '--setopt=cachedir=/var/tmp/image-build-6o41_xxm/dnf/cache', 'install', '-y', '--nogpgcheck', '--installroot', '/home/builder/.local/share/containers/storage/overlay/7260f115e6d18f9786a5800d4c9d326f9df1b7dfcca069c256634c9594e71c65/merged', 'fortune']' returned non-zero exit status 1.
Exiting now ...

The error is:

ERROR:root:Error: Failed to download metadata for repo 'home_builder_testrepo': repomd.xml parser error: Parse error at line: 1 (Extra content at the end of the document
ERROR:root:)

This indicates that the file on the image-build tool container is being read instead of trying to read it from the container of the image being built.

Expected behavior
file:// should look in image container.

Desktop (please complete the following information):

  • OS: Rocky 9.5, building Rocky 8.10 image

Additional context
image-build v0.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions