]> git.proxmox.com Git - mirror_frr.git/blame - debian/backports/rules
backports: minimize diffs with base debian files
[mirror_frr.git] / debian / backports / rules
CommitLineData
a8247b21
SM
1.PHONY: backports $(KNOWN_BACKPORTS)
2
3# error out if these files are missing
4required_files = $(foreach backport,$(KNOWN_BACKPORTS), \
5 $(addprefix debian/backports/$(backport)/, \
6 debian/source/format \
7 versionext \
8 exclude))
9$(if $(filter-out $(wildcard $(required_files)),$(required_files)), \
10 $(error missing required backports files: \
11 $(filter-out $(wildcard $(required_files)),$(required_files)). \
12 see debian/backports/README) \
13)
14
ee9d7744 15TARBALLDIR ?= $(shell dh_testdir debian/changelog && realpath .)
a8247b21
SM
16
17define backports-targets
18# if this file is empty, no automatic changelog entry is created
19VERSIONEXT_$(1) ?= $(strip \
20 $(shell cat $(wildcard debian/backports/$(1)/versionext)))
21DEBIAN_VERSION_$(1) = $(DEBIAN_VERSION)$$(VERSIONEXT_$(1))
22BACKPORTDIR_$(1) = $(realpath debian/backports/$(1))
23
24# as of right now, must be '3.0 (quilt)'
25SOURCEFORMAT_$(1) ?= $(strip \
26 $(shell cat debian/backports/$(1)/debian/source/format))
27
28# files checked for the dirhash (see below)
891a387c 29FINDCMD_$(1) = find -L debian/backports/$(1)/debian \
a8247b21
SM
30 -type f \
31 ! -path debian/backports/$(1)/debian/changelog
32
33# files *not* pulled from the root debian directory into the backport tarball:
34# debian/changelog (copied and edited for backport version entry)
35# debian/backports itself (relevant contents are copied out separately)
36# anything provided in the current backports debian dir
37# anything specified in the 'exclude' file in the current backports debian dir
38EXCLUDEROOT_$(1) = debian/changelog debian/backports \
39 $$(subst debian/backports/$(1)/,,$$(shell $$(FINDCMD_$(1)))) \
40 $$(shell cat debian/backports/$(1)/exclude)
41
42EXCLUDEROOT_TAR_$(1) = $$(foreach file,$$(EXCLUDEROOT_$(1)),--exclude $$(file))
43EXCLUDEROOT_FIND_$(1) = $$(foreach file,$$(EXCLUDEROOT_$(1)),-o -path $$(file))
44
45# find command resulting in all files that *will* be pulled into the backport
46# tarball.
891a387c 47FINDCMDROOT_$(1) = find -L debian/ \
a8247b21
SM
48 '(' -false $$(EXCLUDEROOT_FIND_$(1)) ')' -prune -o \
49 -type f -a '!' '(' -false $$(EXCLUDEROOT_FIND_$(1)) ')'
50
51# usually using `find' output for dependencies has the downfall of not tracking
52# file removal. Work around that by introducing a dependency on a file whose
53# name contains the hash of `find' output, so that the name will change when a
54# file is deleted.
55DIRHASH_$(1) = \
56 $$(shell $$(FINDCMD_$(1)) | sha1sum | sed -r 's/^(......).*/\1/')
57DIRHASHROOT_$(1) = \
58 $$(shell $$(FINDCMDROOT_$(1)) | sha1sum | sed -r 's/^(......).*/\1/')
59
60CONTROL_$(1) = $$(strip \
61 $$(if $$(wildcard $$(BACKPORTDIR_$(1))/debian/control), \
62 $$(BACKPORTDIR_$(1))/debian/control, \
63 $(realpath debian/control) \
64 ))
65
66# TARGETS:
67
68$(1): $(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).dsc ;
69
70# we use 3.0 (custom) to build a source package directly from tarballs,
71# bypassing the usual checks (which wouldn't like our combination-of-
72# directories approach)
73$(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).dsc:
ee9d7744
SM
74 # -b directory does nothing but determine will the .dsc will end up
75 # for the custom source format. Put it in the current directory by
76 # specifying one of its subdirs.
a8247b21
SM
77 dpkg-source -l$$(BACKPORTDIR_$(1))/debian/changelog \
78 -c$$(CONTROL_$(1)) \
79 --format='3.0 (custom)' \
80 --target-format='$$(SOURCEFORMAT_$(1))' \
ee9d7744 81 -b debian $$^
a8247b21
SM
82
83ifeq ($$(SOURCEFORMAT_$(1)),3.0 (quilt))
84# this target depends on the orig.tar.gz file, for which there is no target in
85# this makefile. It is assumed to either already exist or be built by a target
86# provided elsewhere in debian/rules (e.g. via pristine-tar)
47607bca 87$$(if $$(findstring $(ORIG_VERSION),$$(DEBIAN_VERSION_$(1))), \
88 $$(info downstream version matches upstream version (good)), \
89 $$(error quilt format expects downstream version \
90 ($$(DEBIAN_VERSION_$(1))) to contain upstream version \
91 ($(ORIG_VERSION)). Make a new debian/changelog entry \
92 to reflect the new upstream release) \
93)
94
a8247b21
SM
95$(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).dsc: \
96 $(TARBALLDIR)/$(SRCPKG)_$(ORIG_VERSION).orig.tar.gz \
97 $(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).debian.tar.xz
98else
99$$(error unsupported source format for $(1) backport: $$(SOURCEFORMAT_$(1)))
100endif #SOURCEFORMAT_$(1)
101
102# for 3.0 (quilt)
103$(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).debian.tar.xz: \
104 $$(BACKPORTDIR_$(1))/debian/changelog \
105 $$(shell $$(FINDCMD_$(1))) \
106 $$(BACKPORTDIR_$(1))/$$(DIRHASH_$(1)).backport.dirhash \
107 $$(shell $$(FINDCMDROOT_$(1))) \
108 $$(BACKPORTDIR_$(1))/$$(DIRHASHROOT_$(1)).root.dirhash \
109 $$(BACKPORTDIR_$(1))/exclude
110 rm -f $$(subst .tar.xz,.tar,$$@) $$@
891a387c 111 tar -chf $$(subst .tar.xz,.tar,$$@) \
a8247b21 112 --exclude-vcs $$(EXCLUDEROOT_TAR_$(1)) debian/
891a387c 113 cd debian/backports/$(1) && tar -uhf $$(subst .tar.xz,.tar,$$@) \
a8247b21
SM
114 --exclude-vcs debian/
115 xz $$(subst .tar.xz,.tar,$$@)
116
117$$(BACKPORTDIR_$(1))/debian/changelog: \
118 debian/changelog \
119 debian/backports/$(1)/versionext
120 rm -f debian/backports/$(1)/debian/changelog
121 cp $$< $$@
122 $(if $$(VERSIONEXT_$(1)), \
123 dch -c $$@ -v '$$(DEBIAN_VERSION_$(1))' -b \
124 'backport to $(1) systems', \
125 )
126
127$$(BACKPORTDIR_$(1))/$$(DIRHASH_$(1)).backport.dirhash:
128 rm -f debian/backports/$(1)/*.backport.dirhash
129 touch $$@
130
131$$(BACKPORTDIR_$(1))/$$(DIRHASHROOT_$(1)).root.dirhash:
132 rm -f debian/backports/$(1)/*.root.dirhash
133 touch $$@
134
135endef # backports-targets
136$(foreach backport,$(KNOWN_BACKPORTS),$(eval \
137 $(call backports-targets,$(backport))))
138
139backports: $(KNOWN_BACKPORTS)