factor/extra/mason/updates/updates.factor

38 lines
1.1 KiB
Factor
Raw Permalink Normal View History

! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov.
2008-09-16 00:20:33 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: bootstrap.image.download http.client init kernel
2014-11-15 19:20:49 -05:00
mason.config mason.git mason.platform math.parser namespaces ;
2008-09-16 00:20:33 -04:00
IN: mason.updates
TUPLE: sources git-id boot-image counter ;
C: <sources> sources
SYMBOLS: latest-sources last-built-sources ;
[
f latest-sources set-global
f last-built-sources set-global
] "mason.updates" add-startup-hook
: latest-boot-image ( -- boot-image )
2014-11-15 19:20:49 -05:00
target-boot-image-name
[ maybe-download-image drop ] [ file-checksum ] bi ;
: latest-counter ( -- counter )
counter-url get-global http-get nip string>number ;
2008-09-16 00:20:33 -04:00
: update-sources ( -- )
2015-09-08 19:15:10 -04:00
! Must be run from builds-dir
git-clone-or-pull latest-boot-image latest-counter <sources>
latest-sources set-global ;
: should-build? ( -- ? )
latest-sources get-global last-built-sources get-global = not ;
2008-09-16 00:20:33 -04:00
: finish-build ( -- )
2015-09-08 19:15:10 -04:00
! If the build completed (successfully or not) without
! mason crashing or being killed, don't build this git ID
! and boot image hash again.
latest-sources get-global last-built-sources set-global ;