diff options
| author | Eugen Wissner <belka@caraus.de> | 2023-08-18 07:50:18 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2023-08-18 07:50:18 +0200 |
| commit | 258604f22d2bc50480aa4eb57778ab96c97cf1c6 (patch) | |
| tree | d6fb3c1ce16879b191bc7adba91065d8c6cc7976 /app/SlackBuilder/Download.hs | |
| parent | fd649b66f57123aad95861e636299a2d0a5ca6f7 (diff) | |
| download | slackbuilder-258604f22d2bc50480aa4eb57778ab96c97cf1c6.tar.gz | |
Support repository directory in the clone function
Diffstat (limited to 'app/SlackBuilder/Download.hs')
| -rw-r--r-- | app/SlackBuilder/Download.hs | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/app/SlackBuilder/Download.hs b/app/SlackBuilder/Download.hs index 83db687..cbdcbb8 100644 --- a/app/SlackBuilder/Download.hs +++ b/app/SlackBuilder/Download.hs @@ -1,5 +1,6 @@ module SlackBuilder.Download - ( commit + ( cloneAndArchive + , commit , hostedSources , remoteFileExists , updateSlackBuildVersion @@ -83,3 +84,42 @@ remoteFileExists url = hostedSources url { httpConfigCheckResponse = const $ const $ const Nothing } go uri = req HEAD uri NoReqBody ignoreResponse mempty + +uploadCommand :: Text -> Text -> SlackBuilderT () +uploadCommand localPath remotePath' = do + remoteRoot <- SlackBuilderT $ asks remotePath + liftIO $ callProcess "scp" $ Text.unpack <$> + [ "slackbuilds/" <> localPath + , remoteRoot <> remotePath' + ] + +cloneAndArchive :: Text -> Text -> FilePath -> Text -> SlackBuilderT () +cloneAndArchive repo nameVersion tarball tagPrefix = do + let (_, version) = Text.breakOnEnd "-" nameVersion + nameVersion' = Text.unpack nameVersion + + repository' <- SlackBuilderT $ asks repository + liftIO $ callProcess "rm" ["-rf", nameVersion'] + + liftIO $ callProcess "git" ["clone", Text.unpack repo, nameVersion'] + liftIO $ callProcess "git" + [ "-C" + , nameVersion' + , "checkout" + , Text.unpack $ tagPrefix <> version + ] + liftIO $ callProcess "git" + [ "-C" + , nameVersion' + , "submodule" + , "update" + , "--init" + , "--recursive" + ] + + liftIO $ callProcess "tar" + [ "Jcvf" + , repository' </> tarball + , nameVersion' + ] + liftIO $ callProcess "rm" ["-rf", nameVersion'] |
