~gilir/+junk/tasksel-lubuntu-support

« back to all changes in this revision

Viewing changes to tasksel.pl

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2009-02-17 17:06:14 UTC
  • Revision ID: james.westby@ubuntu.com-20090217170614-3udm5qfxqxi92ryp
Tags: 2.73ubuntu14
Offer manual package selection via aptitude if the cdebconf terminal
plugin is available (LP: #21570).

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
my $debconf_helper="/usr/lib/tasksel/tasksel-debconf";
13
13
my $filter_tasks="/usr/lib/tasksel/filter-tasks";
 
14
my $disconnect="/usr/lib/tasksel/disconnect";
14
15
my $testdir="/usr/lib/tasksel/tests";
15
16
my $packagesdir="/usr/lib/tasksel/packages";
16
17
my $descdir="/usr/share/tasksel";
41
42
        }
42
43
}
43
44
 
 
45
sub run_disconnect {
 
46
        if ($testmode) {
 
47
                print join(" ", @_)."\n";
 
48
                return 0;
 
49
        }
 
50
        else {
 
51
                return system($disconnect, @_) >> 8;
 
52
        }
 
53
}
 
54
 
44
55
# A list of all available task desc files.
45
56
sub list_task_descs {
46
57
        return glob("$descdir/*.desc"), glob("$localdescdir/*.desc");
194
205
}
195
206
 
196
207
# Given task hash, returns a list of all available packages in the task.
197
 
# If the apt_get_tasks parameter is true, then it does not expand tasks
198
 
# that apt-get knows about, and just returns apt-get task syntax for
199
 
# those.
 
208
# If the aptitude_tasks or apt_get_tasks parameter is true, then it does
 
209
# not expand tasks that aptitude/apt-get knows about, and just returns
 
210
# aptitude/apt-get task syntax for those.
200
211
sub task_packages {
201
212
        my $task=shift;
 
213
        my $aptitude_tasks=shift;
202
214
        my $apt_get_tasks=shift;
203
215
        
204
216
        my %list;
210
222
                
211
223
        if ($task->{packages} eq 'task-fields') {
212
224
                # task-fields method is built-in for speed and to support
213
 
                # apt-get task definitions
214
 
                if ($apt_get_tasks) {
 
225
                # aptitude/apt-get task definitions
 
226
                if ($aptitude_tasks) {
 
227
                        return '~t^'.$task->{task}.'$';
 
228
                }
 
229
                elsif ($apt_get_tasks) {
215
230
                        return $task->{task}.'^';
216
231
                }
217
232
                else {
675
690
        my $dap;
676
691
        my ($dap_from, $dap_to);
677
692
        my @dap_options;
678
 
        my @apt;
 
693
        my (@aptitude, @apt);
679
694
        if ($manual_selection) {
680
695
                # Manaul selection and task installs, as best
681
696
                # aptitude can do it currently. Disables use of
682
697
                # debconf-apt-progress.
683
 
                @apt="aptitude";
 
698
                @aptitude="aptitude";
684
699
        }
685
700
        elsif (-x "/usr/bin/debconf-apt-progress") {
686
701
                $dap="debconf-apt-progress";
691
706
                }
692
707
                push @dap_options, split(' ', $options{'debconf-apt-progress'})
693
708
                        if exists $options{'debconf-apt-progress'};
 
709
                @aptitude=qw{aptitude -q};
694
710
                @apt=qw{apt-get -q};
695
711
        }
696
712
        else {
 
713
                @aptitude="aptitude";
697
714
                @apt="apt-get";
698
715
        }
699
716
 
722
739
        
723
740
        # And finally, act on selected tasks.
724
741
        if (@tasks_install || @tasks_remove || $manual_selection) {
725
 
                my @args;
 
742
                my (@aptitude_args, @apt_args);
726
743
                foreach my $task (@tasks_remove) {
727
 
                        push @args, map { "$_-" } task_packages($task, 0);
 
744
                        my @args = map { "$_-" } task_packages($task, 0, 0);
 
745
                        push @aptitude_args, @args;
 
746
                        push @apt_args, @args;
728
747
                        my $path=find_task_script($task->{task}, "prerm");
729
748
                        if (defined $path) {
730
749
                                my @prefix=task_region($dap, $dap_from, $dap_to, \@dap_options, $cur_region++, 1, $num_regions);
732
751
                        }
733
752
                }
734
753
                foreach my $task (@tasks_install) {
735
 
                        push @args, task_packages($task, 1);
 
754
                        push @aptitude_args, task_packages($task, 1, 0);
 
755
                        push @apt_args, task_packages($task, 0, 1);
736
756
                        my $path=find_task_script($task->{task}, "preinst");
737
757
                        if (defined $path) {
738
758
                                my @prefix=task_region($dap, $dap_from, $dap_to, \@dap_options, $cur_region++, 1, $num_regions);
741
761
                }
742
762
                # If the user selected no other tasks and manual package
743
763
                # selection, run aptitude w/o the --visual-preview parameter.
744
 
                if (! @args && $manual_selection) {
745
 
                        my $ret=run("aptitude");
 
764
                if (! @aptitude_args && $manual_selection) {
 
765
                        my $ret=run_disconnect("aptitude");
746
766
                        if ($ret != 0) {
747
767
                                error gettext("aptitude failed")." ($ret)";
748
768
                        }
749
769
                }
750
770
                else {
751
 
                        if ($manual_selection) {
752
 
                                unshift @args, "--visual-preview";
753
 
                        }
754
771
                        my @prefix;
755
772
                        if (defined $dap_from and defined $dap_to) {
756
773
                                if ($num_regions) {
764
781
                        } elsif (defined $dap) {
765
782
                                @prefix=($dap, @dap_options, '--');
766
783
                        }
767
 
                        my $ret=run(@prefix, @apt, "-y", "install", @args);
 
784
                        my $ret;
 
785
                        if ($manual_selection) {
 
786
                                $ret=run(@aptitude, "-y", "--schedule-only", "install", @aptitude_args);
 
787
                        } else {
 
788
                                $ret=run(@prefix, @apt, "-y", "install", @apt_args);
 
789
                        }
768
790
                        if ($ret != 0) {
769
791
                                error gettext("aptitude failed")." ($ret)";
770
792
                        }
 
793
 
 
794
                        if ($manual_selection) {
 
795
                                $ret=run_disconnect(@prefix, @aptitude);
 
796
                                if ($ret != 0) {
 
797
                                        error gettext("aptitude failed")." ($ret)";
 
798
                                }
 
799
                        }
771
800
                }
772
801
                foreach my $task (@tasks_remove) {
773
802
                        my $path=find_task_script($task->{task}, "postrm");