From 258604f22d2bc50480aa4eb57778ab96c97cf1c6 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 18 Aug 2023 07:50:18 +0200 Subject: Support repository directory in the clone function --- app/SlackBuilder/Download.hs | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'app/SlackBuilder/Download.hs') 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'] -- cgit v1.2.3