Debian Codegraph @

src/container/Containerfile

raw
1 # Base Containerfile for Debcraft
2 FROM debian:sid
3
4 ARG HOST_ARCH
5 ARG SOURCE_DATE_EPOCH
6 ENV SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}
7
8 ENV DEBIAN_FRONTEND=noninteractive
9
10 # Standardize date formats and timestamps in output and logs
11 ENV LC_ALL=C
12
13 # Inside the container there are no GPG keys available, so ensure Git never
14 # tries to sign commits. Using environment variables avoids modifying the
15 # repository's local git config and only affects processes in this container.
16 ENV GIT_CONFIG_COUNT=1
17 ENV GIT_CONFIG_KEY_0=commit.gpgsign
18 ENV GIT_CONFIG_VALUE_0=false
19
20 # Ensure output is colorized in Node.js / general tools
21 ENV FORCE_COLOR=1
22 # BSD-style tools (autopkgtest)
23 ENV CLICOLOR_FORCE=1
24 # CMake
25 ENV CMAKE_COLOR_MAKEFILE=ON
26 ENV CMAKE_COLOR_DIAGNOSTICS=ON
27
28 # Automatically remove 500MB+ of debug symbols that GCC maintainers have
29 # intentionally in unstable for bootstrapping new stack tracing, but which is
30 # unnecessary for Debcraft containers
31 COPY 80-strip-gcc-debug-symbols /etc/apt/apt.conf.d/
32
33 # When building on amd64 prefer variant amd64v3 on new releases that support
34 # the dpkg feature 'Architecture-Variants'
35 RUN if grep -q 'VERSION="26.04 (Resolute Raccoon)"' /etc/os-release; \
36 then \
37 if [ "$(uname --machine)" = "x86_64" ]; \
38 then \
39 echo 'APT::Architecture-Variants "amd64v3";' >> /etc/apt/apt.conf.d/99enable-amd64v3; \
40 echo 'host-arch-variant = amd64v3' >> /etc/dpkg/buildpackage.conf; \
41 fi; \
42 fi
43
44 # Stretch is no longer available at deb.debian.org, use archive.debian.org instead
45 RUN if grep -q 'PRETTY_NAME="Debian GNU/Linux 9 (stretch)"' /etc/os-release; \
46 then \
47 echo "deb http://archive.debian.org/debian stretch main\ndeb http://archive.debian.org/debian-security stretch/updates main" \
48 > /etc/apt/sources.list; \
49 fi
50
51 # Before installing anything else, install auto-apt-proxy that will hook into
52 # /etc/apt/apt.conf.d/auto-apt-proxy.conf and try to use a proxy if available
53 # https://manpages.debian.org/unstable/auto-apt-proxy/auto-apt-proxy.1.en.html#PRECEDENCE_BETWEEN_MULTIPLE_POSSIBLE_PROXIES
54 RUN apt-get update -q && \
55 apt-get install -q --yes --no-install-recommends \
56 auto-apt-proxy
57
58 # Debian build essentials and Debcraft essentials
59 # Unfortunately this is almost 500 MB but here is no way around it. Luckily due
60 # to caching all rebuilds and all later containers will build much faster.
61 RUN apt-get update -q && \
62 apt-get install -q --yes --no-install-recommends \
63 blhc \
64 ccache \
65 curl \
66 devscripts \
67 eatmydata \
68 equivs \
69 fakeroot \
70 git \
71 git-buildpackage \
72 lintian \
73 pristine-tar \
74 quilt
75
76 # Validator dependencies
77 RUN apt-get update -q && \
78 apt-get install -q --yes --no-install-recommends \
79 apt-utils \
80 autopkgtest \
81 autodep8 \
82 codespell \
83 command-not-found \
84 hunspell-en-us \
85 python3-bs4 \
86 python3-debian \
87 python3-hunspell \
88 python3-levenshtein \
89 python3-setuptools \
90 shellcheck \
91 xxd
92
93 # The diffoscope-minimal package is available only since Debian 11 "Bullseye",
94 # and thus building containers of older Debian or Ubuntu releases will fail
95 # but can be ignored, as only diffoscope-features are affected. Use same
96 # section to also install utilities diffoscope needs to show good reports
97 # across two .changes files.
98 RUN apt-get update -q && \
99 apt-get install -q --yes --no-install-recommends \
100 diffoscope-minimal \
101 zstd || true
102
103 # The lintianb-rush package is (consistently) available only since Debian 12
104 # "Bookworm" and thus building containers of older Debian or Ubuntu releases
105 # will fail, but that can be ignored
106 RUN apt-get update -q && \
107 apt-get install -q --yes --no-install-recommends \
108 lintian-brush || true
109
110 # The licenserecon package is available only since Debian 13 "Trixie",
111 # and thus building containers of older Debian or Ubuntu releases will fail
112 # but can be ignored
113 RUN apt-get update -q && \
114 apt-get install -q --yes --no-install-recommends \
115 licenserecon || true
116
117 # @TODO: The dh-debputy and python3-lsprotocol are available only in latest
118 # Debian Sid 2024, and thus building containers of older Debian and Ubuntu
119 # releases will fail and thus an override to return a successful exit code is
120 # needed. This can be removed once dh-debputy with dependencies is available via
121 # backports: https://salsa.debian.org/debian/debputy/-/issues/76#note_512583
122 RUN apt-get update -q && \
123 apt-get install -q --yes --no-install-recommends \
124 dh-debputy \
125 python3-lsprotocol || true
126
127 # Install sccache (available in Debian/Ubuntu since December 2022) so C/C++ and
128 # Rust builds can use it
129 RUN apt-get update -q && \
130 apt-get install -q --yes --no-install-recommends \
131 sccache || true
132
133 # Activate source repositories in the Containerfile so that the large download
134 # is cached in the container and the validator can run quickly
135 COPY enable-source-repositories.sh enable-extra-repositories.sh output.inc.sh /
136 RUN /enable-source-repositories.sh
137
138 # Insert extra repositories and keys right before build dependencies are to be
139 # installed following convention set in Salsa CI
140 # (https://salsa.debian.org/salsa-ci-team/pipeline#add-private-repositories-to-the-builds)
141 COPY ci /ci
142 COPY extra_repository_dir /debcraft/extra_repository_dir
143 RUN /enable-extra-repositories.sh
144
145 RUN echo "Package: *" >> /etc/apt/preferences.d/99experimental-force && \
146 echo "Pin: release a=experimental" >> /etc/apt/preferences.d/99experimental-force && \
147 echo "Pin-Priority: 900" >> /etc/apt/preferences.d/99experimental-force && \
148 echo "" >> /etc/apt/preferences.d/99experimental-force && \
149 echo "Package: libcrack2 libcrack2-dev cracklib-runtime" >> /etc/apt/preferences.d/99experimental-force && \
150 echo "Pin: release a=unstable" >> /etc/apt/preferences.d/99experimental-force && \
151 echo "Pin-Priority: 999" >> /etc/apt/preferences.d/99experimental-force
152
153 # Install dependencies
154 #@TODO: Use 'apt-get build-dep .' as all modern Debian/Ubuntu versions support it
155 COPY control /
156
157 # Verify build dependencies are satisfiable before attempting installation
158 # This provides much clearer error messages than mk-build-deps failure output.
159 # Skip this step if /control is missing (e.g. when building downloader container).
160 RUN [ -z "$HOST_ARCH" ] || dpkg --add-architecture "$HOST_ARCH"; \
161 apt-get update -q && \
162 if [ -s /control ]; then \
163 cd /tmp && \
164 mk-build-deps ${HOST_ARCH:+--host-arch $HOST_ARCH} /control && \
165 apt-get install --dry-run ./*.deb 2>&1 || { echo "ERROR: Build dependencies cannot be satisfied. See apt output above for specific missing packages."; exit 1; } && \
166 DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -o Debug::pkgProblemResolver=yes ./*.deb && \
167 rm -f ./*.deb; \
168 fi
169
170 # Should be automatic and not needed at all, but run one more time just to be sure
171 RUN update-ccache-symlinks
172
173 # Older ccache does not support '--verbose' but will print stats anyway, just
174 # followed by help section. Newer ccache 4.0+ (Ubuntu 22.04 "Focal", Debian 12
175 # "Bullseye") however require '--verbose' to show any cache hit stats at all.
176 RUN ccache --show-stats --verbose || true; sccache --show-stats || true
177
178 # All Debcraft commands and libraries are copied to the container root as it is
179 # a throw-away environment and strict adherense to LSB does not matter. Do not
180 # put any scripts into the /debcraft folder, as it is dedicated for build
181 # artifacts that will be stored.
182 COPY *.sh /
183 COPY improve.d/ /improve.d/