File: make-archive

package info (click to toggle)
bird2 2.18-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,644 kB
  • sloc: ansic: 75,250; sh: 3,807; perl: 3,444; lex: 887; xml: 520; makefile: 511; python: 495; sed: 13
file content (116 lines) | stat: -rwxr-xr-x 2,660 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/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

# Gather commit information
HEAD=$(git rev-parse HEAD)
COMMIT_DATE=$(git show -q --pretty="format:%aD" HEAD)

# Reproducible archive
function stabletgz() {
  tar --sort=name --format=posix \
    --pax-option=delete=atime,delete=ctime \
    --clamp-mtime --mtime="$COMMIT_DATE" \
    --numeric-owner --owner=0 --group=0 \
    --mode=go+u,go-w -cf - $2 | \
    gzip --no-name --best > $1
}

# 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"
  stabletgz $SRCPKG.tar.gz $SRCPKG

  if $ARCHIVE_DOCS; then
    # Generate documentation
    pushd $SRCPKG
      # Fix documentation in time
      sed -i "s#^<date></date>#<date>$COMMIT_DATE</date>#" doc/bird.sgml
      sed -i "s#^</documentid>#-$HEAD</documentid>#" doc/bird.sgml

      # Actually make it
      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"
    stabletgz $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