source: trunk/debathena/debathena/config-package-dev/divert.mk @ 22961

Revision 22961, 4.5 KB checked in by tabbott, 16 years ago (diff)
In config-package-dev: * Move homepage field to source package section, so it works. * Make DEB_TRANSFROM_FILES targets depend on common-build-arch and common-build-indep, so it works with architecture-dependent packages. * Remove useless clean code from transform-files.mk. * Move divert.mk from binary-fixup to binary-post-install. * Add debhelper.mk to divert.mk, since we use its binary-post-install/package target. * Change maintainer to me, rather than debathena@mit.edu, since I'll be maintaining config-package-dev in Debian. * Upload to Debian (Closes: #469107)
RevLine 
[22854]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
[22961]23include /usr/share/cdbs/1/rules/debhelper.mk
24
[22923]25CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev (>= 4.5~)
[22854]26
27DEB_DIVERT_SCRIPT = /usr/share/config-package-dev/divert.sh.in
28
29DEB_DIVERT_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
[22923]30    $(if $(DEB_TRANSFORM_FILES_$(package)),$(package), \
[22918]31    $(if $(DEB_REMOVE_FILES_$(package)),$(package), \
32    $(if $(DEB_UNREMOVE_FILES_$(package)),$(package), \
33    $(if $(DEB_UNDIVERT_FILES_$(package)),$(package), \
34    $(if $(DEB_DIVERT_FILES_$(package)),$(package)))))))
[22854]35
36ifeq ($(DEB_DIVERT_EXTENSION),)
37DEB_DIVERT_EXTENSION = .divert
38endif
39
40DEB_DIVERT_ENCODER = /usr/share/config-package-dev/encode
41
[22918]42divert_files_replace_name = $(shell echo $(1) | perl -pe 's/(.*)\Q$(DEB_DIVERT_EXTENSION)\E/$$1$(2)/')
43
[22854]44debian-divert/%: package = $(subst debian-divert/,,$@)
[22923]45debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(DEB_TRANSFORM_FILES_$(package))
[22918]46debian-divert/%: divert_remove_files = $(DEB_REMOVE_FILES_$(package))
47debian-divert/%: divert_undivert_files = $(DEB_UNDIVERT_FILES_$(package))
48debian-divert/%: divert_unremove_files = $(DEB_UNREMOVE_FILES_$(package))
49debian-divert/%: divert_files_all = $(strip $(divert_files) $(divert_remove_files) $(divert_undivert_files) $(divert_unremove_files))
50debian-divert/%: divert_files_thispkg = $(strip $(divert_files) $(divert_remove_files))
[22854]51$(patsubst %,debian-divert/%,$(DEB_DIVERT_PACKAGES)) :: debian-divert/%:
52        ( \
53            sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
[22918]54            $(if $(divert_files_all), \
[22854]55                echo 'if [ "$$1" = "configure" ]; then'; \
[22918]56                $(foreach file,$(divert_undivert_files), \
[22923]57                    $(if $(DEB_UNDIVERT_VERSION_$(file)),,\
[22918]58                        echo "ERROR!  Missing undivert version for $(file)!">&2; exit 1;) \
59                    echo -n "    if [ -n \"\$$2\" ] && dpkg --compare-versions \"\$$2\" '<<' "; \
[22923]60                    echo "'$(DEB_UNDIVERT_VERSION_$(file))'; then"; \
[22918]61                    echo "        undivert_unlink $(call divert_files_replace_name,$(file), )"; \
62                    echo "    fi";) \
63                $(foreach file,$(divert_unremove_files), \
[22923]64                    $(if $(DEB_UNREMOVE_VERSION_$(file)),,\
[22918]65                        echo "ERROR!  Missing unremove version for $(file)!">&2; exit 1;) \
66                    echo -n "    if [ -n \"\$$2\" ] && dpkg --compare-versions \"\$$2\" '<<' "; \
[22923]67                    echo "'$(DEB_UNREMOVE_VERSION_$(file))'; then"; \
[22918]68                    echo "        undivert_unremove $(file)"; \
69                    echo "    fi";) \
[22854]70                $(foreach file,$(divert_files), \
[22918]71                    echo "    divert_link $(call divert_files_replace_name,$(file), )";) \
72                $(foreach file,$(divert_remove_files), \
73                    mkdir -p $(DEB_DESTDIR)/usr/share/$(cdbs_curpkg); \
74                    echo "    divert_remove $(file) /usr/share/$(cdbs_curpkg)/`$(DEB_DIVERT_ENCODER) $(file)`";) \
[22854]75                echo 'fi'; \
76            ) \
77        ) >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper
78        ( \
79            sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
[22918]80            $(if $(divert_files_thispkg), \
[22854]81                echo 'if [ "$$1" = "remove" ]; then'; \
82                $(foreach file,$(divert_files), \
[22918]83                    echo "    undivert_unlink $(call divert_files_replace_name,$(file), )";) \
84                $(foreach file,$(divert_remove_files), \
85                    echo "    undivert_unremove $(file) $(cdbs_curpkg)";) \
[22854]86                echo 'fi'; \
87            ) \
88        ) >> $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper
89        ( \
90            echo -n "diverted-files="; \
[22918]91            $(foreach file,$(divert_files_thispkg),\
92                echo -n "configures-"; \
93                ${DEB_DIVERT_ENCODER} "$(call divert_files_replace_name,$(file))"; \
[22854]94                echo -n ", ";) \
95            echo \
96        ) >> $(CURDIR)/debian/$(cdbs_curpkg).substvars
97
[22961]98$(patsubst %,binary-post-install/%,$(DEB_DIVERT_PACKAGES)) :: binary-post-install/%: debian-divert/%
[22854]99
100endif
Note: See TracBrowser for help on using the repository browser.