From: Silas McCroskey Date: Tue, 14 Feb 2017 11:45:50 +0000 (+0700) Subject: debian: structure for building backports from a single branch X-Git-Tag: frr-3.0-rc3~1^2~47 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8e18f48ee5f980abf03d8df6a827811af81d4f5e;p=matthieu%2Ffrr.git debian: structure for building backports from a single branch Source a makefile (when it exists) in debian/rules to assemble a source package via: * a debian.tar.gz tarball built from combining the contents of debian/ and debian/backports/$backport/debian/ using other details under debian/backports/$backport * an orig.tar.gz file (not generated by this makefile). This can (and should) be the same for all backports. Details in debian/backports/README Signed-off-by: Silas McCroskey --- diff --git a/debian/backports/.gitignore b/debian/backports/.gitignore new file mode 100644 index 0000000000..3b20d26891 --- /dev/null +++ b/debian/backports/.gitignore @@ -0,0 +1,2 @@ +*/*.dirhash +*/debian/changelog diff --git a/debian/backports/README b/debian/backports/README new file mode 100644 index 0000000000..efd322e1d9 --- /dev/null +++ b/debian/backports/README @@ -0,0 +1,28 @@ +This directory contains the debian directories for backports to other debian +platforms. These are built via the `3.0 (custom)' source format, which +allows one to build a source package directly out of tarballs (e.g. an +orig.tar.gz tarball and a debian.tar.gz file), at which point the format can +be changed to a real format (e.g. `3.0 (quilt)'). + +Source packages are assembled via targets of the same name as the system to +which the backport is done (e.g. `precise'), included in debian/rules. + +To create a new debian backport: + +* Add its name to `KNOWN_BACKPORTS', defined in debian/rules. +* Create a directory of the same name in debian/backports. +* Add the files `exclude', `versionext', and `debian/source/format' under + this directory: + * `exclude' contains whitespace-separated paths (relative to the root of + the source dir) that should be excluded from the source package (e.g. + debian/patches). + * `versionext' contains the suffix added to the version number for this + backport's build. Distributions often have guidelines for what this + should be. If left empty, no new debian/changelog entry is created. + * `debian/source/format' should contain the source format of the resulting + source package. As of of the writing of this document the only supported + format is `3.0 (quilt)'. +* Add appropriate files under the `debian/' subdirectory. These will be + included in the source package, overriding any top-level `debian/' files + with equivalent paths. + diff --git a/debian/backports/rules b/debian/backports/rules new file mode 100644 index 0000000000..3b8699754f --- /dev/null +++ b/debian/backports/rules @@ -0,0 +1,129 @@ +.PHONY: backports $(KNOWN_BACKPORTS) + +# error out if these files are missing +required_files = $(foreach backport,$(KNOWN_BACKPORTS), \ + $(addprefix debian/backports/$(backport)/, \ + debian/source/format \ + versionext \ + exclude)) +$(if $(filter-out $(wildcard $(required_files)),$(required_files)), \ + $(error missing required backports files: \ + $(filter-out $(wildcard $(required_files)),$(required_files)). \ + see debian/backports/README) \ +) + +TARBALLDIR ?= $(shell dh_testdir debian/changelog && realpath ../) + +define backports-targets +# if this file is empty, no automatic changelog entry is created +VERSIONEXT_$(1) ?= $(strip \ + $(shell cat $(wildcard debian/backports/$(1)/versionext))) +DEBIAN_VERSION_$(1) = $(DEBIAN_VERSION)$$(VERSIONEXT_$(1)) +BACKPORTDIR_$(1) = $(realpath debian/backports/$(1)) + +# as of right now, must be '3.0 (quilt)' +SOURCEFORMAT_$(1) ?= $(strip \ + $(shell cat debian/backports/$(1)/debian/source/format)) + +# files checked for the dirhash (see below) +FINDCMD_$(1) = find debian/backports/$(1)/debian \ + -type f \ + ! -path debian/backports/$(1)/debian/changelog + +# files *not* pulled from the root debian directory into the backport tarball: +# debian/changelog (copied and edited for backport version entry) +# debian/backports itself (relevant contents are copied out separately) +# anything provided in the current backports debian dir +# anything specified in the 'exclude' file in the current backports debian dir +EXCLUDEROOT_$(1) = debian/changelog debian/backports \ + $$(subst debian/backports/$(1)/,,$$(shell $$(FINDCMD_$(1)))) \ + $$(shell cat debian/backports/$(1)/exclude) + +EXCLUDEROOT_TAR_$(1) = $$(foreach file,$$(EXCLUDEROOT_$(1)),--exclude $$(file)) +EXCLUDEROOT_FIND_$(1) = $$(foreach file,$$(EXCLUDEROOT_$(1)),-o -path $$(file)) + +# find command resulting in all files that *will* be pulled into the backport +# tarball. +FINDCMDROOT_$(1) = find debian/ \ + '(' -false $$(EXCLUDEROOT_FIND_$(1)) ')' -prune -o \ + -type f -a '!' '(' -false $$(EXCLUDEROOT_FIND_$(1)) ')' + +# usually using `find' output for dependencies has the downfall of not tracking +# file removal. Work around that by introducing a dependency on a file whose +# name contains the hash of `find' output, so that the name will change when a +# file is deleted. +DIRHASH_$(1) = \ + $$(shell $$(FINDCMD_$(1)) | sha1sum | sed -r 's/^(......).*/\1/') +DIRHASHROOT_$(1) = \ + $$(shell $$(FINDCMDROOT_$(1)) | sha1sum | sed -r 's/^(......).*/\1/') + +CONTROL_$(1) = $$(strip \ + $$(if $$(wildcard $$(BACKPORTDIR_$(1))/debian/control), \ + $$(BACKPORTDIR_$(1))/debian/control, \ + $(realpath debian/control) \ + )) + +# TARGETS: + +$(1): $(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).dsc ; + +# we use 3.0 (custom) to build a source package directly from tarballs, +# bypassing the usual checks (which wouldn't like our combination-of- +# directories approach) +$(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).dsc: + # -b directory unused (but required) for '3.0 (custom)' source format + dpkg-source -l$$(BACKPORTDIR_$(1))/debian/changelog \ + -c$$(CONTROL_$(1)) \ + --format='3.0 (custom)' \ + --target-format='$$(SOURCEFORMAT_$(1))' \ + --build . $$^ + +ifeq ($$(SOURCEFORMAT_$(1)),3.0 (quilt)) +# this target depends on the orig.tar.gz file, for which there is no target in +# this makefile. It is assumed to either already exist or be built by a target +# provided elsewhere in debian/rules (e.g. via pristine-tar) +$(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).dsc: \ + $(TARBALLDIR)/$(SRCPKG)_$(ORIG_VERSION).orig.tar.gz \ + $(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).debian.tar.xz +else +$$(error unsupported source format for $(1) backport: $$(SOURCEFORMAT_$(1))) +endif #SOURCEFORMAT_$(1) + +# for 3.0 (quilt) +$(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).debian.tar.xz: \ + $$(BACKPORTDIR_$(1))/debian/changelog \ + $$(shell $$(FINDCMD_$(1))) \ + $$(BACKPORTDIR_$(1))/$$(DIRHASH_$(1)).backport.dirhash \ + $$(shell $$(FINDCMDROOT_$(1))) \ + $$(BACKPORTDIR_$(1))/$$(DIRHASHROOT_$(1)).root.dirhash \ + $$(BACKPORTDIR_$(1))/exclude + rm -f $$(subst .tar.xz,.tar,$$@) $$@ + tar -cf $$(subst .tar.xz,.tar,$$@) \ + --exclude-vcs $$(EXCLUDEROOT_TAR_$(1)) debian/ + cd debian/backports/$(1) && tar -uf $$(subst .tar.xz,.tar,$$@) \ + --exclude-vcs debian/ + xz $$(subst .tar.xz,.tar,$$@) + +$$(BACKPORTDIR_$(1))/debian/changelog: \ + debian/changelog \ + debian/backports/$(1)/versionext + rm -f debian/backports/$(1)/debian/changelog + cp $$< $$@ + $(if $$(VERSIONEXT_$(1)), \ + dch -c $$@ -v '$$(DEBIAN_VERSION_$(1))' -b \ + 'backport to $(1) systems', \ + ) + +$$(BACKPORTDIR_$(1))/$$(DIRHASH_$(1)).backport.dirhash: + rm -f debian/backports/$(1)/*.backport.dirhash + touch $$@ + +$$(BACKPORTDIR_$(1))/$$(DIRHASHROOT_$(1)).root.dirhash: + rm -f debian/backports/$(1)/*.root.dirhash + touch $$@ + +endef # backports-targets +$(foreach backport,$(KNOWN_BACKPORTS),$(eval \ + $(call backports-targets,$(backport)))) + +backports: $(KNOWN_BACKPORTS) diff --git a/debian/rules b/debian/rules index 5744505e64..8a13b1bcea 100755 --- a/debian/rules +++ b/debian/rules @@ -100,3 +100,22 @@ override_dh_systemd_start: override_dh_systemd_enable: dh_systemd_enable frr.service +# backports +SRCPKG = frr +KNOWN_BACKPORTS = ubuntu12.04 ubuntu14.04 ubuntu16.04 +ORIG_VERSION := $(shell dh_testdir && grep -E < configure.ac '^AC_INIT\(.*\)' \ + | cut -d, -f2 | xargs echo) +DEBIAN_VERSION := $(shell dh_testdir && \ + dpkg-parsechangelog -c1 -Sversion < debian/changelog) +-include debian/backports/rules + +ifneq ($(TARBALLDIR),) +# better error message on missing .orig.tar.gz +$(TARBALLDIR)/$(SRCPKG)_$(ORIG_VERSION).orig.tar.gz: + @ echo "\`$(TARBALLDIR)/$(SRCPKG)_$(ORIG_VERSION).orig.tar.gz'" not + found and not generated by debian/rules. Provided you have the \ + necessary packages installed, you can generate it yourself via \ + "\"./bootstrap.sh && ./configure && make dist\"" \ + and renaming the resulting file. + exit 1 +endif # def TARBALLDIR diff --git a/debian/rules.orig b/debian/rules.orig new file mode 100755 index 0000000000..42c0d5f63a --- /dev/null +++ b/debian/rules.orig @@ -0,0 +1,98 @@ +#!/usr/bin/make -f + +export DH_VERBOSE=1 +export DEB_BUILD_HARDENING=1 +export DH_OPTIONS=-v + +ifeq ($(WANT_SNMP), 1) + USE_SNMP=--enable-snmp + $(warning "DEBIAN: SNMP enabled, sorry for your inconvenience") +else + $(warning "DEBIAN: SNMP disabled, see README.Debian") +endif + +ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + DEBIAN_JOBS := $(subst parallel=,,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) +endif + +ifdef DEBIAN_JOBS +MAKEFLAGS += -j$(DEBIAN_JOBS) +endif + +%: + dh $@ --with=systemd,autoreconf --parallel --dbg-package=frr-dbg --list-missing + +override_dh_auto_configure: + # Frr needs /proc to check some BSD vs Linux specific stuff. + # Else it fails with an obscure error message pointing out that + # IPCTL_FORWARDING is an undefined symbol which is not very helpful. + @if ! [ -d /proc/1 ]; then \ + echo "./configure needs a mounted /proc"; \ + exit 1; \ + fi + + if ! [ -e config.status ]; then \ + dh_auto_configure -- \ + --enable-exampledir=/usr/share/doc/frr/examples/ \ + --localstatedir=/var/run/frr \ + --sbindir=/usr/lib/frr \ + --sysconfdir=/etc/frr \ + $(USE_SNMP) \ + --enable-ospfapi=yes \ + --enable-vtysh=yes \ + --enable-isisd=yes \ + --enable-multipath=256 \ + --enable-user=frr \ + --enable-group=frr \ + --enable-vty-group=frrvty \ + --enable-configfile-mask=0640 \ + --enable-logfile-mask=0640 \ + --enable-werror \ + --enable-gcc-rdynamic \ + --with-libpam \ + --enable-systemd=yes \ + --enable-poll=yes \ + --enable-cumulus=yes \ + --enable-pimd=yes \ + --enable-dependency-tracking \ + --enable-bgp-vnc=no; \ + fi + +override_dh_auto_build: + #dh_auto_build + $(MAKE) + dh_auto_build -- -C doc draft-zebra-00.txt + + + # doc/ is a bit crazy +ifeq ($(GENERATE_PDF), 1) + dh_auto_build -- -C doc frr.pdf || true # pdfetex fails with exit code 1 but still produces a good looking .pdf +endif + rm -vf doc/frr.info + dh_auto_build -- -C doc frr.info + rm -vf doc/frr.info.html* + +override_dh_auto_test: + +override_dh_auto_install: + dh_auto_install + + # cleaning up the info dir + rm -f debian/tmp/usr/share/info/dir* + + # install config files + mkdir -p debian/tmp/etc/frr/ + perl -pi -e 's#^!log file #!log file /var/log/frr/#' debian/tmp/usr/share/doc/frr/examples/*sample* + + # installing the Frr specific SNMP MIB + install -D -m 644 ./zebra/GNOME-PRODUCT-ZEBRA-MIB debian/tmp/usr/share/snmp/mibs/GNOME-PRODUCT-ZEBRA-MIB + + # cleaning .la files + sed -i "/dependency_libs/ s/'.*'/''/" debian/tmp/usr/lib/*.la + +override_dh_systemd_start: + dh_systemd_start frr.service + +override_dh_systemd_enable: + dh_systemd_enable frr.service +