catb0t/multifactor

update_boot_image does not cover non-master branches / edge cases well

Opened this issue · 0 comments

the hot path for update_boot_image / _get_boot_image is when branch is master and there's an internet connection. the following output, from a different branch, demonstrates how useless it currently is

its logic needs to be entirely overhauled

** GET http://downloads.factorcode.org/images/reproducible-vm/checksums.txt ==> 404 Not Found
** GET http://downloads.factorcode.org/images/master/checksums.txt ==> 200 OK
update_boot_image: boot image sums: 380a22ac3b325b5675e7aecae99fa7f0 / 03fbcb9aa339ca129577a689544e3aaf
	update_boot_image: !!! local / remote checksum mismatch !!! 
_get_boot_image: Downloading boot image file boot.unix-x86.64.image
** GET http://downloads.factorcode.org/images/master/boot.unix-x86.64.image ==> 200 OK (1s)
** GET http://downloads.factorcode.org/images/master/checksums.txt ==> 200 OK
_get_boot_image: boot image sums: 380a22ac3b325b5675e7aecae99fa7f0 / 380a22ac3b325b5675e7aecae99fa7f0

-> _get_boot_image {
const File boot_image_file = BuildSh.generate_make_targets(){:boot_image}
say (__METHOD_NAME__ + ': Downloading boot image file ' + boot_image_file)
const boot_image_urls = BuildSh.boot_image_urls
const boot_image_data = BuildSh.make_http_request( boot_image_urls{:boot_image_url} )
const local_md5 = boot_image_data.md5
const remote_checksum_data = BuildSh.make_http_request( boot_image_urls{:checksum} )
if (! remote_checksum_data) {
say "#{__METHOD_NAME__}: Can't download, can't checksum"
return false
}
const remote_md5 = BuildSh._process_checksums_file(remote_checksum_data, boot_image_file)
say "#{__METHOD_NAME__}: boot image sums: #{remote_md5} / #{local_md5}"
if (remote_md5 != local_md5) { die "#{__METHOD_NAME__}: !!! downloaded checksum mismatch !!! (unrecoverable)" }
boot_image_file.touch.cleave(
{ .binmode },
{ .spurt( boot_image_data ) }
)
}