Fix build: handle missing ubuntu.sources for deb-src#284
Conversation
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 OverviewGreptile SummaryThis PR updates both Docker build images to be resilient to different Ubuntu APT source layouts by checking for These changes are part of the image build steps that prepare the base DOCA Ubuntu image for One functional gap remains: the fallback path only uncomments existing Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
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
|
| 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 |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
29c2432
into
Mellanox:network-operator-26.1.x
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.