]> andersk Git - config-package-dev.git/blob - divert.mk
Initial import of the config-package-dev system.
[config-package-dev.git] / divert.mk
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
20 ifndef _cdbs_rules_divert
21 _cdbs_rules_divert = 1
22
23 CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev
24
25 DEB_DIVERT_SCRIPT = /usr/share/config-package-dev/divert.sh.in
26
27 DEB_DIVERT_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
28     $(if $(DEB_DIVERT_FILES_$(package)),$(package)))
29
30 DEB_DIVERT_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
31     $(if $(DEB_REPLACE_FILES_$(package)),$(package)))
32
33 ifeq ($(DEB_DIVERT_EXTENSION),)
34 DEB_DIVERT_EXTENSION = .divert
35 endif
36
37 DEB_DIVERT_ENCODER = /usr/share/config-package-dev/encode
38
39 debian-divert/%: package = $(subst debian-divert/,,$@)
40 debian-divert/%: replace_inputs = $(DEB_REPLACE_FILES_$(package))
41 debian-divert/%: replace_files = $(foreach file,$(replace_inputs),$(file))
42 debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(replace_files)
43 $(patsubst %,debian-divert/%,$(DEB_DIVERT_PACKAGES)) :: debian-divert/%:
44         ( \
45             sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
46             $(if $(divert_files), \
47                 echo 'if [ "$$1" = "configure" ]; then'; \
48                 $(foreach file,$(divert_files), \
49                     echo "    divert_link $(subst $(DEB_DIVERT_EXTENSION), ,$(file))";) \
50                 echo 'fi'; \
51             ) \
52         ) >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper
53         ( \
54             sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
55             $(if $(divert_files), \
56                 echo 'if [ "$$1" = "remove" ]; then'; \
57                 $(foreach file,$(divert_files), \
58                     echo "    undivert_unlink $(subst $(DEB_DIVERT_EXTENSION), ,$(file))";) \
59                 echo 'fi'; \
60             ) \
61         ) >> $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper
62         ( \
63             echo -n "diverted-files="; \
64             $(foreach file,$(divert_files),\
65                 ${DEB_DIVERT_ENCODER} "$(subst $(DEB_DIVERT_EXTENSION),,$(file))"; \
66                 echo -n ", ";) \
67             echo \
68         ) >> $(CURDIR)/debian/$(cdbs_curpkg).substvars
69
70 $(patsubst %,binary-fixup/%,$(DEB_DIVERT_PACKAGES)) :: binary-fixup/%: debian-divert/%
71
72 endif
This page took 0.228893 seconds and 5 git commands to generate.