Something went wrong. Try again.
forked from cz-nic/bird
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117#!/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 informationVERSION="$($(dirname $0)/version | sed 's/^v//')"
SRCPKG="bird-${VERSION}"DOCPKG="bird-doc-${VERSION}"
if [ -z "$ARCHIVE_DOCS" ]; then ARCHIVE_DOCS=truefi
# Check that we are running on a clean repositoryif ! git diff-index --quiet HEAD || ! git diff-index --cached --quiet HEAD; then echo 'WARNING: git index has uncommitted changes!'fi
# Prepare a tempdirT=$(mktemp -d)function cleanup_tmpdir() { rm -rf $T}
trap cleanup_tmpdir EXIT
# Gather commit informationHEAD=$(git rev-parse HEAD)COMMIT_DATE=$(git show -q --pretty="format:%aD" HEAD)
# Reproducible archivefunction 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 archiveecho "Building $VERSION"git archive --format=tar --prefix="$SRCPKG/" HEAD -o $T/initial.tgz
# Generate changelogecho "Generating changelog"mkdir $T/$SRCPKGgit log > $T/$SRCPKG/ChangeLog
# Unpack the archivepushd $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