File: make-dist

package info (click to toggle)
cockpit 355-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 311,568 kB
  • sloc: javascript: 774,787; python: 40,655; ansic: 35,157; cpp: 11,141; sh: 3,512; makefile: 580; xml: 261
file content (56 lines) | stat: -rwxr-xr-x 1,593 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh

set -eu
ROOT_DIR=$(realpath -m "$0"/../..)
cd "$ROOT_DIR"

message() { printf "  %-8s %s\n" "$1" "$2" >&2; }

# Set the version number from the state at the time the build was requested
VERSION="$(git describe --tags --long --dirty=.dirty | sed 's/-\([0-9]*\)-g/.dev\1+g/')"

while [ $# != 0 ] ; do
    case "$1" in
        *=*)
            break;;
        *)
            echo "usage: $0 [MAKE_VAR=VALUE...]" >&2
            exit 1
    esac
    shift
done

# NB: only the filename of the tarball should be written to stdout.
# Everything else should go to stderr.

# autogen, if not already done
if [ ! configure -nt configure.ac ]; then
    message AUTOGEN 'configure, Makefile.in'
    # Unfortunately there's no better way to silence this
    NOCONFIGURE=1 ./autogen.sh >/dev/null 2>&1
fi

# If we have a configured tree, use it to build the tarball.  Otherwise, create
# a temporary directory and configure it with a minimal config to build the
# tarball.
if [ -f Makefile ]; then
    :
else
    builddir='tmp/build-dist'
    rm -rf "${builddir}"
    mkdir -p "${builddir}"
    cd "${builddir}"
    message CONFIG "${builddir}/Makefile"
    ../../configure \
        CPPFLAGS=-I../../tools/mock-build-env \
        PKG_CONFIG_PATH=../../tools/mock-build-env \
        --enable-prefix-only \
        > /dev/null
fi

# Do the actual build; dist creates both the main and node runtime tarballs
make -s -j"$(nproc)" XZ_OPT='-0' VERSION="${VERSION}" "$@" dist >&2

# Output tarball paths to stdout (only)
realpath "cockpit-${VERSION}.tar.xz"
realpath "cockpit-node-${VERSION}.tar.xz"