[Cdd-commits] r307 - in cdd/trunk/cdd: . debian

Otavio Salvador debian-custom@lists.debian.org
Tue, 28 Sep 2004 11:33:11 -0600


Author: otavio
Date: Tue Sep 28 11:33:09 2004
New Revision: 307

Modified:
   cdd/trunk/cdd/cdd-gen-control
   cdd/trunk/cdd/debian/changelog
Log:
    - cdd-gen-control:
      o Add -D suport to cdd-gen-control to degrade dependencies to
        recommends; 
      o Add support for architecture dependent packages;
      o Add fallback to architecture independent packages so allow
      o backward compatibility;
      o Add suport to tasksel based tasks;


Modified: cdd/trunk/cdd/cdd-gen-control
==============================================================================
--- cdd/trunk/cdd/cdd-gen-control	(original)
+++ cdd/trunk/cdd/cdd-gen-control	Tue Sep 28 11:33:09 2004
@@ -17,7 +17,8 @@
 	    @tasks $debug);
 my @arch = qw(alpha arm i386 ia64 m68k mips mipsel powerpc s390 sparc hppa);
 
-$debug = 0;
+my $debug = 0;
+my $nodepends = 0;
 
 my %taskinfo = ();
 
@@ -34,7 +35,7 @@
 my $CommonPackage = "" ;
 my $prefix        = "test-" ;
 
-getopts("cdaemis:", \%opts);
+getopts("cdaemis:tD", \%opts);
 
 $tmpaptsources = $opts{'s'} if ($opts{'s'});
 
@@ -47,6 +48,7 @@
 }
 
 $debug = 1 if ($opts{'d'});
+$nodepends = 1 if ($opts{'D'});
 
 load_available_packages();
 
@@ -98,26 +100,39 @@
 
     for $task (sort keys %taskinfo) {
 	print "Package: $task\n";
-	print "Architecture: all\n";
 	my $header;
 # Leave out XBCS-Task for the moment ...
-#	for $header (qw(Section XBCS-Task Priority)) {
-	for $header (qw(Section Priority)) {
+#	for $header (qw(Section Architecture XBCS-Task Priority)) {
+	for $header (qw(Section Architecture Priority)) {
 	    print "$header: $taskinfo{$task}{$header}\n"
 		if (defined $taskinfo{$task}{$header});
 	}
 
-	for $header (qw(Pre-Depends Depends Suggests Recommends)) {
-	    if (defined $taskinfo{$task}{$header}) {
-		print "$header: ";
-		# Print -common page with versioned dependency if necessary
-		if ( $header =~ /Depends/ ) {
-		    unless ( $CommonPackage =~ /^$/ ) { print $prefix."common (= $CommonPackage), "; }
+	if ($nodepends) {
+		# degrade dependencies to recommends and recommends to
+		# suggests
+		print "Depends: education-tasks\n";
+	    	print "Recommends: ", join(", ", sort @{$taskinfo{$task}{Depends}}),"\n"
+			if defined $taskinfo{$task}{Depends};
+		my @suggests;
+		push @suggests, @{$taskinfo{$task}{Recommends}} if defined $taskinfo{$task}{Recommends};
+		push @suggests, @{$taskinfo{$task}{Suggests}} if defined $taskinfo{$task}{Suggests};
+	    	print "Suggests: ", join(", ", sort @suggests),"\n" if @suggests;
+	}
+	else {
+	    for $header (qw(Pre-Depends Depends Suggests Recommends)) {
+		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" ;
 		}
-                print join(", ", sort @{$taskinfo{$task}{$header}}),"\n" ;
 	    }
 	}
 
+
 	# Description Description-long
 	print "Description: $taskinfo{$task}{Description}\n";
 	print "$taskinfo{$task}{'Description-long'}"; # Already contain newline
@@ -126,6 +141,75 @@
     }
 }
 
+sub print_task_desc {
+	if (! -d "tasksel") {
+		mkdir("tasksel") || die "mkdir tasksel: $!";
+	}
+	
+	foreach my $task (sort keys %taskinfo) {
+		next if (exists $taskinfo{$task}{'Leaf'} &&
+			$taskinfo{$task}{'Leaf'} eq 'false');
+		
+		print "Task: $task\n";
+		print "Section: debian-edu\n";
+		print "Description: $taskinfo{$task}{Description}\n";
+		print "$taskinfo{$task}{'Description-long'}"; # Already contain newline
+		print "Packages: task-files\n";
+		print "Relevance: 10\n";
+		print "Key: \n";
+		print " $task\n";
+		
+		print "\n";
+
+		open (OUT, ">tasksel/$task") || die "tasksel/$task: $!";
+		print OUT "$task\n";
+		foreach my $package (task_packages($task)) {
+			print OUT "$package\n";
+		}
+		close OUT;
+	}
+}
+
+sub task_packages {
+	my $task=shift;
+	my @packages=@_;
+	foreach my $package (@{$taskinfo{$task}{Depends}}) {
+		if ($package=~/\|/) {
+			# Tasksel doesn't allow boolean oring of
+			# dependencies. Just take the first one that is
+			# available.
+			my $ok=0;
+			foreach my $alternative (split(' | ', $package)) {
+	    			if (! exists $taskinfo{$alternative} &&
+				    ! exists $available{$alternative}) {
+				    	if (! exists $missing{$alternative}) {
+				    		$missing{$alternative} = 1;
+				    	}
+				}
+				else {
+					print STDERR "task_packages: choosing $alternative from $package\n" if $debug;
+					$package=$alternative;
+					$ok=1;
+					last;
+				}
+			}
+			if (! $ok) {
+				next;
+			}
+		}
+		if (exists $taskinfo{$package}) {
+			# Add packages from task recursively, since
+			# tasksel does not support dependent tasks of
+			# the type used by debian-edu
+			push @packages, $package, task_packages($package);
+		}
+		else {
+			push @packages, $package;
+		}
+	}
+	return @packages;
+}
+
 #
 # Check the APT cache, and find the packages currently available.
 #
@@ -331,11 +415,19 @@
 
 	$_ = $line;
 	$taskinfo{$curpkg}{'Section'}      = $1 if (m/^Section:\s+(.+)$/);
+	$taskinfo{$curpkg}{'Architecture'} = $1 if (m/^Architecture:\s+(.+)$/);
 	# This task name is needed in the Menu file but the former tag "Architecture"
 	# is never used and was left out here
 	$taskinfo{$curpkg}{'XBCS-Task'}    = $1 if (m/^Task:\s+(.+)$/);
 
 	$taskinfo{$curpkg}{'Priority'}     = $1 if (m/^Priority:\s+(.+)$/);
+	$taskinfo{$curpkg}{'Leaf'}         = $1 if (m/^Leaf:\s+(.+)$/);
+
+	# Set default architecture to all to be backward compatible
+	# with previous versions.  
+	if (!$taskinfo{$curpkg}{'Architecture'}) {
+	    $taskinfo{$curpkg}{'Architecture'} = 'all';
+	}
 
 	if (m/^Description:\s+(.+)$/) {
 	    $taskinfo{$curpkg}{'Description'} = $1;

Modified: cdd/trunk/cdd/debian/changelog
==============================================================================
--- cdd/trunk/cdd/debian/changelog	(original)
+++ cdd/trunk/cdd/debian/changelog	Tue Sep 28 11:33:09 2004
@@ -4,6 +4,14 @@
     - Fixed some man pages and examples
   * Guillem Jover
     - Added Catalan (ca) debconf translation.
+  * Otavio Salvador
+    - cdd-gen-control:
+      o Add -D suport to cdd-gen-control to degrade dependencies to
+        recommends; 
+      o Add support for architecture dependent packages;
+      o Add fallback to architecture independent packages so allow
+      o backward compatibility;
+      o Add suport to tasksel based tasks;
 
  -- Andreas Tille <tille@debian.org>  Sat, 21 Aug 2004 09:06:13 +0200