Debian Codegraph @

tools/make-dist

raw
1 #!/bin/sh
2
3 set -eu
4 ROOT_DIR=$(realpath -m "$0"/../..)
5 cd "$ROOT_DIR"
6
7 message() { printf " %-8s %s\n" "$1" "$2" >&2; }
8
9 # Set the version number from the state at the time the build was requested
10 VERSION="$(git describe --tags --long --dirty=.dirty | sed 's/-\([0-9]*\)-g/.dev\1+g/')"
11
12 while [ $# != 0 ] ; do
13 case "$1" in
14 *=*)
15 break;;
16 *)
17 echo "usage: $0 [MAKE_VAR=VALUE...]" >&2
18 exit 1
19 esac
20 shift
21 done
22
23 # NB: only the filename of the tarball should be written to stdout.
24 # Everything else should go to stderr.
25
26 # autogen, if not already done
27 if [ ! configure -nt configure.ac ]; then
28 message AUTOGEN 'configure, Makefile.in'
29 # Unfortunately there's no better way to silence this
30 NOCONFIGURE=1 ./autogen.sh >/dev/null 2>&1
31 fi
32
33 # If we have a configured tree, use it to build the tarball. Otherwise, create
34 # a temporary directory and configure it with a minimal config to build the
35 # tarball.
36 if [ -f Makefile ]; then
37 :
38 else
39 builddir='tmp/build-dist'
40 rm -rf "${builddir}"
41 mkdir -p "${builddir}"
42 cd "${builddir}"
43 message CONFIG "${builddir}/Makefile"
44 ../../configure \
45 CPPFLAGS=-I../../tools/mock-build-env \
46 PKG_CONFIG_PATH=../../tools/mock-build-env \
47 --enable-prefix-only \
48 > /dev/null
49 fi
50
51 # Do the actual build; dist creates both the main and node runtime tarballs
52 make -s -j"$(nproc)" XZ_OPT='-0' VERSION="${VERSION}" "$@" dist >&2
53
54 # Output tarball paths to stdout (only)
55 realpath "cockpit-${VERSION}.tar.xz"
56 realpath "cockpit-node-${VERSION}.tar.xz"