]> git.proxmox.com Git - mirror_frr.git/blob - debian/backports/rules
backports: symlink identical files
[mirror_frr.git] / debian / backports / rules
1 .PHONY: backports $(KNOWN_BACKPORTS)
2
3 # error out if these files are missing
4 required_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
15 TARBALLDIR ?= $(shell dh_testdir debian/changelog && realpath .)
16
17 define backports-targets
18 # if this file is empty, no automatic changelog entry is created
19 VERSIONEXT_$(1) ?= $(strip \
20 $(shell cat $(wildcard debian/backports/$(1)/versionext)))
21 DEBIAN_VERSION_$(1) = $(DEBIAN_VERSION)$$(VERSIONEXT_$(1))
22 BACKPORTDIR_$(1) = $(realpath debian/backports/$(1))
23
24 # as of right now, must be '3.0 (quilt)'
25 SOURCEFORMAT_$(1) ?= $(strip \
26 $(shell cat debian/backports/$(1)/debian/source/format))
27
28 # files checked for the dirhash (see below)
29 FINDCMD_$(1) = find -L debian/backports/$(1)/debian \
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
38 EXCLUDEROOT_$(1) = debian/changelog debian/backports \
39 $$(subst debian/backports/$(1)/,,$$(shell $$(FINDCMD_$(1)))) \
40 $$(shell cat debian/backports/$(1)/exclude)
41
42 EXCLUDEROOT_TAR_$(1) = $$(foreach file,$$(EXCLUDEROOT_$(1)),--exclude $$(file))
43 EXCLUDEROOT_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.
47 FINDCMDROOT_$(1) = find -L debian/ \
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.
55 DIRHASH_$(1) = \
56 $$(shell $$(FINDCMD_$(1)) | sha1sum | sed -r 's/^(......).*/\1/')
57 DIRHASHROOT_$(1) = \
58 $$(shell $$(FINDCMDROOT_$(1)) | sha1sum | sed -r 's/^(......).*/\1/')
59
60 CONTROL_$(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:
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.
77 dpkg-source -l$$(BACKPORTDIR_$(1))/debian/changelog \
78 -c$$(CONTROL_$(1)) \
79 --format='3.0 (custom)' \
80 --target-format='$$(SOURCEFORMAT_$(1))' \
81 -b debian $$^
82
83 ifeq ($$(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)
87 $(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).dsc: \
88 $(TARBALLDIR)/$(SRCPKG)_$(ORIG_VERSION).orig.tar.gz \
89 $(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).debian.tar.xz
90 else
91 $$(error unsupported source format for $(1) backport: $$(SOURCEFORMAT_$(1)))
92 endif #SOURCEFORMAT_$(1)
93
94 # for 3.0 (quilt)
95 $(TARBALLDIR)/$(SRCPKG)_$$(DEBIAN_VERSION_$(1)).debian.tar.xz: \
96 $$(BACKPORTDIR_$(1))/debian/changelog \
97 $$(shell $$(FINDCMD_$(1))) \
98 $$(BACKPORTDIR_$(1))/$$(DIRHASH_$(1)).backport.dirhash \
99 $$(shell $$(FINDCMDROOT_$(1))) \
100 $$(BACKPORTDIR_$(1))/$$(DIRHASHROOT_$(1)).root.dirhash \
101 $$(BACKPORTDIR_$(1))/exclude
102 rm -f $$(subst .tar.xz,.tar,$$@) $$@
103 tar -chf $$(subst .tar.xz,.tar,$$@) \
104 --exclude-vcs $$(EXCLUDEROOT_TAR_$(1)) debian/
105 cd debian/backports/$(1) && tar -uhf $$(subst .tar.xz,.tar,$$@) \
106 --exclude-vcs debian/
107 xz $$(subst .tar.xz,.tar,$$@)
108
109 $$(BACKPORTDIR_$(1))/debian/changelog: \
110 debian/changelog \
111 debian/backports/$(1)/versionext
112 rm -f debian/backports/$(1)/debian/changelog
113 cp $$< $$@
114 $(if $$(VERSIONEXT_$(1)), \
115 dch -c $$@ -v '$$(DEBIAN_VERSION_$(1))' -b \
116 'backport to $(1) systems', \
117 )
118
119 $$(BACKPORTDIR_$(1))/$$(DIRHASH_$(1)).backport.dirhash:
120 rm -f debian/backports/$(1)/*.backport.dirhash
121 touch $$@
122
123 $$(BACKPORTDIR_$(1))/$$(DIRHASHROOT_$(1)).root.dirhash:
124 rm -f debian/backports/$(1)/*.root.dirhash
125 touch $$@
126
127 endef # backports-targets
128 $(foreach backport,$(KNOWN_BACKPORTS),$(eval \
129 $(call backports-targets,$(backport))))
130
131 backports: $(KNOWN_BACKPORTS)