Browse Source

* Add support for preinst, postinst, prerm and postrm scripts for tasks.

* Add preinst script for desktop task, to install read-edid and mdetect
  for X server autoconfiguration.
* Clean up executation of commands.
tags/2.39
Joey Hess 15 years ago
parent
commit
5b76476774
10 changed files with 114 additions and 54 deletions
  1. +4
    -0
      Makefile
  2. +8
    -1
      README
  3. +5
    -1
      debian/changelog
  4. +1
    -4
      debian/copyright
  5. +1
    -1
      debian/po/lt.po
  6. +13
    -0
      info/desktop.preinst
  7. +3
    -3
      po/tasksel.pot
  8. +3
    -0
      tasks/desktop
  9. +2
    -2
      tasks/po/lt.po
  10. +74
    -42
      tasksel.pl

+ 4
- 0
Makefile View File

@@ -32,6 +32,7 @@ updatetaskspo:
install:
install -d $(DESTDIR)/usr/bin $(DESTDIR)$(TASKDIR) \
$(DESTDIR)/usr/lib/tasksel/tests \
$(DESTDIR)/usr/lib/tasksel/info \
$(DESTDIR)/usr/lib/tasksel/packages \
$(DESTDIR)/usr/share/man/man8
install -m 755 tasksel.pl $(DESTDIR)/usr/bin/tasksel
@@ -49,6 +50,9 @@ install:
for test in tests/*; do \
install -m 755 $$test $(DESTDIR)/usr/lib/tasksel/tests/; \
done
for script in info/*; do \
install -m 755 $$script $(DESTDIR)/usr/lib/tasksel/info/; \
done
for package in packages/*; do \
install -m 755 $$package $(DESTDIR)/usr/lib/tasksel/packages/; \
done


+ 8
- 1
README View File

@@ -18,7 +18,7 @@ debian-tasks.desc to remove tasks.

The file format is a rfc-822 style stanza, with fields named Task, Section,
Description (which should include an extended description), Key, Packages,
Depends, and optional Test- and Source fields. Here is an example:
Depends, Test- and Relevance fields. Here is an example:

Task: graphical-games
Section: user
@@ -83,3 +83,10 @@ listed as dependencies are installed.
If a task is important enough that it should go near the top of its
section, give it a relevance of 9 or 10. If a task is not likely to be
used, give it a relevance of 1. Default is 5.

tasksel also supports preinst, postinst, prerm, and postrm scripts for
tasks. These are run before a task is installed, and after it is removed as
with the dpkg scripts. These scripts sould be installed in
/usr/lib/tasksel/info/, for example, /usr/lib/tasksel/info/desktop.preinst.
Currently they are passed no parameters, but this might change later. These
scripts should take care not to output anything to stdout.

+ 5
- 1
debian/changelog View File

@@ -12,8 +12,12 @@ tasksel (2.39) UNRELEASED; urgency=low
[ Joey Hess ]
* Uncomment the now-available sa-exim in mail server task.
* Add cpufrequtils to laptop.
* Add support for preinst, postinst, prerm and postrm scripts for tasks.
* Add preinst script for desktop task, to install read-edid and mdetect
for X server autoconfiguration.
* Clean up executation of commands.

-- Joey Hess <joeyh@debian.org> Thu, 29 Dec 2005 07:14:56 -0500
-- Joey Hess <joeyh@debian.org> Mon, 2 Jan 2006 15:09:12 -0500

tasksel (2.38) unstable; urgency=low



+ 1
- 4
debian/copyright View File

@@ -1,6 +1,3 @@
This package was debianized by Randolph Chung <tausq@debian.org> on
Wed, 8 Dec 1999 21:41:46 -0700.

Upstream Authors: Randolph Chung and Joey Hess
Authors: Randolph Chung and Joey Hess

Copyright: GPLv2, see /usr/share/common-licenses/GPL

+ 1
- 1
debian/po/lt.po View File

@@ -13,7 +13,7 @@ msgstr ""
"Language-Team: Lithuanian <komp_lt@konferencijos.lt>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit"
"Content-Transfer-Encoding: 8bit\n"

#. Type: multiselect
#. Description


+ 13
- 0
info/desktop.preinst View File

@@ -0,0 +1,13 @@
#!/bin/sh
set -e

# Neither mdetect or read-edid are strictly needed, but they make X
# autoconfiguration work better. Need to install them before X is
# preconfigured. Note that they are also listed as part of the task, which
# will take care of their removal when the task is removed.
for pkg in mdetect read-edid; do
if apt-cache show "$pkg" >/dev/null 2>&1 &&
! dpkg --get-selections | grep "$pkg" | grep -q install; then
apt-get -q -y -f install $pkg >/dev/null || true
fi
done

+ 3
- 3
po/tasksel.pot View File

@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2005-12-25 17:19-0500\n"
"POT-Creation-Date: 2006-01-02 15:28-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../tasksel.pl:328
#: ../tasksel.pl:358
msgid ""
"Usage:\n"
"tasksel install <task>\n"
@@ -29,6 +29,6 @@ msgid ""
"\t --task-desc returns the description of a task\n"
msgstr ""

#: ../tasksel.pl:526 ../tasksel.pl:542 ../tasksel.pl:556
#: ../tasksel.pl:557 ../tasksel.pl:575 ../tasksel.pl:586
msgid "aptitude failed"
msgstr ""

+ 3
- 0
tasks/desktop View File

@@ -31,3 +31,6 @@ Packages-list:
# enough basic X stuff here for a minally useful desktop without them.
twm
xterm
# support for X autoconfiguration. See also the desktop.preinst script.
read-edid
mdetect

+ 2
- 2
tasks/po/lt.po View File

@@ -7,13 +7,13 @@ msgid ""
msgstr ""
"Project-Id-Version: tasksel_tasks\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2005-11-18 14:45-0500\n"
"POT-Creation-Date: 2006-01-02 15:28-0500\n"
"PO-Revision-Date: 2005-12-27 00:37+0200\n"
"Last-Translator: Kęstutis Biliūnas <kebil@kaunas.init.lt>\n"
"Language-Team: Lithuanian <komp_lt@konferencijos.lt>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit"
"Content-Transfer-Encoding: 8bit\n"

#. Description
#: ../po/debian-tasks.desc:3


+ 74
- 42
tasksel.pl View File

@@ -1,6 +1,6 @@
#!/usr/bin/perl
# Debian task selector, mark II.
# Copyright 2004 by Joey Hess <joeyh@debian.org>.
# Copyright 2004-2006 by Joey Hess <joeyh@debian.org>.
# Licensed under the GPL, version 2 or higher.
use Locale::gettext;
use Getopt::Long;
@@ -14,6 +14,8 @@ my $packagesdir="/usr/lib/tasksel/packages";
my $descdir="/usr/share/tasksel";
my $localdescdir="/usr/local/share/tasksel";
my $statusfile="/var/lib/dpkg/status";
my $infodir="/usr/lib/tasksel/info";
my $testmode=0;

sub warning {
print STDERR "tasksel: @_\n";
@@ -24,6 +26,19 @@ sub error {
exit 1;
}

# Run a shell command except in test mode, and returns its exit code.
# Prints the command in test mode. Parameters should be pre-split for
# system.
sub run {
if ($testmode) {
print join(" ", @_)."\n";
return 0;
}
else {
return system(@_) >> 8;
}
}

# A list of all available task desc files.
sub list_task_descs {
return glob("$descdir/*.desc"), glob("$localdescdir/*.desc");
@@ -324,6 +339,21 @@ sub name_to_task {
return (grep { $_->{task} eq $name } @_)[0];
}

sub task_script {
my $task=shift;
my $script=shift;

my $path="$infodir/$task.$script";
if (-e $path && -x _) {
my $ret=run($path);
if ($ret != 0) {
warning("$path exited with nonzero code $ret");
return 0;
}
}
return 1;
}

sub usage {
print STDERR gettext(q{Usage:
tasksel install <task>
@@ -360,11 +390,14 @@ sub getopts {
usage();
exit 1;
}
$testmode=1 if $ret{test}; # set global
return %ret;
}

sub main {
my %options=getopts();
my @tasks_remove;
my @tasks_install;

# Options that output stuff and don't need a full processed list of
# tasks.
@@ -410,10 +443,9 @@ sub main {
my $task=name_to_task($options{"install"}, @tasks);
$task->{_install} = 1 if $task;
}
my @aptitude_remove;
if ($options{"remove"}) {
my $task=name_to_task($options{"remove"}, @tasks);
push @aptitude_remove, task_packages($task, 0);
push @tasks_remove, $task;
}
# The interactive bit.
@@ -470,12 +502,12 @@ sub main {
}
foreach my $task (@list) {
if (! $task->{_selected} && $task->{_installed}) {
push @aptitude_remove, task_packages($task, 0);
push @tasks_remove, $task;
}
}
}

# Mark dependnent packages for install if their dependencies are met.
# Mark dependenent tasks for install if their dependencies are met.
foreach my $task (@tasks) {
if (! $task->{_install} && exists $task->{depends} && length $task->{depends} ) {
$task->{_install} = 1;
@@ -489,74 +521,74 @@ sub main {

# Add tasks to install and see if any selected task requires manual
# selection.
my @aptitude_install;
my $manual_selection=0;
foreach my $task (grep { $_->{_install} } @tasks) {
push @aptitude_install, task_packages($task, 1);
push @tasks_install, $task;
if ($task->{packages} eq 'manual') {
$manual_selection=1;
}
}
my $aptitude;
my @aptitude;
if ($manual_selection) {
# Manaul selection and task installs, as best
# aptitude can do it currently. Disables use of
# debconf-apt-progress.
$aptitude="aptitude";
@aptitude="aptitude";
}
elsif (-x "/usr/bin/debconf-apt-progress") {
$aptitude="debconf-apt-progress";
$aptitude.=" $options{'debconf-apt-progress'}"
@aptitude="debconf-apt-progress";
push @aptitude, split(' ', $options{'debconf-apt-progress'})
if exists $options{'debconf-apt-progress'};
$aptitude.=" -- aptitude -q";
push @aptitude, qw{-- aptitude -q};
}
else {
$aptitude="aptitude";
@aptitude="aptitude";
}

# Remove any packages we were asked to.
if (@aptitude_remove) {
if ($options{test}) {
print "$aptitude -y remove ".join(" ", @aptitude_remove)."\n";
# Task removal..
if (@tasks_remove) {
my @packages_remove=map { task_packages($_, 0) } @tasks_remove;
foreach my $task (@tasks_remove) {
task_script($task->{task}, "prerm");
}
else {
my $ret=system(split(' ', $aptitude), "-y", "remove", @aptitude_remove) >> 8;
if ($ret != 0) {
error gettext("aptitude failed")." ($ret)";
}
my $ret=run(@aptitude, "-y", "remove", @packages_remove);
if ($ret != 0) {
error gettext("aptitude failed")." ($ret)";
}
foreach my $task (@tasks_remove) {
task_script($task->{task}, "postrm");
}
}
# And finally, act on selected tasks.
if (@aptitude_install || $manual_selection) {
# If the user selected no tasks and manual package
if (@tasks_install || $manual_selection) {
my @packages_install=map {task_packages($_, 1) } @tasks_install;
foreach my $task (@tasks_install) {
task_script($task->{task}, "preinst");
}
# If the user selected no other tasks and manual package
# selection, run aptitude w/o the --visual-preview parameter.
if (! @aptitude_install && $manual_selection) {
if ($options{test}) {
print "aptitude\n";
}
else {
my $ret=system("aptitude") >> 8;
if ($ret != 0) {
error gettext("aptitude failed")." ($ret)";
}
if (! @packages_install && $manual_selection) {
my $ret=run("aptitude");
if ($ret != 0) {
error gettext("aptitude failed")." ($ret)";
}
}
else {
if ($manual_selection) {
unshift @aptitude_install, "--visual-preview";
unshift @packages_install, "--visual-preview";
}
if ($options{test}) {
print "$aptitude --without-recommends -y install ".join(" ", @aptitude_install)."\n";
}
else {
my $ret=system(split(' ', $aptitude), "--without-recommends", "-y", "install", @aptitude_install) >> 8;
if ($ret != 0) {
error gettext("aptitude failed");
}
my $ret=run(@aptitude, "--without-recommends",
"-y", "install",
@packages_install);
if ($ret != 0) {
error gettext("aptitude failed")." ($ret)";
}
}
foreach my $task (@tasks_install) {
task_script($task->{task}, "postinst");
}
}
}



Loading…
Cancel
Save