[23257] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r22918 - in trunk/debathena/debathena/config-package-dev: . debian

daemon@ATHENA.MIT.EDU (tabbott@MIT.EDU)
Mon Apr 21 16:34:56 2008

Date: Mon, 21 Apr 2008 16:34:25 -0400 (EDT)
From: tabbott@MIT.EDU
Message-Id: <200804212034.QAA15754@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: tabbott
Date: 2008-04-21 16:34:25 -0400 (Mon, 21 Apr 2008)
New Revision: 22918

Modified:
   trunk/debathena/debathena/config-package-dev/check-files.mk
   trunk/debathena/debathena/config-package-dev/debian/changelog
   trunk/debathena/debathena/config-package-dev/divert.mk
   trunk/debathena/debathena/config-package-dev/divert.sh.in
   trunk/debathena/debathena/config-package-dev/encode
Log:
In config-package-dev:
  * Add new DEB_REMOVE_FILES_$package variable designed for removing
    files in .d directories.
  * Move the "configure-" in the filename encoding from the encode script
    to divert.mk, so that we can re-use the encoder for DEB_REMOVE_FILES.
  * Add new DEB_UNDIVERT_FILES_package and DEB_UNREMOVE_FILES_package
    API variables for having a new version of the package stop diverting a
    file.
  * Correct check for not generating an empty if clause when no files are
    being diverted.
  * Remove only the last DEB_DIVERT_EXTENSION from filenames.


Modified: trunk/debathena/debathena/config-package-dev/check-files.mk
===================================================================
--- trunk/debathena/debathena/config-package-dev/check-files.mk	2008-04-21 20:23:46 UTC (rev 22917)
+++ trunk/debathena/debathena/config-package-dev/check-files.mk	2008-04-21 20:34:25 UTC (rev 22918)
@@ -25,7 +25,7 @@
 DEB_CHECK_FILES_DIR = debian/check_file_copies
 
 debian_check_files_source = $(if $(DEB_CHECK_FILES_SOURCE_$(1)),$(DEB_CHECK_FILES_SOURCE_$(1)),$(1))
-debian_check_files_check = $(subst $(DEB_DIVERT_EXTENSION),,$(call debian_check_files_source,$(1)))
+debian_check_files_check = $(call divert_files_replace_name,$(call debian_check_files_source,$(1)))
 
 debian_check_files = $(patsubst %,$(DEB_CHECK_FILES_DIR)%,$(1))
 undebian_check_files = $(patsubst $(DEB_CHECK_FILES_DIR)%,%,$(1))

Modified: trunk/debathena/debathena/config-package-dev/debian/changelog
===================================================================
--- trunk/debathena/debathena/config-package-dev/debian/changelog	2008-04-21 20:23:46 UTC (rev 22917)
+++ trunk/debathena/debathena/config-package-dev/debian/changelog	2008-04-21 20:34:25 UTC (rev 22918)
@@ -1,3 +1,18 @@
+config-package-dev (4.4) unstable; urgency=low
+
+  * Add new DEB_REMOVE_FILES_$package variable designed for removing
+    files in .d directories.
+  * Move the "configure-" in the filename encoding from the encode script
+    to divert.mk, so that we can re-use the encoder for DEB_REMOVE_FILES.
+  * Add new DEB_UNDIVERT_FILES_package and DEB_UNREMOVE_FILES_package
+    API variables for having a new version of the package stop diverting a
+    file.
+  * Correct check for not generating an empty if clause when no files are
+    being diverted.
+  * Remove only the last DEB_DIVERT_EXTENSION from filenames.
+
+ -- Tim Abbott <tabbott@mit.edu>  Sat, 19 Apr 2008 21:03:02 -0400
+
 config-package-dev (4.3) unstable; urgency=low
 
   * Fix bug where DEB_DIVERT code gets added twice if a package uses both

Modified: trunk/debathena/debathena/config-package-dev/divert.mk
===================================================================
--- trunk/debathena/debathena/config-package-dev/divert.mk	2008-04-21 20:23:46 UTC (rev 22917)
+++ trunk/debathena/debathena/config-package-dev/divert.mk	2008-04-21 20:34:25 UTC (rev 22918)
@@ -20,13 +20,16 @@
 ifndef _cdbs_rules_divert
 _cdbs_rules_divert = 1
 
-CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev
+CDBS_BUILD_DEPENDS := $(CDBS_BUILD_DEPENDS), config-package-dev (>= 4.4)
 
 DEB_DIVERT_SCRIPT = /usr/share/config-package-dev/divert.sh.in
 
 DEB_DIVERT_PACKAGES += $(foreach package,$(DEB_ALL_PACKAGES), \
     $(if $(DEB_REPLACE_FILES_$(package)),$(package), \
-    $(if $(DEB_DIVERT_FILES_$(package)),$(package))))
+    $(if $(DEB_REMOVE_FILES_$(package)),$(package), \
+    $(if $(DEB_UNREMOVE_FILES_$(package)),$(package), \
+    $(if $(DEB_UNDIVERT_FILES_$(package)),$(package), \
+    $(if $(DEB_DIVERT_FILES_$(package)),$(package)))))))
 
 ifeq ($(DEB_DIVERT_EXTENSION),)
 DEB_DIVERT_EXTENSION = .divert
@@ -34,33 +37,58 @@
 
 DEB_DIVERT_ENCODER = /usr/share/config-package-dev/encode
 
+divert_files_replace_name = $(shell echo $(1) | perl -pe 's/(.*)\Q$(DEB_DIVERT_EXTENSION)\E/$$1$(2)/')
+
 debian-divert/%: package = $(subst debian-divert/,,$@)
