tools.deploy.backend: refactoring of make-staging-image
parent
64d3c01523
commit
a70deca651
|
@ -1,18 +1,42 @@
|
||||||
USING: pcre sequences tools.deploy.backend tools.test ;
|
USING: bootstrap.image kernel pcre sequences tools.deploy.backend
|
||||||
|
tools.test ;
|
||||||
IN: tools.deploy.backend.tests
|
IN: tools.deploy.backend.tests
|
||||||
|
|
||||||
: complete-match? ( str regexp -- ? )
|
: complete-match? ( str regexp -- ? )
|
||||||
"^" "$" surround matches? ;
|
"^" "$" surround matches? ;
|
||||||
|
|
||||||
|
! deploy-command-line
|
||||||
{ t } [
|
{ t } [
|
||||||
{ } staging-command-line
|
"image" "hello-world" "manifest.file" { "foob" } deploy-command-line
|
||||||
|
{
|
||||||
|
"-pic=0"
|
||||||
|
"-i=.*foob.*"
|
||||||
|
"-vocab-manifest-out=manifest.file"
|
||||||
|
"-deploy-vocab=hello-world"
|
||||||
|
"-deploy-config=.*hello-world"
|
||||||
|
"-output-image=image"
|
||||||
|
"-resource-path=.*"
|
||||||
|
"-run=tools.deploy.shaker"
|
||||||
|
} [ complete-match? ] 2all?
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
! input-image-name
|
||||||
|
{ t } [
|
||||||
|
{ "foo" } input-image-name my-boot-image-name =
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
! staging-command-line
|
||||||
|
{ t } [
|
||||||
|
{ "one" "two" } staging-command-line
|
||||||
{
|
{
|
||||||
"-staging"
|
"-staging"
|
||||||
"-no-user-init"
|
"-no-user-init"
|
||||||
"-pic=0"
|
"-pic=0"
|
||||||
"-output-image.*"
|
"-output-image.*"
|
||||||
"-include="
|
"-include=one two"
|
||||||
"-i=boot\\..*"
|
"-i=.*"
|
||||||
|
"-resource-path=.*"
|
||||||
|
"-run=tools.deploy.restage"
|
||||||
} [ complete-match? ] 2all?
|
} [ complete-match? ] 2all?
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
@ -29,17 +53,3 @@ IN: tools.deploy.backend.tests
|
||||||
"-run=tools.deploy.restage"
|
"-run=tools.deploy.restage"
|
||||||
} [ complete-match? ] 2all?
|
} [ complete-match? ] 2all?
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
{ t } [
|
|
||||||
"image" "hello-world" "manifest.file" { "foob" } deploy-command-line
|
|
||||||
{
|
|
||||||
"-pic=0"
|
|
||||||
"-i=.*foob.*"
|
|
||||||
"-vocab-manifest-out=manifest.file"
|
|
||||||
"-deploy-vocab=hello-world"
|
|
||||||
"-deploy-config=.*hello-world"
|
|
||||||
"-output-image=image"
|
|
||||||
"-resource-path=.*"
|
|
||||||
"-run=tools.deploy.shaker"
|
|
||||||
} [ complete-match? ] 2all?
|
|
||||||
] unit-test
|
|
||||||
|
|
|
@ -55,6 +55,12 @@ ERROR: can't-deploy-library-file library ;
|
||||||
[ delete-file ] each
|
[ delete-file ] each
|
||||||
] with-directory-files ;
|
] with-directory-files ;
|
||||||
|
|
||||||
|
: input-image-name ( profile -- name )
|
||||||
|
but-last [ my-boot-image-name ] [ staging-image-name ] if-empty ;
|
||||||
|
|
||||||
|
: run-factor ( vm-path flags -- )
|
||||||
|
swap prefix dup . run-with-output ; inline
|
||||||
|
|
||||||
: staging-command-line ( profile -- flags )
|
: staging-command-line ( profile -- flags )
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
@ -62,26 +68,16 @@ ERROR: can't-deploy-library-file library ;
|
||||||
[ staging-image-name "-output-image=" prepend , ]
|
[ staging-image-name "-output-image=" prepend , ]
|
||||||
[ " " join "-include=" prepend , ] bi
|
[ " " join "-include=" prepend , ] bi
|
||||||
] [
|
] [
|
||||||
[ "-i=" my-boot-image-name append , ] [
|
input-image-name "-i=" prepend ,
|
||||||
but-last staging-image-name "-i=" prepend ,
|
"-resource-path=" "" resource-path append ,
|
||||||
"-resource-path=" "" resource-path append ,
|
"-run=tools.deploy.restage" ,
|
||||||
"-run=tools.deploy.restage" ,
|
|
||||||
] if-empty
|
|
||||||
] bi
|
] bi
|
||||||
] { } make ;
|
] { } make ;
|
||||||
|
|
||||||
: run-factor ( vm-path flags -- )
|
|
||||||
swap prefix dup . run-with-output ; inline
|
|
||||||
|
|
||||||
DEFER: ?make-staging-image
|
|
||||||
|
|
||||||
: make-staging-image ( profile -- )
|
: make-staging-image ( profile -- )
|
||||||
dup [ but-last ?make-staging-image ] unless-empty
|
{ } [ suffix ] accumulate* [ staging-image-name exists? ] reject
|
||||||
vm-path swap staging-command-line run-factor ;
|
[ staging-command-line ] map
|
||||||
|
[ vm-path swap run-factor ] each ;
|
||||||
: ?make-staging-image ( profile -- )
|
|
||||||
dup staging-image-name exists?
|
|
||||||
[ drop ] [ make-staging-image ] if ;
|
|
||||||
|
|
||||||
: make-deploy-config ( vocab -- file )
|
: make-deploy-config ( vocab -- file )
|
||||||
[ deploy-config vocab-roots get vocab-roots associate assoc-union unparse-use ]
|
[ deploy-config vocab-roots get vocab-roots associate assoc-union unparse-use ]
|
||||||
|
@ -114,7 +110,7 @@ DEFER: ?make-staging-image
|
||||||
vocab "vocab-manifest-" prepend temp-file :> manifest-file
|
vocab "vocab-manifest-" prepend temp-file :> manifest-file
|
||||||
image vocab manifest-file profile deploy-command-line :> flags
|
image vocab manifest-file profile deploy-command-line :> flags
|
||||||
|
|
||||||
profile ?make-staging-image
|
profile make-staging-image
|
||||||
vm flags run-factor
|
vm flags run-factor
|
||||||
manifest-file parse-vocab-manifest-file ;
|
manifest-file parse-vocab-manifest-file ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue