1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
#!/bin/sh
set -e
if [ -z "$CODENAME" ]; then
echo "update_tasks: codename not specified" >&2
exit 1
fi
if [ "$MIRROR"x = ""x ] ; then
echo "update_tasks: mirror dir not specified" >&2
exit 1
fi
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
}
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
}
update_essential_list () {
file=$1
tasklist=$2
tasksel=$3
(grep -Ev "^(#.*)?[[:space:]]*$" $tasklist ;
echo DONE ;
cat $tasksel/usr/share/tasksel/debian-tasks.desc) | 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
}
# 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=$(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
# Now grab the appropriate tasksel package
TASKSEL_DEB=$MIRROR/`mawk '
/^Package: tasksel-data$/ { found=1 }
/^Filename:/ { if (found==1) { print $2; exit } }' $TMP_PKG`
# 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/$(which_deb $MIRROR sid tasksel-data binary)
fi
dpkg -x $TASKSEL_DEB $TDIR/tasksel
[ -e task.languages ] || exit 1
grep -Ev "^(#.*)?[[:space:]]*$" task.languages > $TDIR/languages
for tlist in task.list.*; do
variant=${tlist##*.}
expand_task_list task.gen.$variant $tlist $TDIR/languages
# Create (empty) output files
: >task-essential-$variant
: >task-full-$variant
update_essential_list \
task-essential-$variant \
task.gen.$variant.primary \
$TDIR/tasksel
update_full_list \
task-full-$variant \
task.gen.$variant.primary \
$TMP_PKG
# 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
update_full_list \
task-full-$variant \
task.gen.$variant.secondary \
$TMP_PKG
fi
done
rm -rf $TDIR
|