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.

58 lines
834 B

  1. #!/bin/sh
  2. # verify and optionally save out the file
  3. set -e
  4. file="$1"
  5. saveto="$2"
  6. if [ -n "$ROOT" ]; then
  7. chroot=chroot
  8. else
  9. chroot=
  10. fi
  11. valid () {
  12. line="$1"
  13. tmp=$($chroot tempfile)
  14. echo "$line" > $ROOT$tmp
  15. if $chroot $ROOT apt-get -o APT::Get::List-Cleanup=false \
  16. -o Dir::Etc::sourcelist=$tmp update
  17. then
  18. rm -f $ROOT$tmp
  19. else
  20. rm -f $ROOT$tmp
  21. false
  22. fi
  23. }
  24. items=0
  25. gooditems=0
  26. IFS="
  27. "
  28. for line in $(cat $file); do
  29. if [ "$(expr "$line" : "#")" != 1 ]; then
  30. items=$(expr "$items" + 1)
  31. if valid "$line"; then
  32. gooditems=$(expr "$gooditems" + 1)
  33. if [ -n "$saveto" ]; then
  34. echo "$line" >> $saveto
  35. fi
  36. else
  37. if [ -n "$saveto" ]; then
  38. echo "#$line" >> $saveto
  39. fi
  40. fi
  41. else
  42. if [ -n "$saveto" ]; then
  43. echo "$line" >> $saveto
  44. fi
  45. fi
  46. done
  47. if [ "$gooditems" != "$items" ]; then
  48. exit 1
  49. fi