Skip to content

Fix build: handle missing ubuntu.sources for deb-src#284

Merged
almaslennikov merged 1 commit intoMellanox:network-operator-26.1.xfrom
rollandf:fix/docker-ubuntu-sources-26.1
Feb 10, 2026
Merged

Fix build: handle missing ubuntu.sources for deb-src#284
almaslennikov merged 1 commit intoMellanox:network-operator-26.1.xfrom
rollandf:fix/docker-ubuntu-sources-26.1

Conversation

@rollandf
Copy link
Member

Check for the existence of /etc/apt/sources.list.d/ubuntu.sources before modifying it, falling back to /etc/apt/sources.list if needed. This fixes build failures on base images where the sources file location differs.

Check for the existence of /etc/apt/sources.list.d/ubuntu.sources before modifying it, falling back to /etc/apt/sources.list if needed. This fixes build failures on base images where the sources file location differs.

Signed-off-by: Fred Rolland <frolland@nvidia.com>
@greptile-apps
Copy link

greptile-apps bot commented Feb 10, 2026

Greptile Overview

Greptile Summary

This PR updates both Docker build images to be resilient to different Ubuntu APT source layouts by checking for /etc/apt/sources.list.d/ubuntu.sources before editing it, and falling back to modifying /etc/apt/sources.list.

These changes are part of the image build steps that prepare the base DOCA Ubuntu image for apt-get source ${PACKAGES} (used to fetch source packages after installing build dependencies).

One functional gap remains: the fallback path only uncomments existing deb-src lines in sources.list. On images that don’t include any deb-src entries (only deb entries), deb-src won’t actually be enabled and apt-get source will still fail.

Confidence Score: 3/5

  • This PR is not safe to merge until deb-src enabling is made reliable on images without existing deb-src entries.
  • The conditional file existence check fixes one failure mode, but the /etc/apt/sources.list fallback can be a no-op on common base images lacking deb-src lines, so the subsequent apt-get source ${PACKAGES} step can still fail deterministically.
  • Dockerfile, Dockerfile.nic-configuration-daemon

Important Files Changed

Filename Overview
Dockerfile Adds conditional logic to enable deb-src repos by editing /etc/apt/sources.list.d/ubuntu.sources or falling back to /etc/apt/sources.list; fallback can no-op on images without deb-src lines, so apt-get source may still fail.
Dockerfile.nic-configuration-daemon Same deb-src enabling change as Dockerfile, with identical limitation: /etc/apt/sources.list fallback only uncomments existing deb-src lines, which may not exist.

Sequence Diagram

sequenceDiagram
    participant CI as CI Build
    participant DF as Dockerfile
    participant APT as apt-get
    participant SRC as APT sources

    CI->>DF: docker build
    DF->>SRC: if ubuntu.sources exists
    alt /etc/apt/sources.list.d/ubuntu.sources present
        DF->>SRC: sed: Types: deb -> deb deb-src
    else /etc/apt/sources.list present
        DF->>SRC: sed: uncomment '# deb-src' lines
    else neither file present
        DF->>SRC: no change
    end
    DF->>APT: apt-get update (allow insecure)
    DF->>APT: apt-get install dpkg-dev...
    DF->>APT: apt-get source <packages>
    APT-->>CI: build succeeds/fails depending on deb-src enabled
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +54 to +58
RUN if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then \
sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources; \
elif [ -f /etc/apt/sources.list ]; then \
sed -i 's/^#\s*deb-src/deb-src/' /etc/apt/sources.list; \
fi
Copy link

Choose a reason for hiding this comment

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

deb-src not enabled

The /etc/apt/sources.list fallback only uncomments lines that start with # deb-src, but many Ubuntu images ship active deb lines without any deb-src lines at all. In that case, this sed no-ops and apt-get source ${PACKAGES} will still fail (the same build failure, just on a different base). Consider ensuring a deb-src entry exists (or enabling deb-src from existing deb entries) rather than only uncommenting existing deb-src lines.

Comment on lines +37 to +41
RUN if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then \
sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources; \
elif [ -f /etc/apt/sources.list ]; then \
sed -i 's/^#\s*deb-src/deb-src/' /etc/apt/sources.list; \
fi
Copy link

Choose a reason for hiding this comment

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

deb-src not enabled

Same issue as in Dockerfile: if the base image only has deb entries (common) and no deb-src lines, the fallback sed -i 's/^#\s*deb-src/deb-src/' does nothing, and apt-get source ${PACKAGES} later will still fail. This needs to create/enable deb-src sources rather than only uncomment them.

@almaslennikov almaslennikov merged commit 29c2432 into Mellanox:network-operator-26.1.x Feb 10, 2026
5 of 8 checks passed
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.

2 participants