diff --git a/extra/builder/release/upload/upload.factor b/extra/builder/release/upload/upload.factor index 38f6dcb133..32a27f82fd 100644 --- a/extra/builder/release/upload/upload.factor +++ b/extra/builder/release/upload/upload.factor @@ -1,5 +1,5 @@ -USING: kernel namespaces io io.files +USING: kernel namespaces sequences arrays io io.files builder.util builder.common builder.release.archive ; @@ -8,17 +8,47 @@ IN: builder.release.upload ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: remote-location ( -- dest ) - "factorcode.org:/var/www/factorcode.org/newsite/downloads" - platform - append-path ; +SYMBOL: upload-host -: (upload) ( -- ) - { "scp" archive-name remote-location } to-strings - [ "Error uploading binary to factorcode" print ] - run-or-bail ; +SYMBOL: upload-username + +SYMBOL: upload-directory + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: remote-location ( -- dest ) + upload-directory get platform append ; + +: remote-archive-name ( -- dest ) + remote-location "/" archive-name 3append ; + +: temp-archive-name ( -- dest ) + remote-archive-name ".incomplete" append ; + +: upload-command ( -- args ) + "scp" + archive-name + [ upload-username get % "@" % upload-host get % ":" % temp-archive-name % ] "" make + 3array ; + +: rename-command ( -- args ) + [ + "ssh" , + upload-host get , + "-l" , + upload-username get , + "mv" , + temp-archive-name , + remote-archive-name , + ] { } make ; + +: upload-temp-file ( -- ) + upload-command [ "Error uploading binary to factorcode" print ] run-or-bail ; + +: rename-temp-file ( -- ) + rename-command [ "Error renaming binary on factorcode" print ] run-or-bail ; : upload ( -- ) upload-to-factorcode get - [ (upload) ] + [ upload-temp-file rename-temp-file ] when ;