Skip to content

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

Merged
rollandf merged 1 commit intoMellanox:mainfrom
rollandf:fix/docker-ubuntu-sources
Feb 10, 2026
Merged

Fix build: handle missing ubuntu.sources for deb-src#283
rollandf merged 1 commit intoMellanox:mainfrom
rollandf:fix/docker-ubuntu-sources

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 Dockerfile and Dockerfile.nic-configuration-daemon to guard the deb-src enabling step by checking whether /etc/apt/sources.list.d/ubuntu.sources exists, and falling back to editing /etc/apt/sources.list when it doesn’t. This is intended to prevent build failures on base images that don’t ship the newer ubuntu.sources format, so apt-get source ... can proceed during image builds.

Confidence Score: 3/5

  • This PR is mergeable once the deb-src fallback reliably enables source repos on minimal bases.
  • The change is small and localized, but the new /etc/apt/sources.list fallback only uncomments existing deb-src lines; on images without any deb-src entries, apt-get source will still fail, which defeats the stated build-fix goal for some bases.
  • Dockerfile, Dockerfile.nic-configuration-daemon

Important Files Changed

Filename Overview
Dockerfile Adds conditional logic to edit either ubuntu.sources or sources.list to enable deb-src before running apt-get update/install/source; fallback may still fail when sources.list lacks any deb-src entries.
Dockerfile.nic-configuration-daemon Same conditional deb-src enabling logic as Dockerfile before apt-get source; fallback only uncomments existing deb-src lines and won’t help if none are present.

Sequence Diagram

sequenceDiagram
  participant Builder as Docker build
  participant FS as Base image filesystem
  participant APT as apt-get

  Builder->>FS: Check /etc/apt/sources.list.d/ubuntu.sources exists?
  alt ubuntu.sources present
    Builder->>FS: sed Types: deb -> Types: deb deb-src
  else ubuntu.sources absent
    Builder->>FS: Check /etc/apt/sources.list exists?
    alt sources.list present
      Builder->>FS: sed uncomment deb-src lines
    else sources.list absent
      Note over Builder,FS: No change to APT sources
    end
  end
  Builder->>APT: apt-get update
  Builder->>APT: apt-get install dpkg-dev...
  Builder->>APT: apt-get source dpkg-dev...
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 enablement is incomplete

In the /etc/apt/sources.list fallback, this only uncomments existing deb-src lines (s/^#\s*deb-src/deb-src/). On images where deb-src entries are absent (common for minimal bases), this won’t enable source repos, and apt-get source ${PACKAGES} will still fail. If the goal is to reliably enable deb-src across bases, this branch likely needs to also add matching deb-src entries when none exist (or transform debdeb-src lines) rather than only uncommenting.

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 enablement is incomplete

Same as Dockerfile: the /etc/apt/sources.list fallback only uncomments pre-existing deb-src lines. If the base image’s sources.list doesn’t contain any deb-src entries, apt-get source ${PACKAGES} can still fail even though this block ran. Consider adding deb-src entries (or transforming corresponding deb lines) when no deb-src lines exist, instead of only uncommenting.

@rollandf rollandf merged commit 8c280e7 into Mellanox:main Feb 10, 2026
7 of 10 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