debian-cd-clone/tools/update_tasks

153 lines
3.5 KiB
Plaintext
Raw Normal View History

#!/bin/sh
2008-06-07 00:27:20 +00:00
set -e
if [ -z "$CODENAME" ]; then
echo "update_tasks: codename not specified" >&2
2008-06-07 00:31:58 +00:00
exit 1
fi
2008-10-12 23:08:57 +00:00
if [ "$MIRROR"x = ""x ] ; then
echo "update_tasks: mirror dir not specified" >&2
exit 1
fi
2008-10-12 23:08:57 +00:00
if [ "$BDIR"x = ""x ] ; then
echo "update_tasks: temp dir not specified" >&2
2008-10-12 23:54:01 +00:00
exit 1
fi
TDIR=$BDIR/update_tasks
2008-10-12 23:54:01 +00:00
mkdir -p $TDIR
2008-10-12 23:08:57 +00:00
update_full_list () {
2008-06-07 00:31:58 +00:00
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) {
2008-06-07 19:31:29 +00:00
# Parse the Tasks: line, splitting into array "these"
gsub("Task: ", "", $0)
gsub(",", "", $0)
split($0, these)
2008-06-07 19:31:29 +00:00
# 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
}
update_essential_list () {
2008-06-07 00:31:58 +00:00
file=$1
tasklist=$2
desktoptasks=$3
tasksel=$4
(grep -Ev "^(#.*)?[[:space:]]*$" $tasklist ;
echo DONE ;
cat $tasksel/usr/share/tasksel/debian-tasks.desc) | mawk -v DT=$desktoptasks '
BEGIN {
split(DT, d_tasks, ",")
}
/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) {
if ((cur_task != "gnome-desktop") &&
(cur_task != "kde-desktop") &&
(cur_task != "xfce-desktop")) {
in_key = 1
}
for (dt_num in d_tasks) {
if (cur_task == d_tasks[dt_num]) {
in_key = 1
}
}
}
}
}
next
}' | sort -s -n -k1 | cut -d: -f2 > $file
}
# We need to gunzip a copy of the appropriate Packages.gz file
# Assume i386, use the $CODENAME main Packages file
2008-10-12 23:54:01 +00:00
TMP_PKG=$TDIR/Packages
zcat $MIRROR/dists/$CODENAME/main/binary-i386/Packages.gz > $TMP_PKG
# Now grab the appropriate tasksel package
TASKSEL_DEB=$MIRROR/`mawk '
/^Package: tasksel-data$/ { found=1 }
/^Filename:/ { if (found==1) { print $2; exit } }' $TMP_PKG`
2008-10-12 23:54:01 +00:00
dpkg -x $TASKSEL_DEB $TDIR/tasksel
update_essential_list task-essential task.list gnome-desktop \
2008-10-12 23:54:01 +00:00
$TDIR/tasksel
update_essential_list task-essential-kde task.list.kde kde-desktop \
2008-10-12 23:54:01 +00:00
$TDIR/tasksel
update_essential_list task-essential-xfce task.list.xfce xfce-desktop \
2008-10-12 23:54:01 +00:00
$TDIR/tasksel
update_full_list task-full task.list $TMP_PKG
update_full_list task-full-kde task.list.kde $TMP_PKG
update_full_list task-full-xfce task.list.xfce $TMP_PKG
rm -rf $TDIR