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.
 
 
 
 

128 lines
3.5 KiB

  1. #
  2. # Copyright 2018 John-Mark Gurney.
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. # 1. Redistributions of source code must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in the
  12. # documentation and/or other materials provided with the distribution.
  13. #
  14. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. # SUCH DAMAGE.
  25. #
  26. # $Id$
  27. #
  28. BEGIN {
  29. vmroot = "https://download.freebsd.org/ftp/snapshots/VM-IMAGES/"
  30. isoroot = "https://download.freebsd.org/ftp/snapshots/ISO-IMAGES/"
  31. }
  32. tolower($1) == "message-id:" {
  33. MID=$2
  34. sub(".*<", "", MID)
  35. sub(">.*", "", MID)
  36. }
  37. $0 == "== ISO CHECKSUMS ==" {
  38. root = isoroot
  39. type = "iso"
  40. }
  41. $0 == "== VM IMAGE CHECKSUMS ==" {
  42. root = vmroot
  43. type = "vm"
  44. }
  45. function isdate(date) {
  46. m = match(date, "[0-9]+")
  47. if (m && RLENGTH == 8)
  48. return 1
  49. return 0
  50. }
  51. #FreeBSD-13.0-CURRENT-powerpc-powerpcspe-20181026-r339752-bootonly.iso
  52. #FreeBSD-13.0-CURRENT-sparc64-20181026-r339752-bootonly.iso.asc
  53. #FreeBSD-13.0-CURRENT-arm64-aarch64-PINE64-LTS-20181026-r339752.img.xz
  54. #FreeBSD-13.0-CURRENT-i386-20181026-r339752.vmdk.xz
  55. $1 == "SHA512" {
  56. # Strip parens
  57. fname = substr($2, 2, length($2) - 2)
  58. split(fname, dotparts, ".")
  59. # recombine around version string, strips of ALL extensions (including vm type)
  60. basename = dotparts[1] "." dotparts[2]
  61. cnt = split(basename, parts, "-")
  62. # make arch part, may include additional part
  63. arch = parts[4]
  64. basearch = arch
  65. if (parts[4] == "arm" || (parts[4] == "powerpc" && parts[5] == "powerpcspe") || parts[4] == "arm64") {
  66. basearch = parts[5]
  67. arch = parts[4] "-" parts[5]
  68. nextidx = 6
  69. } else
  70. nextidx = 5
  71. # find date, may be platform first
  72. if (isdate(parts[nextidx])) {
  73. platform = "xxx"
  74. date = parts[nextidx]
  75. nextidx += 1
  76. } else {
  77. platform = parts[nextidx]
  78. date = parts[nextidx + 1]
  79. if (isdate(date)) {
  80. nextidx += 2
  81. } else {
  82. date = parts[nextidx + 2]
  83. platform = parts[nextidx] "-" parts[nextidx + 1]
  84. nextidx += 3
  85. }
  86. }
  87. if (nextidx == cnt)
  88. vers="xxx"
  89. else {
  90. vers=""
  91. sep=""
  92. for (i = nextidx + 1; i <= cnt; i++) {
  93. vers = vers sep parts[i]
  94. sep="-"
  95. }
  96. }
  97. if (type == "vm") {
  98. vers = dotparts[3]
  99. url = root parts[2] "-" parts[3] "/" basearch "/" date "/" fname
  100. } else
  101. url = root parts[2] "/" fname
  102. # if this part doesn't begin w/ r (for svn rev), skip it, we can't parse
  103. # others for now
  104. if (substr(parts[nextidx], 1, 1) != "r")
  105. next
  106. # double check that date is valid, if not, skip it
  107. if (!isdate(date))
  108. next
  109. printf("%s %s %s %s %s %s %s %s %s %s\n", type, parts[2] "-" parts[3], arch, platform, date, parts[nextidx], vers, fname, url, MID)
  110. }