Ticket #867: c-p-d-867.diff
File c-p-d-867.diff, 5.7 KB (added by jdreed, 11 years ago) |
---|
-
divert.sh.in
19 19 ours=#DEB_DIVERT_EXTENSION# 20 20 theirs=#DEB_DIVERT_EXTENSION#-orig 21 21 22 tmpdir="/var/cache/config-package-dev" 23 22 24 divert_link_divert() 23 25 { 24 26 file=$1 … … 131 133 undivert_unremove "$file" 132 134 fi 133 135 } 136 137 save_diverted_list() 138 { 139 filename="$1" 140 rm -f "$tmpdir/$filename" 141 mkdir -p "$tmpdir" 142 touch "$tmpdir/$filename" 143 # Get the list of what the currently installed version of the 144 # package diverts, from its Conflicts. We can't simply use 145 # dpkg-divert --list, because we can't guarantee that all 146 # diversions by our package were created by c-p-d 147 diverted_files=$(dpkg-query -W -f '${Conflicts}' "$package" | perl -ne 'sub unparse { $_ = $_[0]; return "/" unless $_; return "_" if $_ eq "-"; return uc($_) if /^[a-z]$/; s/^x//; return chr hex $_;} s/\s+//g; print join(" ", map { if (/^diverts/) { s|^diverts-|/|; s/\+([^+]*)\+/unparse($1)/eg; (-e $_) ? $_ : "" } } split(",", $_));') 148 for f in $diverted_files; do 149 # It's possible we should explicitly check for diversion to 150 # $theirs or diversion to /usr/share/$packge/(encoded name) 151 if LC_ALL=C dpkg-divert --list "$package" | \ 152 grep -qx "diversion of $f to .* by $package"; then 153 echo $f >> "$tmpdir/$filename" 154 fi 155 done 156 } 157 158 cleanup_old_diversions() { 159 # Save the list of what we're diverting now 160 save_diverted_list "${package}.diversions-new" 161 if [ -f "$tmpdir/${package}.diversions-old" ]; then 162 for f in $(cat "$tmpdir/${package}.diversions-old"); do 163 # If we used to divert something and we now don't, punt it 164 if ! grep -xFq "$f" "$tmpdir/${package}.diversions-new"; then 165 echo "Cleaning up old diversion of $f" >&2 166 undivert_unlink "$f" 167 fi 168 done 169 fi 170 rm -f "$tmpdir/${package}.diversions-new" 171 rm -f "$tmpdir/${package}.diversions-old" 172 } -
debian/changelog
1 config-package-dev (4.14) unstable; urgency=low 2 3 * Add functions to divert.sh.in and code to the preinst to allow 4 config-package-dev to cleanup after itself without requiring manual 5 specification of undiversions/unremovals (Trac: #867) 6 * Write divert.sh.in to the preinst to enable the aforementioned feature 7 * Change the prerm to undivert on "deconfigure" as well as "remove" 8 operations (Trac: #388) 9 10 -- Jonathan Reed <jdreed@mit.edu> Wed, 26 Sep 2012 11:01:46 -0400 11 1 12 config-package-dev (4.13) unstable; urgency=low 2 13 3 14 * Fix DEB_CHECK_FILES and DEB_TRANSFORM_FILES with non-conffiles in -
debian/control
7 7 Vcs-Git: git://andersk.mit.edu/config-package-dev.git 8 8 Vcs-Browser: http://andersk.mit.edu/gitweb/config-package-dev.git 9 9 Build-Depends: cdbs, 10 debhelper (>= 6),10 debhelper, 11 11 dh-buildinfo 12 12 Standards-Version: 3.9.2 13 13 -
divert.mk
30 30 31 31 CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev (>= 4.5~) 32 32 33 # divert.sh.in is included in the p ostinst/prerm scripts of packages34 # installing diversions using config-package-dev.33 # divert.sh.in is included in the preinst/postinst/prerm scripts of 34 # packages installing diversions using config-package-dev. 35 35 DEB_DIVERT_SCRIPT = /usr/share/config-package-dev/divert.sh.in 36 36 # script used to encode the path of a file uniquely in a valid virtual 37 37 # package name. … … 76 76 set -e; \ 77 77 { \ 78 78 sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \ 79 echo 'if [ "$$1" = "configure" ]; then'; \ 80 echo ' cleanup_old_diversions'; \ 79 81 $(if $(divert_files_all), \ 80 echo 'if [ "$$1" = "configure" ]; then'; \81 82 $(foreach file,$(divert_undivert_files), \ 82 83 echo " check_undivert_unlink $(call divert_files_replace_name,$(file), )"; )\ 83 84 $(foreach file,$(divert_unremove_files), \ … … 87 88 $(foreach file,$(divert_remove_files), \ 88 89 mkdir -p debian/$(cdbs_curpkg)/usr/share/$(cdbs_curpkg); \ 89 90 echo " divert_remove $(file) $(call remove_files_name,$(file))";) \ 90 echo 'fi'; \91 91 ) \ 92 echo 'fi'; \ 92 93 } >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper 94 # Add code to the preinst script to calculate the list 95 # of diverted files from the previous (if any) version 96 set -e; \ 97 { \ 98 sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \ 99 echo 'case "$$1" in'; \ 100 echo ' install|upgrade)'; \ 101 echo ' if [ -n "$$2" ]; then'; \ 102 echo ' save_diverted_list "$${package}.diversions-old"'; \ 103 echo ' fi'; \ 104 echo ' ;;'; \ 105 echo 'esac'; \ 106 } >> $(CURDIR)/debian/$(cdbs_curpkg).preinst.debhelper 93 107 # Add code to prerm script to undo diversions when package is removed. 94 108 set -e; \ 95 109 { \ … … 99 113 fi;) \ 100 114 sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \ 101 115 $(if $(divert_files_thispkg), \ 102 echo 'if [ "$$1" = "remove" ] ; then'; \116 echo 'if [ "$$1" = "remove" ] || [ "$$1" = "deconfigure" ]; then'; \ 103 117 $(foreach file,$(call reverse_dh_compat_5,$(divert_files)), \ 104 118 echo " undivert_unlink $(call divert_files_replace_name,$(file), )";) \ 105 119 $(foreach file,$(call reverse_dh_compat_5,$(divert_remove_files)), \