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.
 
 
 
 

179 lines
5.1 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. relvmroot = "https://download.freebsd.org/ftp/releases/VM-IMAGES/"
  32. relisoroot = "https://download.freebsd.org/ftp/releases/ISO-IMAGES/"
  33. }
  34. tolower($1) == "message-id:" {
  35. MID=$2
  36. sub(".*<", "", MID)
  37. sub(">.*", "", MID)
  38. }
  39. $0 == "== ISO CHECKSUMS ==" ||
  40. $0 == "ISO Image Checksums" {
  41. type = "iso"
  42. }
  43. $0 == "== VM IMAGE CHECKSUMS ==" ||
  44. $0 == "Virtual Machine Disk Image Checksums" {
  45. type = "vm"
  46. }
  47. function isdate(date) {
  48. m = match(date, "[0-9]+")
  49. if (m && RLENGTH == 8)
  50. return 1
  51. return 0
  52. }
  53. function isrelease(relpart) {
  54. if (index(relpart, "BETA") == 1 || index(relpart, "RC") == 1 ||
  55. index(relpart, "RELEASE") == 1)
  56. return 1
  57. return 0
  58. }
  59. #FreeBSD-13.0-CURRENT-powerpc-powerpcspe-20181026-r339752-bootonly.iso
  60. #FreeBSD-13.0-CURRENT-sparc64-20181026-r339752-bootonly.iso.asc
  61. #FreeBSD-13.0-CURRENT-arm64-aarch64-PINE64-LTS-20181026-r339752.img.xz
  62. #FreeBSD-13.0-CURRENT-i386-20181026-r339752.vmdk.xz
  63. #FreeBSD-12.1-BETA3-amd64-mini-memstick.img.xz
  64. #FreeBSD-12.1-RC1-amd64-mini-memstick.img.xz
  65. #FreeBSD-12.1-RELEASE-arm64-aarch64.vmdk.xz
  66. $1 == "SHA512" {
  67. # Strip parens
  68. fname = substr($2, 2, length($2) - 2)
  69. split(fname, dotparts, ".")
  70. # recombine around dot in version, strips off ALL extensions (including vm type)
  71. basename = dotparts[1] "." dotparts[2]
  72. cnt = split(basename, parts, "-")
  73. # make arch part, may include additional part
  74. arch = parts[4]
  75. basearch = arch
  76. if (parts[4] == "arm" ||
  77. (parts[4] == "powerpc" && parts[5] == "powerpcspe") ||
  78. (parts[4] == "powerpc" && parts[5] == "powerpc64") ||
  79. parts[4] == "arm64") {
  80. # FreeBSD-11.3-STABLE-arm64-aarch64-20191011-r353406-memstick.img
  81. basearch = parts[5]
  82. arch = parts[4] "-" parts[5]
  83. nextidx = 6
  84. } else {
  85. # FreeBSD-11.3-STABLE-amd64-20191011-r353406.qcow2.xz
  86. nextidx = 5
  87. }
  88. # find date, may be platform first
  89. if (isrelease(parts[3])) {
  90. if (nextidx > cnt) {
  91. # FreeBSD-12.1-BETA3-i386.vhd.xz
  92. platform = "xxx"
  93. } else if (cnt == nextidx) {
  94. # FreeBSD-12.1-RC1-powerpc-powerpcspe-dvd1.iso
  95. platform = parts[nextidx]
  96. nextidx += 1
  97. } else {
  98. # FreeBSD-12.1-BETA3-amd64-mini-memstick.img.xz
  99. platform = parts[nextidx] "-" parts[nextidx + 1]
  100. nextidx += 2
  101. }
  102. date = "xxx"
  103. } else if (isdate(parts[nextidx])) {
  104. # FreeBSD-11.3-STABLE-amd64-20191011-r353406.qcow2.xz
  105. platform = "xxx"
  106. date = parts[nextidx]
  107. nextidx += 1
  108. } else {
  109. # FreeBSD-13.0-CURRENT-arm64-aarch64-PINE64-LTS-20181026-r339752.img.xz
  110. platform = parts[nextidx]
  111. date = parts[nextidx + 1]
  112. if (isdate(date)) {
  113. # FreeBSD-13.0-CURRENT-arm64-aarch64-PINEBOOK-20191011-r353427.img.xz
  114. nextidx += 2
  115. } else {
  116. # FreeBSD-13.0-CURRENT-arm64-aarch64-PINE64-LTS-20181026-r339752.img.xz
  117. date = parts[nextidx + 2]
  118. platform = parts[nextidx] "-" parts[nextidx + 1]
  119. nextidx += 3
  120. }
  121. }
  122. if (nextidx >= cnt)
  123. vers="xxx"
  124. else {
  125. vers=""
  126. sep=""
  127. for (i = nextidx + 1; i <= cnt; i++) {
  128. vers = vers sep parts[i]
  129. sep="-"
  130. }
  131. }
  132. if (isrelease(parts[3])) {
  133. if (type == "vm") {
  134. vers = dotparts[3]
  135. url = relvmroot parts[2] "-" parts[3] "/" basearch "/Latest/" fname
  136. } else
  137. url = relisoroot parts[2] "/" fname
  138. } else {
  139. if (type == "vm") {
  140. vers = dotparts[3]
  141. url = vmroot parts[2] "-" parts[3] "/" basearch "/" date "/" fname
  142. } else
  143. url = isoroot parts[2] "/" fname
  144. }
  145. # if this part doesn't begin w/ r (for svn rev), skip it, we can't parse
  146. # others for now
  147. rev = parts[nextidx]
  148. if (isrelease(parts[3])) {
  149. # FreeBSD-12.1-RC1-amd64-mini-memstick.img.xz
  150. rev = "unspec"
  151. } else if (substr(rev, 1, 1) != "r") {
  152. next
  153. }
  154. # double check that date is valid, if not, skip it
  155. if (date != "xxx" && !isdate(date))
  156. next
  157. printf("%s %s %s %s %s %s %s %s %s %s\n", type, parts[2] "-" parts[3], arch, platform, date, rev, vers, fname, url, MID)
  158. }