From: Anders Kaseorg Date: Sat, 6 Nov 2010 23:20:29 +0000 (+0000) Subject: * Fix a quoting bug that failed to disallow transformation of generated X-Git-Tag: 4.12~4 X-Git-Url: http://andersk.mit.edu/gitweb/config-package-dev.git/commitdiff_plain/50bf756320b9f47d119ed9524a0d7969e5e2c90f * 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.) git-svn-id: svn+ssh://svn.mit.edu/athena/trunk/debathena/debathena/config-package-dev@24906 728af825-273c-0410-89f9-f7d3b574a069 --- diff --git a/check-files.mk b/check-files.mk index e7e2ca6..70a5820 100644 --- a/check-files.mk +++ b/check-files.mk @@ -63,7 +63,7 @@ $(call debian_check_files_tmp,%): name = $(call debian_check_files_check,$(targe $(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; \ diff --git a/config-package.mk b/config-package.mk index 2f67112..eed82e6 100644 --- a/config-package.mk +++ b/config-package.mk @@ -85,24 +85,17 @@ # 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 diff --git a/debian/changelog b/debian/changelog index e11d49f..685a7ec 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,12 +1,20 @@ 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 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 Sat, 06 Nov 2010 19:02:52 -0400 config-package-dev (4.11) unstable; urgency=low diff --git a/divert.mk b/divert.mk index 7324bd4..ffa4d31 100644 --- a/divert.mk +++ b/divert.mk @@ -53,6 +53,10 @@ endif # 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)) @@ -70,24 +74,14 @@ $(patsubst %,debian-divert/%,$(DEB_DIVERT_PACKAGES)) :: debian-divert/%: $(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 diff --git a/divert.sh.in b/divert.sh.in index b705812..7e7659e 100644 --- a/divert.sh.in +++ b/divert.sh.in @@ -107,3 +107,27 @@ undivert_unremove() 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 +} diff --git a/examples/debathena-bin-example-1.1/debian/rules b/examples/debathena-bin-example-1.1/debian/rules index 50a8249..7a21914 100755 --- a/examples/debathena-bin-example-1.1/debian/rules +++ b/examples/debathena-bin-example-1.1/debian/rules @@ -13,12 +13,11 @@ DEB_DIVERT_FILES_debathena-bin-example += /usr/share/man/man1/less.debathena.1.g 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