]> gitweb.factorcode.org Git - factor.git/blob - extra/mason/updates/updates.factor
http.client: remove http-get* and its friends, change http-request* and with-http...
[factor.git] / extra / mason / updates / updates.factor
1 ! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: bootstrap.image.download http.client init kernel
4 math.parser namespaces mason.config mason.common mason.git
5 mason.platform ;
6 IN: mason.updates
7
8 TUPLE: sources git-id boot-image counter ;
9
10 C: <sources> sources
11
12 SYMBOLS: latest-sources last-built-sources ;
13
14 [
15     f latest-sources set-global
16     f last-built-sources set-global
17 ] "mason.updates" add-startup-hook
18
19 : latest-boot-image ( -- boot-image )
20     boot-image-name
21     [ maybe-download-image drop ] [ file-checksum ] bi ;
22
23 : latest-counter ( -- counter )
24     counter-url get-global http-get nip string>number ;
25
26 : update-sources ( -- )
27     #! Must be run from builds-dir
28     git-pull latest-boot-image latest-counter <sources>
29     latest-sources set-global ;
30
31 : build? ( -- ? )
32     latest-sources get-global last-built-sources get-global = not ;
33
34 : finish-build ( -- )
35     #! If the build completed (successfully or not) without
36     #! mason crashing or being killed, don't build this git ID
37     #! and boot image hash again.
38     latest-sources get-global last-built-sources set-global ;