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.

66 lines
1.3 KiB

  1. #!/bin/sh
  2. set -e
  3. . /usr/share/debconf/confmodule
  4. db_capb backup
  5. gendir=/usr/lib/apt-setup/generators
  6. if [ "$1" ]; then
  7. ROOT="$1"
  8. chroot=chroot
  9. else
  10. ROOT=
  11. chroot=
  12. fi
  13. export ROOT
  14. # generators/01setup will create this
  15. export APT_CONFIG=/etc/apt/apt.conf.new
  16. log() {
  17. logger -t apt-setup "$@"
  18. }
  19. warning() {
  20. log "warning: $@"
  21. }
  22. gencount=`ls "$gendir"/* | wc -l`
  23. db_progress START 0 $gencount apt-setup/progress/title
  24. for generator in $gendir/*; do
  25. base=$(basename $generator | sed 's/[0-9]*//')
  26. if ! db_progress INFO apt-setup/progress/$base; then
  27. db_subst apt-setup/progress/fallback SCRIPT "$base"
  28. db_progress INFO apt-setup/progress/fallback
  29. fi
  30. tmp=$($chroot $ROOT tempfile)
  31. echo > $ROOT$tmp
  32. if $generator $ROOT$tmp; then
  33. if ! apt-setup-verify $ROOT$tmp $ROOT/etc/apt/sources.list.new; then
  34. warning "$generator output did not verify"
  35. fi
  36. else
  37. code="$?"
  38. if [ "$code" = 10 ]; then
  39. # TODO handle backup better
  40. log "$generator backed up"
  41. rm -f $ROOT$tmp
  42. db_progress STOP
  43. exit 10
  44. fi
  45. warning "$generator returned error code $code; discarding output"
  46. fi
  47. rm -f $ROOT$tmp
  48. db_progress STEP 1
  49. done
  50. mv $ROOT/etc/apt/sources.list.new $ROOT/etc/apt/sources.list
  51. if [ -s $ROOT/etc/apt/apt.conf.new ]; then
  52. mv $ROOT/etc/apt/apt.conf.new $ROOT/etc/apt/apt.conf
  53. else
  54. rm -f $ROOT/etc/apt/apt.conf.new
  55. fi
  56. db_progress STOP