diff --git a/Makefile b/Makefile index 57c68d23..1e57c3ca 100755 --- a/Makefile +++ b/Makefile @@ -136,9 +136,6 @@ ifneq ($(ARCHES),source) $(Q)mkdir -p $(TASKDIR) $(Q)echo "- copying task files from 'tasks/$(DI_CODENAME)/'" $(Q)cp -r $(BASEDIR)/tasks/$(CODENAME)/* $(TASKDIR) - $(Q)echo "- task.languages: using 'tasks/$(DI_CODENAME)/$(TASK_LANGLIST)'" - $(Q)cp $(BASEDIR)/tasks/$(DI_CODENAME)/$(TASK_LANGLIST) \ - $(TASKDIR)/task.languages $(Q)echo "- generating dynamic task files" $(Q)set -e; cd $(TASKDIR); \ $(BASEDIR)/tools/update_tasks; \ diff --git a/debian/changelog b/debian/changelog index a693b8df..8dc3165f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ debian-cd (3.1.9) UNRELEASED; urgency=low * Describe discs appropriately depending on the kernel used. Closes: #673975 * Clean up handling of environment variable handling in perl tools. + * Switch over to working with new task-* metapackages. Closes: #672941 -- Steve McIntyre <93sam@debian.org> Tue, 29 May 2012 06:20:20 +0800 diff --git a/tools/update_tasks b/tools/update_tasks index 5b4bfcd0..146f5f93 100755 --- a/tools/update_tasks +++ b/tools/update_tasks @@ -1,222 +1,253 @@ -#!/bin/sh -set -e +#!/usr/bin/perl -w -if [ -z "$CODENAME" ]; then - echo "update_tasks: codename not specified" >&2 - exit 1 -fi +use strict; -if [ "$MIRROR"x = ""x ] ; then - echo "update_tasks: mirror dir not specified" >&2 - exit 1 -fi +my $arch; +my $old_split = $/; +my (@desktop_tasks, @user_tasks, @l10n_tasks, @server_tasks, @special_tasks); +my ($section, $taskname); -if [ "$BDIR"x = ""x ] ; then - echo "update_tasks: temp dir not specified" >&2 - exit 1 -fi -TDIR=$BDIR/update_tasks -mkdir -p $TDIR - -# Sort primary and secondary tasks and add language tasks for both -# Secondary tasks are indicated by a "-" suffix in the task.list file -# When adding language tasks, 'desktop' is sorted before '*-desktop' -expand_task_list () { - outbase=$1 - tasklist=$2 - langlist=$3 - - # Filter out comments, empty lines and secondary tasks - task_primary="$(grep -Ev "^(#.*)?(.*-)?[[:space:]]*$" $tasklist)" - # Select only secondary tasks - task_secondary="$(grep -Ev "^(#.*)?[[:space:]]*$" $tasklist | \ - grep -E "(.*-)[[:space:]]*$" | sed "s/[[:space:]]\+-.*$//")" - - echo "# Primary main tasks" >$outbase.primary - echo "$task_primary" >>$outbase.primary - - echo >>$outbase.primary - echo "# Primary language tasks" >>$outbase.primary - for task in "" $(echo "$task_primary" | grep "^desktop" || true) \ - $(echo "$task_primary" | grep -- "-desktop" || true); do - for language in $(cat $langlist); do - echo $language${task:+-$task} - done - done >>$outbase.primary - - rm -f $outbase.secondary - if [ "$task_secondary" ]; then - echo "# Secondary main tasks" >$outbase.secondary - echo "$task_secondary" >>$outbase.secondary - - echo >>$outbase.secondary - echo "# Secondary language tasks" >>$outbase.secondary - for task in $(echo "$task_secondary" | grep "^desktop" || true) \ - $(echo "$task_secondary" | grep -- "-desktop" || true); do - for language in $(cat $langlist); do - echo $language-$task - done - done >>$outbase.secondary - fi +my $codename = $ENV{'CODENAME'}; +if (! defined($codename)) { + die "update_tasks: codename not specified\n"; } -update_full_list () { - file=$1 - tasklist=$2 - pkgfile=$3 - - (grep -Ev "^(#.*)?[[:space:]]*$" $tasklist ; echo DONE ; cat $pkgfile) | mawk ' - /DONE/ { - in_packages = 1 - next - } - /.*/ { - if (!in_packages) { - tasklist[$1] = num_tasks - num_tasks++ - } - } - /^Package: / { - if (in_packages) { - pkgname = $2 - next - } - } - /^Task: / { - if (in_packages) { - # Parse the Tasks: line, splitting into array "these" - gsub("Task: ", "", $0) - gsub(",", "", $0) - split($0, these) - - # And see if we have any matches - for (task in these) { - for (taskname in tasklist) { - if (these[task] == taskname) { - printf("%d:%s\n", tasklist[taskname], pkgname) - next - } - } - } - } - next - }' | sort -n | cut -d: -f2 >> $file +my $mirror = $ENV{'MIRROR'}; +if (! defined($mirror)) { + die "update_tasks: mirror not specified\n"; } -update_essential_list () { - file=$1 - tasklist=$2 - tasksel=$3 - - file=$tasksel/usr/share/tasksel/descs/debian-tasks.desc - if [ ! -e $file ]; then - file=$tasksel/usr/share/tasksel/debian-tasks.desc - fi - - (grep -Ev "^(#.*)?[[:space:]]*$" $tasklist ; - echo DONE ; - cat $file) | mawk ' - - /DONE/ { - in_tasks = 1 - next - } - /^ / { - if (in_key) { - printf("%d:%s\n", tasklist[cur_task], $1) - next - } - } - /.*/ { - if (!in_tasks) { - tasklist[$1] = num_tasks - num_tasks++ - } - if (in_key) { - in_key = 0 - } - } - /^Task: / { - if (in_tasks) { - cur_task = $2 - next - } - } - /^Key: / { - if (in_tasks) { - for (taskname in tasklist) { - if (taskname == cur_task) { - in_key = 1 - } - } - } - next - }' | sort -s -n -k1 | cut -d: -f2 >> $file +my $bdir = $ENV{'BDIR'}; +if (! defined($bdir)) { + die "update_tasks: temp dir not specified\n"; } -# Look for the coreutils package (which should exist in all archs, and is -# a non -all package) to determine a valid arch for the rest of this -# script -arch=$($BASEDIR/tools/which_deb $MIRROR $CODENAME coreutils binary | sed -e "s/\.deb//" -e "s/.*_//") -# We need to gunzip a copy of the appropriate Packages.gz file(s) -TMP_PKG=$TDIR/Packages -zcat $MIRROR/dists/$CODENAME/main/binary-$arch/Packages.gz > $TMP_PKG -if [ -n "$LOCAL" ] ; then - if [ -n "$LOCALDEBS" ] ; then - zcat $LOCALDEBS/dists/$CODENAME/local/binary-$arch/Packages.gz >> $TMP_PKG - else - zcat $MIRROR/dists/$CODENAME/local/binary-$arch/Packages.gz >> $TMP_PKG - fi -fi +my $basedir = $ENV{'BASEDIR'}; +if (! defined($basedir)) { + die "update_tasks: basedir not specified\n"; +} -# Now grab the appropriate tasksel package -TASKSEL_DEB=$MIRROR/`mawk ' - /^Package: tasksel-data$/ { found=1 } - /^Filename:/ { if (found==1) { print $2; exit } }' $TMP_PKG` +my $tdir = "$bdir/update_tasks"; +system("mkdir -p $tdir"); + +# Look for the coreutils package (which should exist in all archs, and +# is a non -all package) to determine a valid arch for the rest of +# this script +my $coreutils_deb = `$basedir/tools/which_deb $mirror $codename coreutils binary`; +if ($coreutils_deb =~ m/_([[:alnum:]]+)\.deb/) { + $arch = $1; +} else { + die "update_tasks: Can't determine arch!\n"; +} + +# Extract the tasksel-data deb for our suite; we need to parse the +# data in it +my $tasksel_deb = `$basedir/tools/which_deb $mirror $codename tasksel-data binary`; # For testing purposes - set up FORCE_SID_TASKSEL to force us to use # sid's tasksel data even if we're using stable/testing. -if [ "$FORCE_SID_TASKSEL"x = "1"x ] ; then - echo "update_tasks: forcing use of the sid tasksel-data tasks" - TASKSEL_DEB=$MIRROR/$($BASEDIR/tools/which_deb $MIRROR sid tasksel-data binary) -fi +if (defined($ENV{'FORCE_SID_TASKSEL'}) and $ENV{'FORCE_SID_TASKSEL'} eq '1') { + print "update_tasks: forcing use of the sid tasksel-data tasks\n"; + $tasksel_deb = `$basedir/tools/which_deb $mirror sid tasksel-data binary`; +} -dpkg -x $TASKSEL_DEB $TDIR/tasksel +$tasksel_deb = "$mirror/$tasksel_deb"; +chomp $tasksel_deb; -[ -e task.languages ] || exit 1 -grep -Ev "^(#.*)?[[:space:]]*$" task.languages > $TDIR/languages +# Several types of task package we care about: +# +# task-$DESKTOP-desktop - core package set for desktop $DESKTOP +# task-$LANGUAGE - core package set for language $LANGUAGE +# task-$LANGUAGE-desktop - general desktop i18n packages for $LANGUAGE +# task-$LANGUAGE-$DESKTOP-desktop - i18n packages for $DESKTOP, $LANGUAGE +# task-$FOO - package set for $FOO (mail-server, laptop, etc.) +# +# VERY much complicated by the freeform style of the names here: +# * languages can be 1, 2 or 3 words (eg. english, brazilian-portuguese, south-african-english) +# * non-desktop tasks can be 1 or 2 words (e.g. laptop, file-server) +# +# Need to parse debian-tasks.desc to work out what each type is -for tlist in task.list.*; do - variant=${tlist##*.} +system("dpkg -x $tasksel_deb $tdir/tasksel"); - expand_task_list task.gen.$variant $tlist $TDIR/languages +my $descfile = "usr/share/tasksel/descs/debian-tasks.desc"; - # Create (empty) output files - : >task-essential-$variant - : >task-full-$variant +open (TASKS, "$tdir/tasksel/$descfile") + or die "can't open $tdir/tasksel/$descfile: $!\n"; - update_essential_list \ - task-essential-$variant \ - task.gen.$variant.primary \ - $TDIR/tasksel +while (defined (my $task = )) { + chomp $task; + if ($task =~ m/^Task: (\S+)/) { + $taskname = $1; + } + if ($task =~ m/^Section: (\S+)/) { + $section = $1; + if ($section eq "l10n") { + push (@l10n_tasks, $taskname); + } elsif ($section eq "server") { + push (@server_tasks, $taskname); + } elsif ($section eq "user") { + if ($taskname =~ m/^[[:alnum:]]+-desktop/) { + push (@desktop_tasks, $taskname); + } else { + push (@user_tasks, $taskname); + } + } elsif ($section eq "special") { + push (@special_tasks, $taskname); + } else { + die "update_tasks: task $taskname has unknown section $section!\n"; + } - update_full_list \ - task-full-$variant \ - task.gen.$variant.primary \ - $TMP_PKG + } +} +close TASKS; - # Now add packages for secondary tasks; start with Key packages again - if [ -e task.gen.$variant.secondary ]; then - update_essential_list \ - task-full-$variant \ - task.gen.$variant.secondary \ - $TDIR/tasksel +#print "l10n: @l10n_tasks\n"; +#print "desktop: @desktop_tasks\n"; +#print "user: @user_tasks\n"; +#print "server: @server_tasks\n"; +#print "special: @special_tasks\n"; - update_full_list \ - task-full-$variant \ - task.gen.$variant.secondary \ - $TMP_PKG - fi -done +# Reduce special-casing and duplicate code. Add "generic-desktop" and +# "all-desktop" tasks that we can use here. +push (@desktop_tasks, "generic-desktop"); +push (@desktop_tasks, "all-desktop"); -rm -rf $TDIR +# Write out all the groupings +foreach my $desktop (@desktop_tasks) { + my $filename; + my $desktop_name = $desktop; + $desktop_name =~ s/-desktop//g; + + # Essential; $DESKTOP + $filename = "task-essential-$desktop_name"; + open (DESKOUT, "> $filename") or die "can't open file $filename for writing, $!\n"; + + # in all-desktop, add all the desktop tasks + if ($desktop_name eq "all") { + foreach my $taskname (@desktop_tasks) { + print DESKOUT "task-$taskname\n"; + } + } elsif ($desktop_name eq "generic") { + print DESKOUT "task-gnome-desktop\n"; + } else { + print DESKOUT "task-$desktop\n"; + } + + # generic-desktop and all-desktop want all the server and user + # tasks included too + if ($desktop_name eq "all" or $desktop_name eq "generic") { + foreach my $taskname (@user_tasks) { + print DESKOUT "task-$taskname\n"; + } + foreach my $taskname (@server_tasks) { + print DESKOUT "task-$taskname\n"; + } + } + close DESKOUT; + + # Full; $DESKTOP + $filename = "task-full-$desktop_name"; + open (DESKOUT, "> $filename") or die "can't open file $filename for writing, $!\n"; + + # in all-desktop, add all the desktop tasks now + if ($desktop_name eq "all") { + foreach my $taskname (@desktop_tasks) { + print DESKOUT "task-$taskname\n"; + } + } elsif ($desktop_name eq "generic") { + print DESKOUT "task-gnome-desktop\n"; + } else { + print DESKOUT "task-$desktop\n"; + } + + # generic-desktop and all-desktop want all the server and user + # tasks included too + if ($desktop_name eq "all" or $desktop_name eq "generic") { + foreach my $taskname (@user_tasks) { + print DESKOUT "task-$taskname\n"; + } + foreach my $taskname (@server_tasks) { + print DESKOUT "task-$taskname\n"; + } + } + + # task-$LANGUAGE, same for all flavours + foreach my $taskname (@l10n_tasks) { + if ($taskname !~ m/desktop/) { + print DESKOUT "task-$taskname\n"; + } + } + + # task-$LANGUAGE-desktop, same for all flavours + foreach my $taskname (@l10n_tasks) { + if ($taskname =~ m/desktop/) { + my $include = 1; + foreach my $dsk (@desktop_tasks) { + if ($taskname =~ m/$dsk/) { + $include = 0; + last; + } + } + if ($include) { + print DESKOUT "task-$taskname\n"; + } + } + } + + # in all-desktop, add all the desktop l10n tasks + if ($desktop_name eq "all") { + # task-$LANGUAGE-$DESKTOP-desktop + foreach my $taskname (@l10n_tasks) { + foreach my $dsk (@desktop_tasks) { + if ($taskname =~ m/$dsk/) { + print DESKOUT "task-$taskname\n"; + } + } + } + + } elsif ($desktop_name eq "generic") { + # in generic-desktop, add the desktop l10n tasks as though for + # Gnome *first*. Others will come later + + # task-$LANGUAGE-$DESKTOP-desktop + foreach my $taskname (@l10n_tasks) { + if ($taskname =~ m/gnome/) { + print DESKOUT "task-$taskname\n"; + } + } + # task-!gnome-desktop + foreach my $taskname (@desktop_tasks) { + if ($taskname !~ m/gnome/) { + print DESKOUT "task-$taskname\n"; + } + } + + # task-$LANGUAGE-!gnome-desktop + foreach my $taskname (@l10n_tasks) { + if ($taskname =~ m/desktop$/) { + my $include = 0; + foreach my $dsk (@desktop_tasks) { + if ($dsk !~ m/gnome/ and $taskname =~ m/$dsk/) { + $include = 1; + last; + } + } + if ($include) { + print DESKOUT "task-$taskname\n"; + } + } + } + } else { + # a specific desktop, just add the desktop l10n tasks for this + # desktop + + # task-$LANGUAGE-$DESKTOP-desktop + foreach my $taskname (@l10n_tasks) { + if ($taskname =~ m/$desktop_name/) { + print DESKOUT "task-$taskname\n"; + } + } + } + close DESKOUT; +}