File: make-archive

package info (click to toggle)
bird2 2.17.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,584 kB
  • sloc: ansic: 74,910; sh: 3,712; perl: 3,444; lex: 883; python: 495; makefile: 464; xml: 260; sed: 13
file content (97 lines) | stat: -rwxr-xr-x 2,067 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#
#	Generate BIRD distribution tgz
#
#	(c) 2025 CZ.NIC
#
#	Based on an older script by Martin Mares and Ondrej Filip
#	and another one by Jakub Ruzicka and Ondrej Zajicek

set -e

# Gather all required information
VERSION="$($(dirname $0)/version | sed 's/^v//')"

SRCPKG="bird-${VERSION}"
DOCPKG="bird-doc-${VERSION}"

if [ -z "$ARCHIVE_DOCS" ]; then
  ARCHIVE_DOCS=true
fi

# Check that we are running on a clean repository
if ! git diff-index --quiet HEAD || ! git diff-index --cached --quiet HEAD; then
  echo 'WARNING: git index has uncommitted changes!'
fi

# Prepare a tempdir
T=$(mktemp -d)
function cleanup_tmpdir() {
  rm -rf $T
}

trap cleanup_tmpdir EXIT

# Create a preliminary archive
echo "Building $VERSION"
git archive --format=tar --prefix="$SRCPKG/" HEAD -o $T/initial.tgz

# Generate changelog
echo "Generating changelog"
mkdir $T/$SRCPKG
git log > $T/$SRCPKG/ChangeLog

# Unpack the archive
pushd $T
  tar xf initial.tgz
  pushd $SRCPKG

    # Omit historical documents
    rm -rf rfc doc/slides doc/slt2001 doc/old bird.conf

    # Fix the version string
    sed -i 's/^VERSION := .*/VERSION := '${VERSION}'/' Makefile.in

    # Run autoconf
    echo "Running autoreconf"
    autoreconf -i
    rm -rf autom4te*cache

  popd

  # Pack sources
  echo "Packing source package"
  tar czf $SRCPKG.tar.gz $SRCPKG

  if $ARCHIVE_DOCS; then
    # Generate documentation
    pushd $SRCPKG
      echo "Creating documentation"
      (./configure --with-protocols= --disable-client && make docs) > build.log 2>build.err || (
	echo "======== Build log ========"
	cat build.log
	echo "======== Error log ========"
	cat build.err
	echo "If you wish to not build documentation, set env ARCHIVE_DOCS=false"
	false
      )
    popd

    mkdir ${DOCPKG}{,/doc}
    cp $SRCPKG/obj/doc/*.{html,pdf} ${DOCPKG}/doc

    # Pack sources
    echo "Packing docs package"
    tar czf $DOCPKG.tar.gz $DOCPKG
  else
    echo "Skipping documentation build"
  fi

popd

if $ARCHIVE_DOCS; then
  mv $T/$DOCPKG.tar.gz .
fi

mv $T/$SRCPKG.tar.gz .
echo $SRCPKG.tar.gz