]> andersk Git - config-package-dev.git/blame - divert.mk
Fix bug where DEB_DIVERT code gets added twice if a package uses both DEB_DIVERT_FILE...
[config-package-dev.git] / divert.mk
CommitLineData
ab8e2a67
TA
1# -*- mode: makefile; coding: utf-8 -*-
2# Copyright © 2007-2008 Anders Kaseorg <andersk@mit.edu> and
3# Tim Abbott <tabbott@mit.edu>
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation; either version 2, or (at
8# your option) any later version.
9#
10# This program is distributed in the hope that it will be useful, but
11# WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18# 02111-1307 USA.
19
20ifndef _cdbs_rules_divert
21_cdbs_rules_divert = 1
22
23CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev
24
25DEB_DIVERT_SCRIPT = /usr/share/config-package-dev/divert.sh.in
26
27DEB_DIVERT_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
c5ca58a5
TA
28 $(if $(DEB_REPLACE_FILES_$(package)),$(package), \
29 $(if $(DEB_DIVERT_FILES_$(package)),$(package))))
ab8e2a67
TA
30
31ifeq ($(DEB_DIVERT_EXTENSION),)
32DEB_DIVERT_EXTENSION = .divert
33endif
34
35DEB_DIVERT_ENCODER = /usr/share/config-package-dev/encode
36
37debian-divert/%: package = $(subst debian-divert/,,$@)
38debian-divert/%: replace_inputs = $(DEB_REPLACE_FILES_$(package))
39debian-divert/%: replace_files = $(foreach file,$(replace_inputs),$(file))
40debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(replace_files)
41$(patsubst %,debian-divert/%,$(DEB_DIVERT_PACKAGES)) :: debian-divert/%:
42 ( \
43 sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
44 $(if $(divert_files), \
45 echo 'if [ "$$1" = "configure" ]; then'; \
46 $(foreach file,$(divert_files), \
47 echo " divert_link $(subst $(DEB_DIVERT_EXTENSION), ,$(file))";) \
48 echo 'fi'; \
49 ) \
50 ) >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper
51 ( \
52 sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
53 $(if $(divert_files), \
54 echo 'if [ "$$1" = "remove" ]; then'; \
55 $(foreach file,$(divert_files), \
56 echo " undivert_unlink $(subst $(DEB_DIVERT_EXTENSION), ,$(file))";) \
57 echo 'fi'; \
58 ) \
59 ) >> $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper
60 ( \
61 echo -n "diverted-files="; \
62 $(foreach file,$(divert_files),\
63 ${DEB_DIVERT_ENCODER} "$(subst $(DEB_DIVERT_EXTENSION),,$(file))"; \
64 echo -n ", ";) \
65 echo \
66 ) >> $(CURDIR)/debian/$(cdbs_curpkg).substvars
67
68$(patsubst %,binary-fixup/%,$(DEB_DIVERT_PACKAGES)) :: binary-fixup/%: debian-divert/%
69
70endif
This page took 0.148785 seconds and 5 git commands to generate.