[Cdd-commits] r250 - cdd/trunk/cdd

Andreas Tille debian-custom@lists.debian.org
Tue, 13 Jul 2004 10:07:37 -0600


Author: tille
Date: Tue Jul 13 10:07:36 2004
New Revision: 250

Modified:
   cdd/trunk/cdd/cdd-gen-control
Log:
Add versioned dependency from #CDD#-common package if needed


Modified: cdd/trunk/cdd/cdd-gen-control
==============================================================================
--- cdd/trunk/cdd/cdd-gen-control	(original)
+++ cdd/trunk/cdd/cdd-gen-control	Tue Jul 13 10:07:36 2004
@@ -31,6 +31,9 @@
 # the VERSION variable is replaced in the dist target of debian/rules
 $commondepends{"cdd-common"} = "#VERSION#" ;
 
+my $CommonPackage = "" ;
+my $prefix        = "test-" ;
+
 getopts("cdaemis:", \%opts);
 
 $tmpaptsources = $opts{'s'} if ($opts{'s'});
@@ -105,8 +108,14 @@
 	}
 
 	for $header (qw(Pre-Depends Depends Suggests Recommends)) {
-	    print "$header: ", join(", ", sort @{$taskinfo{$task}{$header}}),"\n"
-		if (defined $taskinfo{$task}{$header});
+	    if (defined $taskinfo{$task}{$header}) {
+		print "$header: ";
+		# Print -common page with versioned dependency if necessary
+		if ( $header =~ /Depends/ ) {
+		    unless ( $CommonPackage =~ /^$/ ) { print $prefix."common (= $CommonPackage), "; }
+		}
+                print join(", ", sort @{$taskinfo{$task}{$header}}),"\n" ;
+	    }
 	}
 
 	# Description Description-long
@@ -146,7 +155,6 @@
 #
 sub load_tasks {
     my $taskfile;
-    my $prefix = "test-" ;
 
     unless  ( -d "debian" ) {
         system ( "mkdir debian" ) ;
@@ -214,6 +222,16 @@
 	    print ;
 	}
 	close(COMMON);
+
+	# calculate meta packages version number to make all meta packages depend from exactly the same common package
+	open PARSED, "dpkg-parsechangelog |"
+	    or die "Cannot execute dpkg-parsechangelog: $!";
+
+	while (<PARSED>) {
+	    chomp;
+	    if ( /^Version:\s([.\d]+)$/) { $CommonPackage = $1; last ;}
+	}
+	if ( $CommonPackage =~ /^$/ ) { die "dpkg-parsechangelog does not contain package version number."; }
     }
     
     # First document their existence, so they can depend on each other.