Debian Codegraph @

debian/Dockerfile

raw
1 # Build in-toto for Debian on any host
2 #
3 # Release workflow (with example commands)
4 # ----------------
5 #
6 # 1. Checkout "debian" branch and rebase on upstream release tag
7 #
8 # git switch debian && git rebase v2.0.0
9 #
10 # 2. Update debian/* files, most notably add new entry to debian/changelog
11 #
12 # 3. Build (requires upstream VERSION and path to *.deb dependencies as args)
13 #
14 # - Installs dev tools and build dependencies
15 # NOTE: Extra <securesystemslib>.deb dependency is expected to be passed
16 # via `--build-context extras=/path/*.deb`
17 # - Configures gpg + dput to upload to mentors
18 # - Fetches source dist from GitHub
19 # - Builds Debian package
20 #
21 # docker build --build-context extras=/path/to/dependency/*.deb \
22 # --build-arg VERSION=2.0.0 \
23 # -t deb-build .
24 #
25 # HINT: If the build fails, update debian/* files on host and rebuild.
26 # This might include downstream patching with `quilt`, which is also
27 # available outside of Debian (e.g. via brew on macOS).
28 #
29 # 4. Run to sign and upload (requires signing key as argument)
30 #
31 # docker run --rm -it --name deb-build --entrypoint bash \
32 # --env GPG_KEY="$(gpg --armor --export-secret-key [email protected])" \
33 # deb-build
34 #
35 # 5. (on container) Import signing key, sign and upload to mentors
36 #
37 # echo "$GPG_KEY" | gpg --import
38 # (cd in_toto-2.0.0 && debsign -k [email protected])
39 # dput mentors in-toto_2.0.0-1_arm64.changes
40 #
41 # 6. (optional, on host) Copy package to host, if needed later as build dependency
42 #
43 # docker cp deb-build:/home/build/in-toto_2.0.0-1_all.deb .
44 #
45 # 7. Commit changed Debian files, push/pr into "debian" branch
46 #
47 FROM debian:sid
48
49 # Install developer tools and build dependencies
50 RUN apt-get update \
51 && apt-get install --no-install-recommends -yV \
52 build-essential \
53 devscripts \
54 debhelper \
55 equivs \
56 wget \
57 lintian \
58 dput
59
60 # Copy and install extra dependencies (see --build-context arg)
61 # HACK: Comment out if not needed
62 COPY --from=extras . /tmp/extras
63 RUN apt-get install /tmp/extras/*.deb -yV
64
65 # Copy debian files
66 COPY . /tmp/debian
67
68 RUN mk-build-deps \
69 --install \
70 --remove \
71 --tool 'apt-get --no-install-recommends -yV' /tmp/debian/control
72
73 # Create user (some build tests related to permission fail as root)
74 RUN useradd build --create-home
75 USER build
76 WORKDIR /home/build
77
78 # Configure GPG
79 COPY --chown=build:build <<-"EOT" .gnupg/gpg.conf
80 use-agent
81 pinentry-mode loopback
82 EOT
83
84 COPY --chown=build:build <<-"EOT" .gnupg/gpg-agent.conf
85 allow-loopback-pinentry
86 EOT
87
88 # Configure DPUT
89 COPY --chown=build:build <<-"EOT" .dput.cf
90 [mentors]
91 fqdn = mentors.debian.net
92 incoming = /upload
93 method = https
94 allow_unsigned_uploads = 0
95 progress_indicator = 2
96 # Allow uploads for UNRELEASED packages
97 allowed_distributions = .*
98 EOT
99
100 # Grab source dist and sig for VERSION from GitHub and prepare for building
101 ARG VERSION
102 RUN wget https://github.com/in-toto/in-toto/releases/download/v${VERSION}/in_toto-${VERSION}.tar.gz \
103 -O in-toto_${VERSION}.orig.tar.gz
104 RUN wget https://github.com/in-toto/in-toto/releases/download/v${VERSION}/in_toto-${VERSION}.tar.gz.asc \
105 -O in-toto_${VERSION}.orig.tar.gz.asc
106 RUN tar xf in-toto_${VERSION}.orig.tar.gz
107 RUN cp -r /tmp/debian in_toto-${VERSION}
108
109 # Build
110 RUN cd in_toto-${VERSION} && debuild \
111 --unsigned-source \
112 --unsigned-changes \
113 --lintian-opts --display-level ">=pedantic" --display-experimental --tag-display-limit 0