From: joey <joey>
Date: Mon, 9 Feb 2004 05:24:40 +0000 (+0000)
Subject: r1655:    * Added udeb support, as pioneered by di-packages-build. Understands
X-Git-Tag: version_4.2.0^0
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4f162e192c3563d740490cc99ced1513104ac34c;p=debhelper.git

r1655:    * Added udeb support, as pioneered by di-packages-build. Understands
     "XC-Package-Type: udeb" in debian/control. See debhelper(1) for
     details.
   * Dh_Lib: add and export is_udeb and udeb_filename
   * dh_builddeb: name udebs with proper extension
   * dh_gencontrol: pass -n and filename to dpkg-gencontrol
   * dh_installdocs, dh_makeshlibs, dh_md5sums, dh_installchangelogs,
     dh_installexamples, dh_installman, dh_installmanpages: skip udebs
   * dh_shlibdeps: skip udebs. This may be temporary.
   * dh_installdeb: do not process conffiles, shlibs, preinsts, postrms,
     or prerms for udebs. Do not substiture #DEBHELPER# tokens in
     postinst scripts for udebs.
   * dh_installdebconf: skip config script for udebs, still do templates
---

diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm
index c610963..1da5afd 100644
--- a/Debian/Debhelper/Dh_Getopt.pm
+++ b/Debian/Debhelper/Dh_Getopt.pm
@@ -29,18 +29,18 @@ sub showhelp {
 # order.
 sub AddPackage { my($option,$value)=@_;
 	if ($option eq 'i' or $option eq 'indep') {
-		push @{$options{DOPACKAGES}}, GetPackages('indep');
+		push @{$options{DOPACKAGES}}, getpackages('indep');
 		$options{DOINDEP}=1;
 	}
 	elsif ($option eq 'a' or $option eq 'arch') {
-		push @{$options{DOPACKAGES}}, GetPackages('arch');
+		push @{$options{DOPACKAGES}}, getpackages('arch');
 		$options{DOARCH}=1;
 	}
 	elsif ($option eq 'p' or $option eq 'package') {
 		push @{$options{DOPACKAGES}}, $value;
 	}
 	elsif ($option eq 's' or $option eq 'same-arch') {
-		push @{$options{DOPACKAGES}}, GetPackages('same');
+		push @{$options{DOPACKAGES}}, getpackages('same');
 		$options{DOSAME}=1;
 	}
 	else {
@@ -184,7 +184,7 @@ sub parseopts {
 			# built, and there are none of that type.
 			error("I have no package to build");
 		}
-		push @{$options{DOPACKAGES}},GetPackages();
+		push @{$options{DOPACKAGES}},getpackages();
 	}
 
 	# Remove excluded packages from the list of packages to act on.
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 0eea018..f42f8bd 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -12,8 +12,9 @@ use vars qw(@ISA @EXPORT %dh);
 @ISA=qw(Exporter);
 @EXPORT=qw(&init &doit &complex_doit &verbose_print &error &warning &tmpdir
 	    &pkgfile &pkgext &pkgfilename &isnative &autoscript &filearray
-	    &filedoublearray &GetPackages &basename &dirname &xargs %dh
-	    &compat &addsubstvar &delsubstvar &excludefile);
+	    &filedoublearray &getpackages &basename &dirname &xargs %dh
+	    &compat &addsubstvar &delsubstvar &excludefile &is_udeb
+	    &udeb_filename);
 
 my $max_compat=4;
 
@@ -72,7 +73,7 @@ sub init {
 		$dh{NO_ACT}=1;
 	}
 
-	my @allpackages=GetPackages();
+	my @allpackages=getpackages();
 	# Get the name of the main binary package (first one listed in
 	# debian/control). Only if the main package was not set on the
 	# command line.
@@ -533,8 +534,14 @@ sub excludefile {
 # Must pass "arch" or "indep" or "same" to specify arch-dependant or
 # -independant or same arch packages. If nothing is specified, returns all
 # packages.
-sub GetPackages {
+# As a side effect, populates %package_arches and %package_types with the
+# types of all packages (not only those returned).
+my (%package_types, %package_arches);
+sub getpackages {
 	my $type=shift;
+
+	%package_types=();
+	%package_arches=();
 	
 	$type="" if ! defined $type;
 	
@@ -546,6 +553,7 @@ sub GetPackages {
 
 	my $package="";
 	my $arch="";
+	my $package_type;
 	my @list=();
 	my %seen;
 	open (CONTROL, 'debian/control') ||
@@ -562,12 +570,20 @@ sub GetPackages {
 			else {
 				error("debian/control has a duplicate entry for $package");
 			}
+			$package_type="deb";
 		}
 		if (/^Architecture:\s*(.*)/) {
 			$arch=$1;
 		}
+		if (/^X[BC]*-Package-Type:\s*(.*)/) {
+			$package_type=$1;
+		}
 		
 		if (!$_ or eof) { # end of stanza.
+			if ($package) {
+				$package_types{$package}=$package_type;
+				$package_arches{$package}=$arch;
+			}
 			if ($package &&
 			    (($type eq 'indep' && $arch eq 'all') ||
 			     ($type eq 'arch' && $arch ne 'all') ||
@@ -584,4 +600,18 @@ sub GetPackages {
 	return @list;
 }
 
+sub is_udeb {
+	my $package=shift;
+	
+	return $package_types{$package} eq 'udeb';
+}
+
+sub udeb_filename {
+	my $package=shift;
+	
+	my $filearch=$package_arches{$package} eq 'all' ? "all" : buildarch();
+	isnative($package); # side effect
+	return "${package}_$dh{VERSION}_$filearch.udeb";
+}
+
 1
diff --git a/debhelper.pod b/debhelper.pod
index 8b26ca6..83e6783 100644
--- a/debhelper.pod
+++ b/debhelper.pod
@@ -325,6 +325,15 @@ 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.
 
+=head2 udebs
+
+Debhelper includes support for udebs. To create a udeb with debhelper,
+add "XC-Package-Type: udeb" to the package's stanza in debian/control, and
+build-depend on debhelper (>= 4.2). Debhelper will try to create udebs that
+comply with debian-installer policy, by making the generated package files
+end in ".udeb", not installing any documentation into a udeb, skipping over
+preinst, postrm, prerm, and config scripts, etc.
+
 =head2 Other notes
 
 In general, if any debhelper program needs a directory to exist under
diff --git a/debian/changelog b/debian/changelog
index 9e780a3..5f01e17 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,21 @@
+debhelper (4.2.0) unstable; urgency=low
+
+  * Added udeb support, as pioneered by di-packages-build. Understands
+    "XC-Package-Type: udeb" in debian/control. See debhelper(1) for
+    details.
+  * Dh_Lib: add and export is_udeb and udeb_filename
+  * dh_builddeb: name udebs with proper extension
+  * dh_gencontrol: pass -n and filename to dpkg-gencontrol
+  * dh_installdocs, dh_makeshlibs, dh_md5sums, dh_installchangelogs,
+    dh_installexamples, dh_installman, dh_installmanpages: skip udebs
+  * dh_shlibdeps: skip udebs. This may be temporary.
+  * dh_installdeb: do not process conffiles, shlibs, preinsts, postrms,
+    or prerms for udebs. Do not substiture #DEBHELPER# tokens in
+    postinst scripts for udebs.
+  * dh_installdebconf: skip config script for udebs, still do templates
+
+ -- Joey Hess <joeyh@debian.org>  Sun,  8 Feb 2004 22:51:57 -0500
+
 debhelper (4.1.90) unstable; urgency=low
 
   * dh_strip: Add note to man page that the detached debugging symbols options
diff --git a/dh_builddeb b/dh_builddeb
index 3d9f9d8..31bcdc6 100755
--- a/dh_builddeb
+++ b/dh_builddeb
@@ -63,7 +63,16 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		complex_doit("find $tmp -name $_ | xargs rm -rf")
 			foreach split(":", $ENV{DH_ALWAYS_EXCLUDE});
 	}
-	doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$dh{FILENAME});
+	if (! is_udeb($package)) {
+		doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$dh{FILENAME});
+	}
+	else {
+		my $filename=$dh{FILENAME};
+		if (! $filename) {
+			$filename="/".udeb_filename($package);
+		}
+		doit("dpkg-deb", @{$dh{U_PARAMS}}, "--build", $tmp, $dh{DESTDIR}.$filename);
+	}
 }
 
 =head1 SEE ALSO
diff --git a/dh_gencontrol b/dh_gencontrol
index b9aaefb..7614fa6 100755
--- a/dh_gencontrol
+++ b/dh_gencontrol
@@ -54,9 +54,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 
 	# Generate and install control file.
 	my @command="dpkg-gencontrol";
-	if (GetPackages() > 1) {
+	if (getpackages() > 1) {
 		push @command, "-p$package";
 	}
+	if (is_udeb($package)) {
+		push @command, "-n".udeb_filename($package);
+	}
 	doit(@command, "-l$changelog", "-isp", "-Tdebian/${ext}substvars", 
 		"-P$tmp",@{$dh{U_PARAMS}});
 
diff --git a/dh_installchangelogs b/dh_installchangelogs
index 7de170a..7bb235c 100755
--- a/dh_installchangelogs
+++ b/dh_installchangelogs
@@ -68,6 +68,8 @@ if (isnative($dh{MAINPACKAGE}) && ! defined $upstream) {
 my $news_name="NEWS.Debian";
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+	
 	my $tmp=tmpdir($package);
 	my $changelog=pkgfile($package,"changelog");
 	my $news=pkgfile($package,"NEWS");
diff --git a/dh_installdeb b/dh_installdeb
index e25e175..9832d10 100755
--- a/dh_installdeb
+++ b/dh_installdeb
@@ -52,6 +52,16 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
 	}
 
+	if (is_udeb($package)) {
+		# For udebs, only do the postinst, and no #DEBHELPER#.
+		my $f=pkgfile($package,"postinst");
+		if ($f) {
+			doit("install", "-o", 0, "-g", 0, "-m", 755, 
+			     $f, "$tmp/DEBIAN/postinst");
+		}
+		next;		
+	}
+	
 	# Install debian install scripts.
 	# If any .debhelper files exist, add them into the scripts.
 	foreach my $file (qw{postinst preinst prerm postrm}) {
diff --git a/dh_installdebconf b/dh_installdebconf
index 66dafd0..ebf6a13 100755
--- a/dh_installdebconf
+++ b/dh_installdebconf
@@ -83,7 +83,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
 	}
 
-	if ($config ne '') {
+	if (! is_udeb($package) && $config ne '') {
 		doit("install", "-o", 0, "-g", 0, "-m", 755, "-p",
 		     $config, "$tmp/DEBIAN/config");
 	}
diff --git a/dh_installdocs b/dh_installdocs
index 3fe3d0c..f729186 100755
--- a/dh_installdocs
+++ b/dh_installdocs
@@ -88,6 +88,8 @@ instances of the same text to be added to maintainer scripts.
 init();
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+	
 	my $tmp=tmpdir($package);
 	my $file=pkgfile($package,"docs");
 
diff --git a/dh_installexamples b/dh_installexamples
index 8934e2f..dcd37ad 100755
--- a/dh_installexamples
+++ b/dh_installexamples
@@ -58,6 +58,8 @@ directory, it will install the complete contents of the directory.
 init();
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+
 	my $tmp=tmpdir($package);
 	my $file=pkgfile($package,"examples");
 	
diff --git a/dh_installman b/dh_installman
index 3d03d26..b626e33 100755
--- a/dh_installman
+++ b/dh_installman
@@ -82,6 +82,8 @@ my @sofiles;
 my @sodests;
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+
 	my $tmp=tmpdir($package);
 	my $file=pkgfile($package,"manpages");
 	my @manpages;
diff --git a/dh_installmanpages b/dh_installmanpages
index 39946f6..415c86b 100755
--- a/dh_installmanpages
+++ b/dh_installmanpages
@@ -126,11 +126,13 @@ sub find_so_man {
 }
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+
 	my $tmp=tmpdir($package);
 
 	# Find all filenames that look like man pages.
 	@manpages=();
-	@allpackages=GetPackages('');
+	@allpackages=getpackages('');
 	find(\&find_man,'.'); # populates @manpages
 	
 	foreach my $page (@manpages) {
diff --git a/dh_makeshlibs b/dh_makeshlibs
index a888aec..1d57b01 100755
--- a/dh_makeshlibs
+++ b/dh_makeshlibs
@@ -86,6 +86,8 @@ Generates a shlibs file that looks something like:
 init();
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+	
 	my $tmp=tmpdir($package);
 
 	my %seen;
diff --git a/dh_md5sums b/dh_md5sums
index 7d31322..0619a3b 100755
--- a/dh_md5sums
+++ b/dh_md5sums
@@ -46,6 +46,8 @@ being listed in the md5sums file.
 init();
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+	
 	my $tmp=tmpdir($package);
 
 	if (! -d "$tmp/DEBIAN") {
diff --git a/dh_python b/dh_python
index 02afea8..eb32fd4 100755
--- a/dh_python
+++ b/dh_python
@@ -132,7 +132,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		$strong_dep = 1;
 		my $pack = $package;
 		$pack =~ s/^python/python$python_version/;
-		if (grep { "$_" eq "$pack" } GetPackages()) {
+		if (grep { "$_" eq "$pack" } getpackages()) {
 			addsubstvar($package, "python:Depends", $pack);
 		}
 	}
diff --git a/dh_shlibdeps b/dh_shlibdeps
index 3192b18..c92d1bf 100755
--- a/dh_shlibdeps
+++ b/dh_shlibdeps
@@ -101,6 +101,8 @@ if ($dh{L_PARAMS}) {
 }
 
 foreach my $package (@{$dh{DOPACKAGES}}) {
+	next if is_udeb($package);
+	
 	my $tmp=tmpdir($package);
 	my $ext=pkgext($package);
 
diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING
index 239f53e..5a3156e 100644
--- a/doc/PROGRAMMING
+++ b/doc/PROGRAMMING
@@ -237,5 +237,10 @@ delsubstvar($package, $substvar)
 excludefile($filename)
 	This function returns true if -X has been used to ask for the file
 	to be excluded.
+is_udeb($package)
+	Returns true if the package is marked as a udeb in the control
+	file.
+udeb_filename($package)
+	Returns the filename of the udeb package.
 
 -- Joey Hess <joeyh@debian.org>