On Wednesday 21 March 2007 20:43, Joey Hess wrote:
> Magnus Holmgren wrote:
> > +my $min_debconfver = "0.005";
>
> If you could make this patch use unmunged version numbers, like "0.5",
> I'd accept it.

Is there any correct version number comparing function readily available, or 
just dpkg --compare-versions (which must be overkill)?

If the tests can be done in ascending order, no version comparisons are needed 
at all. That's how I've done in this version of the patch, which also 
includes a simple (but definitely less failure-prone than grepping maintainer 
scripts) check for the "error" template type (easy to leave out if you don't 
like it).

Also notice that I've moved the variable definition inside the loop; different 
binary packages can have different dependencies.

-- 
Magnus Holmgren        [EMAIL PROTECTED]
--- dh_installdebconf	2006-03-15 22:11:47.000000000 +0100
+++ dh_installdebconf	2007-03-21 22:21:11.084118495 +0100
@@ -73,6 +73,7 @@
 	my $tmp=tmpdir($package);
 	my $config=pkgfile($package,"config");
 	my $templates=pkgfile($package,"templates");
+	my $min_debconfver = '0.5';
 
 	if (! -d "$tmp/DEBIAN") {
 		doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
@@ -92,16 +93,23 @@
 		
 		if (-d "debian/po") {
 			complex_doit("po2debconf @extraparams $templates > $tmp/DEBIAN/templates");
+			$min_debconfver = '1.2.0';
 		}
 		else {
 			doit("install", "-o", 0, "-g", 0, "-m", 644, "-p",
 			     $templates, "$tmp/DEBIAN/templates");
 		}
+
+		# Check for templates of type error
+		open TEMPLATES_IN, $templates or error "Could not read $templates: $!";
+		# This has to be made more advanced if more tests are needed.
+		if (grep /^type:\s?error\s*$/i, <TEMPLATES_IN>) {
+			$min_debconfver = '1.4.69';
+		}
+		close TEMPLATES_IN;
 	}
 
-	# I'm going with debconf 0.5 because it was the first
-	# "modern" one. udebs just need cdebconf.
-	my $debconfdep=is_udeb($package) ? "cdebconf-udeb" : "debconf (>= 0.5) | debconf-2.0";
+	my $debconfdep=is_udeb($package) ? "cdebconf-udeb" : "debconf (>= $min_debconfver) | debconf-2.0";
 	if ($config ne '' || $templates ne '') {
 		addsubstvar($package, "misc:Depends", $debconfdep);
 	}

Attachment: pgpNmP6MCulrR.pgp
Description: PGP signature

Reply via email to