You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.7 KiB

#!/bin/sh
set -e
. /usr/share/debconf/confmodule
db_capb backup
gendir=/usr/lib/apt-setup/generators
if [ "$1" = --log-output ] && type log-output >/dev/null 2>&1; then
CATCHLOG=1
shift
else
CATCHLOG=
fi
export CATCHLOG
if [ "$1" ]; then
ROOT="$1"
chroot=chroot
else
ROOT=
chroot=
fi
export ROOT
# generators/01setup will create this; apt honours it (see apt.conf(5))
export APT_CONFIG=/etc/apt/apt.conf.new
log() {
logger -t apt-setup "$@"
}
warning() {
log "warning: $@"
}
gencount=`ls "$gendir"/* | wc -l`
db_progress START 0 $gencount apt-setup/progress/title
for generator in $gendir/*; do
base=$(basename $generator | sed 's/[0-9]*//')
base="${base%%.*}"
if ! db_progress INFO apt-setup/progress/$base; then
db_subst apt-setup/progress/fallback SCRIPT "$base"
db_progress INFO apt-setup/progress/fallback
fi
tmp=$($chroot $ROOT tempfile)
code=0
$generator $ROOT$tmp || code=$?
case $code in
0)
if ! apt-setup-verify $ROOT$tmp $ROOT/etc/apt/sources.list.new; then
warning "$generator output did not verify"
fi
;;
9)
apt-setup-verify --invalid $ROOT$tmp $ROOT/etc/apt/sources.list.new || true
warning "$generator output added commented out"
;;
10)
# TODO handle backup better
log "$generator backed up"
rm -f $ROOT$tmp $ROOT/etc/apt/sources.list.new
db_progress STOP
exit 10
;;
*)
warning "$generator returned error code $code; discarding output"
;;
esac
rm -f $ROOT$tmp
db_progress STEP 1
done
mv $ROOT/etc/apt/sources.list.new $ROOT/etc/apt/sources.list
if [ -s $ROOT/etc/apt/apt.conf.new ]; then
mv $ROOT/etc/apt/apt.conf.new $ROOT/etc/apt/apt.conf
else
rm -f $ROOT/etc/apt/apt.conf.new
fi
db_progress STOP