Debian Codegraph @

tools/release

raw
1 #!/bin/sh
2
3 set -eux
4
5 # Produce a set of Cockpit release tarballs.
6 #
7 # This is the script used to create the official releases.
8 #
9 # It takes two mandatory arguments:
10 #
11 # - the URL to clone the repository from,
12 # eg. 'https://github.com/cockpit-project/cockpit'.
13 #
14 # - the version to release, which is also the tag name, eg. '215'.
15 #
16 # The main release tarball contains a number of files that are not directly in
17 # version control:
18 # - the usual automake stuff
19 # - several submodules
20 # - pre-compiled HTML and JS code
21 #
22 # This script shallow-clones the specified version of Cockpit from the
23 # specified URL, and downloads the version of the tasks container specified in
24 # that version. It then does an offline build of the release tarball, which is
25 # deterministic.
26 #
27 # You can use this script to verify the integrity of a particular set of Cockpit
28 # release tarballs, or even use it to create the tarballs for yourself, as an
29 # alternative to downloading it.
30 #
31 # The result of running `./autogen.sh && make dist VERSION=...` on any system
32 # ought to be the same, so long as the same versions of the autotools are
33 # present. Everything else present in the tarball is definitively pinned down
34 # in one way or another by the contents of the git repository. This script is
35 # a bit overkill, but it's written in hopes that someone reading it can
36 # reasonably convince themselves about the origin of absolutely everything in a
37 # Cockpit source release.
38 #
39 # If this script produces tarballs with different checksums than the
40 # officially-released ones, then please report a bug.
41
42 URL="$1"
43 VERSION="$2"
44
45 # We collect the sources into a temporary directory, then use tar to pipe them
46 # into a container with no network or filesystem access, where the actual build
47 # takes place. The container pipes the built source release back to us.
48
49 SOURCE="$(mktemp -dt 'cockpit-build-XXXXXX')"
50 trap 'rm -rf "${SOURCE}"' EXIT
51
52 # Clone the release and selected submodules into the temporary directory.
53 git clone \
54 --depth=1 \
55 --recurse-submodules=node_modules \
56 --recurse-submodules=vendor \
57 -b "${VERSION}" \
58 "${URL}" \
59 "${SOURCE}"
60
61 # Show exactly what we're building.
62 git -C "${SOURCE}" show --no-patch "${VERSION}"
63
64 # Download the tasks container image used for this release.
65 IMAGE="$(cat "${SOURCE}"/.cockpit-ci/container)"
66 podman pull "${IMAGE}"
67
68 # Build the checked out sources into the release tarballs, offline.
69 # `make dist` builds both the main and node runtime tarballs.
70 # Wrap both in a tar for output and unwrap on the outside.
71 tar -C "${SOURCE}" -c . | \
72 podman \
73 run \
74 --rm \
75 --pull=never \
76 --network=none \
77 --log-driver=none \
78 --interactive \
79 --env=VERSION="${VERSION}" \
80 "${IMAGE}" \
81 sh -euxc '
82 (
83 mkdir work
84 cd work
85 rpm -q autoconf automake
86 automake --version
87 autoconf --version
88 tar x
89 ./autogen.sh
90 make dist VERSION="${VERSION}"
91 ) >&2
92 tar -C work -c cockpit-"${VERSION}".tar.xz cockpit-node-"${VERSION}".tar.xz
93 ' \
94 | tar -xv
95
96 # Show the result.
97 sha256sum cockpit-"${VERSION}".tar.xz cockpit-node-"${VERSION}".tar.xz