From 307194e33ae1856238c94a07818d9dfd4712f52f Mon Sep 17 00:00:00 2001
From: joey <joey>
Date: Mon, 23 Oct 2000 22:36:18 +0000
Subject: [PATCH] r378:    * dh_movefiles: fixed a regexp quoting problem with
 --sourcedir.      Closes: #75434    * Whoops, I think I overwrote bod's NMU
 with 2.2.15. Let's merge those      in:      .      debhelper (2.1.14-0.1)
 unstable; urgency=low      .        * Non-maintainer upload (thanks Joey).   
     * dh_installchangelogs, dh_installdocs: allow dangling symlinks for      
    $TMP/usr/share/doc/$PACKAGE (useful for multi-binary packages).         
 Closes: #53381      .      -- Brendan O'Dea <bod@debian.org>  Fri, 20 Oct
 2000 18:11:59 +1100      .      I also added some documentation to
 debhelper.1 about this, and removed      the TODO entry about it.

---
 debhelper.1          | 12 ++++++++++++
 debian/changelog     | 21 +++++++++++++++++++++
 dh_installchangelogs |  5 +++++
 dh_installdocs       | 25 +++++++++++++++----------
 dh_movefiles         |  4 ++--
 doc/TODO             |  6 ------
 6 files changed, 55 insertions(+), 18 deletions(-)

diff --git a/debhelper.1 b/debhelper.1
index 91aabb4..aedecd7 100644
--- a/debhelper.1
+++ b/debhelper.1
@@ -196,6 +196,18 @@ notice, and so may break packages that use it. See the file
 changes.
 .RE
 .TP
+.B Doc directory symlinks
+.RS
+Sometimes it is useful to make a package not contain a /usr/share/doc/package
+directory at all, instead placing just a dangling symlink in the binary
+package, that points to some other doc directory. Policy says this is ok if
+your package depends on the package whose doc directory it uses. To
+accomplish this, just don't tell debhelper to install any documentation
+files into the package, and use dh_link to set up the symlink (or do it by
+hand), and debhelper should do the right thing: notice it is a dangling
+symlink and not try to install a copyright file or changelog.
+.RE
+.TP
 .B Other notes
 .RS
 In general, if any debhelper program needs a directory to exist under
diff --git a/debian/changelog b/debian/changelog
index 589eacb..633263e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,24 @@
+debhelper (2.1.16) unstable; urgency=low
+
+  * dh_movefiles: fixed a regexp quoting problem with --sourcedir. 
+    Closes: #75434
+  * Whoops, I think I overwrote bod's NMU with 2.2.15. Let's merge those
+    in:
+    .
+    debhelper (2.1.14-0.1) unstable; urgency=low
+    .
+      * Non-maintainer upload (thanks Joey).
+      * dh_installchangelogs, dh_installdocs: allow dangling symlinks for
+        $TMP/usr/share/doc/$PACKAGE (useful for multi-binary packages).
+        Closes: #53381
+    .
+    -- Brendan O'Dea <bod@debian.org>  Fri, 20 Oct 2000 18:11:59 +1100
+    .
+    I also added some documentation to debhelper.1 about this, and removed
+    the TODO entry about it.
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 23 Oct 2000 15:14:49 -0700
+
 debhelper (2.1.15) unstable; urgency=low
 
   * dh_installwm: patched a path in some backwards compatability code.
diff --git a/dh_installchangelogs b/dh_installchangelogs
index 89b6ff6..e14eba6 100755
--- a/dh_installchangelogs
+++ b/dh_installchangelogs
@@ -36,6 +36,11 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
 	}
 
 	if (! -d "$TMP/usr/share/doc/$PACKAGE") {
+		# If it is a dangling symlink, then don't do anything.
+		# Think multi-binary packages that depend on each other and
+		# want to link doc dirs.
+		next if -l "$TMP/usr/share/doc/$PACKAGE";
+
 		doit("install","-d","$TMP/usr/share/doc/$PACKAGE");
 	}
 	doit("install","-o",0,"-g",0,"-p","-m644",$changelog,
diff --git a/dh_installdocs b/dh_installdocs
index 5a3ef70..7af3809 100755
--- a/dh_installdocs
+++ b/dh_installdocs
@@ -57,16 +57,21 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
 		}
 	}
 
-	# Support debian/package.copyright, but if not present, fall back
-	# on debian/copyright for all packages, not just the main binary
-	# package.
-	$copyright=pkgfile($PACKAGE,'copyright');
-	if (! $copyright && -e "debian/copyright") {
-		$copyright="debian/copyright";
-	}
-	if ($copyright) {
-			doit("install","-g",0,"-o",0,"-m","644","-p",$copyright,
-				"$TMP/usr/share/doc/$PACKAGE/copyright");
+	# If the "directory" is a dangling symlink, then don't install
+	# the copyright file. This is useful for multibinary packages 
+	# that share a doc directory.
+	if (-d "$TMP/usr/share/doc/$PACKAGE") {
+		# Support debian/package.copyright, but if not present, fall
+		# back on debian/copyright for all packages, not just the 
+		# main binary package.
+		$copyright=pkgfile($PACKAGE,'copyright');
+		if (! $copyright && -e "debian/copyright") {
+			$copyright="debian/copyright";
+		}
+		if ($copyright) {
+				doit("install","-g",0,"-o",0,"-m","644","-p",$copyright,
+					"$TMP/usr/share/doc/$PACKAGE/copyright");
+		}
 	}
 
 	# Add in the /usr/doc compatability symlinks code.
diff --git a/dh_movefiles b/dh_movefiles
index ad9add2..60e16f1 100755
--- a/dh_movefiles
+++ b/dh_movefiles
@@ -60,13 +60,13 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
 		foreach (@filelist) {
 			$file=$_;
 			$ret=1 if (! -e $file && ! -l $file);
-			$file=~s:^$sourcedir/+::;
+			$file=~s:^\Q$sourcedir\E/+::;
 			complex_doit("(cd $sourcedir >/dev/null ; find $file ! -type d -and ! -type l -print || true) >> debian/movelist");
 		}
 		foreach (@filelist) {
 			$file=$_;
 			$ret=1 if (! -e $file && ! -l $file);
-			$file=~s:^$sourcedir/+::;
+			$file=~s:^\Q$sourcedir\E/+::;
 			complex_doit("(cd $sourcedir >/dev/null ; find $file ! -type d -and -type l -print || true) >> debian/movelist");
 		}
 		complex_doit("(cd $sourcedir >/dev/null ; tar --create --remove-files --files-from=../movelist --file -) | (cd $TMP >/dev/null ;tar xpf -)");
diff --git a/doc/TODO b/doc/TODO
index 4cd0984..9277132 100644
--- a/doc/TODO
+++ b/doc/TODO
@@ -48,12 +48,6 @@ Wishlist items:
   postinst.in before debhelper gets it's hands on it... (#25235)
 * objdump -p can get the soname of a library, try using that in dh_shlibs
   instead of parsing filenames.
-* to suport foo-doc -> foo symlinks in /usr/share/doc, make
-  dh_installdocs/changelogs check to see if the doc dir is a symlink to a
-  directory. If so, dh_installdocs does not install copyright, and
-  dh_installchangelogs does nothing, but everything else dh_installdocs would
-  do is still done. This means that you need to use dh_link and dh_installdirs
-  to set up the link and directory.
 
 Deprecated:
 
-- 
2.39.5