$(call debian_check_files_tmp,%): truename = $(shell /usr/sbin/dpkg-divert --truename $(name))
$(call debian_check_files_tmp,%): package = $(shell dpkg -S $(name) | grep -v "^diversion by" | cut -f1 -d:)
$(call debian_check_files_tmp,%): $(truename)
- [ -n $(package) ]
+ [ -n "$(package)" ]
mkdir -p $(@D)
cp "$(truename)" $@
set -e; \
# DEB_DIVERT_FILES.
#
# DEB_UNDIVERT_FILES_package += /path/file.divert
-# DEB_UNDIVERT_VERSION_/path/file.divert = 1.0-1
#
# List of absolute paths to files whose diversions caused by
-# DEB_DIVERT_FILES are to be removed upon installing this package.
-# This is primarily useful for removing a now-unecessary diversion
-# provided by a previous version of this package on an upgrade.
-#
-# The DEB_UNDIVERT_VERSION_file variable should be set to the
-# version number of this package at which you added
-# DEB_UNDIVERT_FILES_path/file.divert; it is used to avoid attempting
-# to remove the diversions again on future upgrades.
+# DEB_DIVERT_FILES are to be removed upon installing this package, if
+# the diversions have been made on the target system. This is
+# primarily useful for removing a now-unecessary diversion provided by
+# a previous version of this package on an upgrade.
#
# DEB_UNREMOVE_FILES_package += /path/file
-# DEB_UNREMOVE_VERSION_/path/file = 1.0-1
#
# This works like DEB_UNDIVERT_FILES_package, except that it only
-# removes the diversion (not a symlink) and the version number is
-# specified with DEB_UNREMOVE_VERSION_/path/file.
+# removes the diversion (not a symlink).
ifndef _cdbs_rules_config_package
_cdbs_rules_config_package = 1
config-package-dev (4.12) unstable; urgency=low
+ [ Tim Abbott ]
* Allow specifying DEB_TRANSFORM_SCRIPT_$package_$file in case you want
multiple binary packages transforming the same file differently.
(Thanks to Evan Broder for this patch).
* Add a decode script for undoing the file to virtual package name
transformation. (Thanks to Patrick Hurst for writing decode).
- -- Tim Abbott <tabbott@mit.edu> Sun, 09 May 2010 14:14:50 -0400
+ [ Anders Kaseorg ]
+ * Fix a quoting bug that failed to disallow transformation of generated
+ conffiles. (Patch from Evan Broder.)
+ * Remove DEB_UNDIVERT_VERSION_file and DEB_UNREMOVE_VERSION_file, and
+ instead test for the undiverted file in the postinst. (Patch from
+ Evan Broder.)
+
+ -- Anders Kaseorg <andersk@mit.edu> Sat, 06 Nov 2010 19:02:52 -0400
config-package-dev (4.11) unstable; urgency=low
# foo.divert.divert-orig
divert_files_replace_name = $(shell echo $(1) | perl -pe 's/(.*)\Q$(DEB_DIVERT_EXTENSION)\E/$$1$(2)/')
+# Transform a full path into the path it should be diverted to if it's
+# removed
+remove_files_name = /usr/share/$(cdbs_curpkg)/$(shell $(DEB_DIVERT_ENCODER) $(1))
+
debian-divert/%: package = $(subst debian-divert/,,$@)
debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(DEB_TRANSFORM_FILES_$(package))
debian-divert/%: divert_remove_files = $(DEB_REMOVE_FILES_$(package))
$(if $(divert_files_all), \
echo 'if [ "$$1" = "configure" ]; then'; \
$(foreach file,$(divert_undivert_files), \
- $(if $(DEB_UNDIVERT_VERSION_$(file)),,\
- echo "ERROR! Missing undivert version for $(file)!">&2; exit 1;) \
- echo -n " if [ -n \"\$$2\" ] && dpkg --compare-versions \"\$$2\" '<<' "; \
- echo "'$(DEB_UNDIVERT_VERSION_$(file))'; then"; \
- echo " undivert_unlink $(call divert_files_replace_name,$(file), )"; \
- echo " fi";) \
+ echo " check_undivert_unlink $(call divert_files_replace_name,$(file), )"; )\
$(foreach file,$(divert_unremove_files), \
- $(if $(DEB_UNREMOVE_VERSION_$(file)),,\
- echo "ERROR! Missing unremove version for $(file)!">&2; exit 1;) \
- echo -n " if [ -n \"\$$2\" ] && dpkg --compare-versions \"\$$2\" '<<' "; \
- echo "'$(DEB_UNREMOVE_VERSION_$(file))'; then"; \
- echo " undivert_unremove $(file)"; \
- echo " fi";) \
+ echo " check_undivert_unremove $(file) $(call remove_files_name,$(file))"; )\
$(foreach file,$(divert_files), \
echo " divert_link $(call divert_files_replace_name,$(file), )";) \
$(foreach file,$(divert_remove_files), \
mkdir -p debian/$(cdbs_curpkg)/usr/share/$(cdbs_curpkg); \
- echo " divert_remove $(file) /usr/share/$(cdbs_curpkg)/`$(DEB_DIVERT_ENCODER) $(file)`";) \
+ echo " divert_remove $(file) $(call remove_files_name,$(file))";) \
echo 'fi'; \
) \
} >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper
undivert_unlink_divert "$file"
}
+check_undivert_unlink()
+{
+ prefix=$1
+ suffix=$2
+
+ file=$prefix$suffix
+ ourfile=$prefix$ours$suffix
+ theirfile=$prefix$theirs$suffix
+
+ if dpkg-divert --list "$package" | \
+ grep -xFq "diversion of $file to $theirfile by $package"; then
+ undivert_unlink "$prefix" "$suffix"
+ fi
+}
+
+check_undivert_unremove()
+{
+ file=$1
+ removedfile=$2
+ if dpkg-divert --list "$package" | \
+ grep -xFq "diversion of $file to $removedfile by $package"; then
+ undivert_unremove "$file"
+ fi
+}
DEB_DH_LINK_debathena-bin-example += \
/usr/share/man/man1/less.debathena-orig.1.gz /usr/share/man/man1/less.debathena.1.gz
-# Remove elinks diversion on upgrade from version(s) prior to 1.1
+# Remove elinks diversion on upgrade if it was previously in place on
+# the target system
DEB_UNDIVERT_FILES_debathena-bin-example += /usr/bin/elinks.debathena
-DEB_UNDIVERT_VERSION_/usr/bin/elinks.debathena = 1.1
# and the man page
DEB_UNDIVERT_FILES_debathena-bin-example += /usr/share/man/man1/elinks.debathena.1.gz
-DEB_UNDIVERT_VERSION_/usr/share/man/man1/elinks.debathena.1.gz = 1.1
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/config-package.mk