# Detect which make is available
- MAKE=make
- which gmake 2>/dev/null >/dev/null && MAKE=gmake
- - $MAKE
+ - BRANCH=$CI_COMMIT_BRANCH $MAKE
- $MAKE check
# Build docs when tools are available
- if which linuxdoc pdflatex sgmlsasp >/dev/null ; then $MAKE docs ; fi
-build-only-doc:
+build-release:
image: registry.nic.cz/labs/bird:docbuilder
stage: build
tags:
- autoreconf
- ./configure --with-protocols= --disable-client
- make obj/doc/bird-singlepage.html
+ - BRANCH=$CI_COMMIT_BRANCH tools/make-archive
artifacts:
paths:
- obj/doc/bird-singlepage.html
- expire_in: 1 month
+ - bird-*.tar.gz
+ expire_in: 1 day
.build-linux: &build-linux
<<: *build-base
stage: pkg
script:
- pip3 install apkg
- - apkg build
+ - BRANCH=$CI_COMMIT_BRANCH ARCHIVE_DOCS=false apkg build
#- apkg install -y pkg/pkgs/*/*/*.deb
artifacts:
paths:
stage: pkg
script:
- pip3 install apkg
- - apkg build
+ - BRANCH=$CI_COMMIT_BRANCH ARCHIVE_DOCS=false apkg build
#- apkg install -y pkg/pkgs/*/*/*.rpm
artifacts:
paths:
script:
- sed -i "s/runstatedir/with-runtimedir/" distro/pkg/rpm/bird.spec
- pip3 install apkg
- - apkg build
+ - BRANCH=$CI_COMMIT_BRANCH ARCHIVE_DOCS=false apkg build
#- apkg install -y pkg/pkgs/*/*/*.rpm
artifacts:
paths:
- mkdir $BDIR
- cd $BDIR
- ../configure
- - make
+ - BRANCH=$CI_COMMIT_BRANCH make
artifacts:
paths:
- $BDIR/bird
# Makefile for the BIRD Internet Routing Daemon
# (c) 1999--2000 Martin Mares <mj@ucw.cz>
-# (c) 2016 Jan Moskyto Matejka <mq@ucw.cz>
+# (c) 2016--2025 Maria Matejka <mq@ucw.cz>
# Disable build-in rules
MAKEFLAGS += -r
objdir := @objdir@
exedir := @exedir@
-git-label:=$(strip $(shell cd $(srcdir) && [ "$$(git rev-parse --show-toplevel)" = "$$(readlink -f .)" ] && git describe --always --dirty=-x 2>/dev/null))
-ifneq ($(git-label),)
- CFLAGS += -DGIT_LABEL="$(git-label)"
-endif
+# Find out which version we are actually building
+VERSION := $(strip $(shell bash tools/version))
+CFLAGS += -DBIRD_VERSION='"$(VERSION)"'
ifeq ($(objdir),.)
objdir := $(realpath .)
apkg build -Hi
-tools/make-dev-archive script is in charge of creating archive from source.
+tools/make-archive script is in charge of creating archive from source.
## Create (source) package from upstream release
[project]
name = "bird"
# needed for make-archive
-make_archive_script = "tools/make-dev-archive"
+make_archive_script = "tools/make-archive"
[upstream]
# needed for get-archive
#ifndef _BIRD_CONFIG_H_
#define _BIRD_CONFIG_H_
-#define XSTR2(X) #X
-#define XSTR1(X) XSTR2(X)
-
/* BIRD version */
-#ifdef GIT_LABEL
-#define BIRD_VERSION XSTR1(GIT_LABEL)
-#else
-#define BIRD_VERSION "2.16"
+#ifndef BIRD_VERSION
+#error "BIRD_VERSION not defined"
#endif
+/* ... is a string literal at least of 4 characters */
+_Static_assert(sizeof(BIRD_VERSION) >= 4, BIRD_VERSION);
+_Static_assert(sizeof(BIRD_VERSION "") == sizeof(BIRD_VERSION), BIRD_VERSION);
+
/* Include parameters determined by configure script */
#include "sysdep/autoconf.h"
--- /dev/null
+#!/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)"
+
+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 misc 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
# This a modified version of gendist script which generates development
# archive (tarball) without docs from current sources.
-BIRD_VERSION=`grep 'BIRD_VERSION \"' sysdep/config.h | sed '/BIRD_VERSION/!d;s/^.*"\(.*\)"$/\1/'`
+BIRD_VERSION=$(bash tools/version)
# differentiate dev tarballs from upstream ones
GIT_HASH=$(git rev-parse --short HEAD )
TIMESTAMP=$(date -u +'%s' 2>/dev/null)
--- /dev/null
+#!/bin/bash
+
+TAG=$(git tag --merged | sed -n 's/^v//p' | tail -n1)
+
+# Pack with zeros if needed
+TM=$TAG
+while [ -n "${TM/*.*.*/}" ]; do
+ TM="${TM}.0"
+done
+
+if [ "$(git rev-parse HEAD)" == "$(git rev-parse v${TAG})" ]; then
+ echo $TM
+ exit 0
+fi
+
+HASH=$(git rev-parse --short=12 HEAD)
+
+# Add branch info if not passed via command line
+if [ -z "${BRANCH}" ]; then
+ # There is also --show-current but it's too new to be portable.
+ BRANCH=$(git branch | sed -n 's/^[*] //p' | grep -v 'HEAD detached')
+fi
+
+# Found a branch
+if [ -n "$BRANCH" ]; then
+ LENGTH=$(git log --oneline v$TAG..HEAD | wc -l)
+ echo $TM+branch.$(echo $BRANCH | sed 's/[^a-zA-Z0-9]/./g').${HASH}
+ exit 0
+fi
+
+echo $TM+detached.${HASH}
+exit 0