A utility for downloading and verifying FreeBSD releases and snapshots
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.
 
 
 
 

86 lines
1.4 KiB

  1. #!/bin/sh -
  2. set -e
  3. args=`getopt m $*`
  4. if [ $? -ne 0 ]; then
  5. echo 'Usage: $0 [ -m ]'
  6. exit 2
  7. fi
  8. set -- $args
  9. while :; do
  10. case "$1" in
  11. -m)
  12. more=1
  13. shift
  14. ;;
  15. --)
  16. shift; break
  17. ;;
  18. esac
  19. done
  20. mkdir "$0.running"
  21. # minimize file
  22. tmpfname="tmp.snapinf.asc"
  23. awk '
  24. output != 1 && tolower($1) == "message-id:" {
  25. print
  26. next
  27. }
  28. $0 == "-----BEGIN PGP SIGNED MESSAGE-----" {
  29. output = 1
  30. }
  31. output == 1 {
  32. print
  33. }
  34. $0 == "-----END PGP SIGNATURE-----" {
  35. output = 0
  36. }' > "$tmpfname"
  37. if ! gpg --verify "$tmpfname"; then
  38. echo 'failed verify'
  39. rm "$tmpfname"
  40. rmdir "$0.running"
  41. exit 1
  42. fi
  43. # process file
  44. awk -f ./mksnapidx.awk "$tmpfname" > additional
  45. rm "$tmpfname"
  46. # only check if there isn't more to come
  47. if [ x"$more" = x"1" ]; then
  48. (cat snapshot.idx || :; cat additional) > snapshot.idx.new
  49. (cat snapshot.complete.idx || :; cat additional) > snapshot.complete.idx.new
  50. else
  51. (xzcat snapshot.idx.xz; cat additional) | sort -u | awk '
  52. {
  53. if (!system("wget --method=HEAD " $9))
  54. print
  55. }
  56. ' > snapshot.idx.new
  57. xz snapshot.idx.new
  58. (xzcat snapshot.complete.idx.xz || :; cat additional) | sort -u > snapshot.complete.idx.new
  59. xz snapshot.complete.idx.new
  60. fi
  61. rm additional
  62. # install new indexes
  63. if [ x"$more" = x"1" ]; then
  64. mv snapshot.idx.new snapshot.idx
  65. mv snapshot.complete.idx.new snapshot.complete.idx
  66. else
  67. mv snapshot.idx.new.xz snapshot.idx.xz
  68. mv snapshot.complete.idx.new.xz snapshot.complete.idx.xz
  69. fi
  70. rmdir "$0.running"