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.
 
 
 
 

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