-debian-divert/%: replace_inputs = $(DEB_REPLACE_FILES_$(package))
-debian-divert/%: replace_files = $(foreach file,$(replace_inputs),$(file))
-debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(replace_files)
+debian-divert/%: divert_files = $(DEB_DIVERT_FILES_$(package)) $(DEB_REPLACE_FILES_$(package))
+debian-divert/%: divert_remove_files = $(DEB_REMOVE_FILES_$(package))
+debian-divert/%: divert_undivert_files = $(DEB_UNDIVERT_FILES_$(package))
+debian-divert/%: divert_unremove_files = $(DEB_UNREMOVE_FILES_$(package))
+debian-divert/%: divert_files_all = $(strip $(divert_files) $(divert_remove_files) $(divert_undivert_files) $(divert_unremove_files))
+debian-divert/%: divert_files_thispkg = $(strip $(divert_files) $(divert_remove_files))
 $(patsubst %,debian-divert/%,$(DEB_DIVERT_PACKAGES)) :: debian-divert/%:
 	( \
 	    sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
-	    $(if $(divert_files), \
+	    $(if $(divert_files_all), \
 		echo 'if [ "$$1" = "configure" ]; then'; \
+		$(foreach file,$(divert_undivert_files), \
+		    $(if $(DEB_UNDIVERT_FILES_VERSION_$(file)),,\
+			echo "ERROR!  Missing undivert version for $(file)!">&2; exit 1;) \
+		    echo -n "    if [ -n \"\$$2\" ] && dpkg --compare-versions \"\$$2\" '<<' "; \
+		    echo "'$(DEB_UNDIVERT_FILES_VERSION_$(file))'; then"; \
+		    echo "        undivert_unlink $(call divert_files_replace_name,$(file), )"; \
+		    echo "    fi";) \
+		$(foreach file,$(divert_unremove_files), \
+		    $(if $(DEB_UNREMOVE_FILES_VERSION_$(file)),,\
+			echo "ERROR!  Missing unremove version for $(file)!">&2; exit 1;) \
+		    echo -n "    if [ -n \"\$$2\" ] && dpkg --compare-versions \"\$$2\" '<<' "; \
+		    echo "'$(DEB_UNREMOVE_FILES_VERSION_$(file))'; then"; \
+		    echo "        undivert_unremove $(file)"; \
+		    echo "    fi";) \
 		$(foreach file,$(divert_files), \
-		    echo "    divert_link $(subst $(DEB_DIVERT_EXTENSION), ,$(file))";) \
+		    echo "    divert_link $(call divert_files_replace_name,$(file), )";) \
+		$(foreach file,$(divert_remove_files), \
+		    mkdir -p $(DEB_DESTDIR)/usr/share/$(cdbs_curpkg); \
+		    echo "    divert_remove $(file) /usr/share/$(cdbs_curpkg)/`$(DEB_DIVERT_ENCODER) $(file)`";) \
 		echo 'fi'; \
 	    ) \
 	) >> $(CURDIR)/debian/$(cdbs_curpkg).postinst.debhelper
 	( \
 	    sed 's/#PACKAGE#/$(cdbs_curpkg)/g; s/#DEB_DIVERT_EXTENSION#/$(DEB_DIVERT_EXTENSION)/g' $(DEB_DIVERT_SCRIPT); \
-	    $(if $(divert_files), \
+	    $(if $(divert_files_thispkg), \
 		echo 'if [ "$$1" = "remove" ]; then'; \
 		$(foreach file,$(divert_files), \
-		    echo "    undivert_unlink $(subst $(DEB_DIVERT_EXTENSION), ,$(file))";) \
+		    echo "    undivert_unlink $(call divert_files_replace_name,$(file), )";) \
+		$(foreach file,$(divert_remove_files), \
+		    echo "    undivert_unremove $(file) $(cdbs_curpkg)";) \
 		echo 'fi'; \
 	    ) \
 	) >> $(CURDIR)/debian/$(cdbs_curpkg).prerm.debhelper
 	( \
 	    echo -n "diverted-files="; \
-	    $(foreach file,$(divert_files),\
-		${DEB_DIVERT_ENCODER} "$(subst $(DEB_DIVERT_EXTENSION),,$(file))"; \
+	    $(foreach file,$(divert_files_thispkg),\
+		echo -n "configures-"; \
+		${DEB_DIVERT_ENCODER} "$(call divert_files_replace_name,$(file))"; \
 		echo -n ", ";) \
 	    echo \
 	) >> $(CURDIR)/debian/$(cdbs_curpkg).substvars

Modified: trunk/debathena/debathena/config-package-dev/divert.sh.in
===================================================================
--- trunk/debathena/debathena/config-package-dev/divert.sh.in	2008-04-21 20:23:46 UTC (rev 22917)
+++ trunk/debathena/debathena/config-package-dev/divert.sh.in	2008-04-21 20:34:25 UTC (rev 22918)
@@ -11,7 +11,7 @@
 #   Undoes the action of divert_link <prefix> <suffix> specified
 #   above.
 #
-# Version: 3.4
+# Version: 4.0
 #
 
 package=#PACKAGE#
@@ -19,19 +19,22 @@
 ours=#DEB_DIVERT_EXTENSION#
 theirs=#DEB_DIVERT_EXTENSION#-orig
 
-divert_link()
+divert_link_divert()
 {
-    prefix=$1
-    suffix=$2
-
-    file=$prefix$suffix
-    ourfile=$prefix$ours$suffix
-    theirfile=$prefix$theirs$suffix
-
+    file=$1
+    ourfile=$2
+    theirfile=$3
     if ! dpkg-divert --list "$package" | \
 	grep -xFq "diversion of $file to $theirfile by $package"; then
 	dpkg-divert --divert "$theirfile" --rename --package "$package" --add "$file"
     fi
+}
+
+divert_link_symlink()
+{
+    file=$1
+    ourfile=$2
+    theirfile=$3
     if [ ! -L "$file" ] && [ ! -e "$file" ]; then
 	ln -s "$(basename "$ourfile")" "$file"
     elif [ ! -L "$file" ] || \
@@ -41,7 +44,7 @@
     fi
 }
 
-undivert_unlink()
+divert_link()
 {
     prefix=$1
     suffix=$2
@@ -49,7 +52,23 @@
     file=$prefix$suffix
     ourfile=$prefix$ours$suffix
     theirfile=$prefix$theirs$suffix
+    divert_link_divert "$file" "$ourfile" "$theirfile"
+    divert_link_symlink "$file" "$ourfile" "$theirfile"
+}
 
+divert_remove()
+{
+    file=$1
+    ourfile=""
+    theirfile=$2
+    divert_link_divert "$file" "$ourfile" "$theirfile"
+}
+
+undivert_unlink_symlink()
+{
+    file="$1"
+    ourfile="$2"
+    theirfile="$3"
     if [ ! -L "$file" ] || \
 	[ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
 	  "$(readlink "$file")" != "$(basename "$theirfile")" ]; then
@@ -57,6 +76,11 @@
     else
 	rm -f "$file"
     fi
+}
+
+undivert_unlink_divert()
+{
+    file="$1"
     if [ ! -L "$file" ] && [ ! -e "$file" ]; then
 	dpkg-divert --remove --rename --package "$package" "$file"
     else
@@ -64,3 +88,22 @@
     fi
 }
 
+undivert_unlink()
+{
+    prefix=$1
+    suffix=$2
+
+    file=$prefix$suffix
+    ourfile=$prefix$ours$suffix
+    theirfile=$prefix$theirs$suffix
+
+    undivert_unlink_symlink "$file" "$ourfile" "$theirfile"
+    undivert_unlink_divert "$file" "$package"
+}
+
+undivert_unremove()
+{
+    file=$1
+    undivert_unlink_divert "$file"
+}
+

Modified: trunk/debathena/debathena/config-package-dev/encode
===================================================================
--- trunk/debathena/debathena/config-package-dev/encode	2008-04-21 20:23:46 UTC (rev 22917)
+++ trunk/debathena/debathena/config-package-dev/encode	2008-04-21 20:34:25 UTC (rev 22918)
@@ -13,7 +13,6 @@
 # determine the cause of conflicts between different configuration
 # packages.
  
-print "configures-";
 $ARGV[0] =~ s,^/,,;
 split('', $ARGV[0]);
 foreach (@_){


home help back first fref pref prev next nref lref last post