1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: http.client checksums checksums.md5 splitting assocs
4 kernel io.files bootstrap.image sequences io urls ;
5 IN: bootstrap.image.download
7 CONSTANT: url URL" http://factorcode.org/images/latest/"
9 : download-checksums ( -- alist )
10 url "checksums.txt" >url derive-url http-get nip
11 string-lines [ " " split1 ] { } map>assoc ;
13 : need-new-image? ( image -- ? )
16 [ md5 checksum-file hex-string ]
17 [ download-checksums at ]
21 : download-image ( arch -- )
22 boot-image-name dup need-new-image? [
23 "Downloading " write dup write "..." print
24 url over >url derive-url download
26 "Boot image corrupt, or checksums.txt on server out of date" throw
29 "Boot image up to date" print
33 : download-my-image ( -- ) my-arch download-image ;
35 MAIN: download-my-image