diff --git a/app/Main.hs b/app/Main.hs index 29c332e..ee8b2c8 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -275,8 +275,22 @@ updatePackageIfRequired package@Package{..} version = do Left errorBundle -> liftIO $ putStr $ errorBundlePretty errorBundle updateDownload :: Package -> Package.Updater -> SlackBuilderT (URI, Digest MD5) -updateDownload package Package.Updater{ detectLatest } = detectLatest - >>= renderAndDownload package . fromJust +updateDownload Package{..} Package.Updater{..} = detectLatest + >>= getVersion (Text.pack $ Text.unpack category Text.unpack name) . fromJust + +cloneFromGit :: URI -> Text -> Text -> Text -> SlackBuilderT (URI, Digest MD5) +cloneFromGit repo tagPrefix packagePath version = do + repository' <- SlackBuilderT $ asks repository + let downloadFileName = URI.unRText + $ NonEmpty.last $ snd $ fromJust $ URI.uriPath repo + relativeTarball = Text.unpack packagePath + (dropExtension (Text.unpack downloadFileName) <> "-" <> Text.unpack version) + tarball = repository' relativeTarball + name' = Text.pack (takeBaseName $ Text.unpack packagePath) + checksum <- clone (URI.render repo) (Text.pack tarball) tagPrefix + uploadCommand (Text.pack relativeTarball) ("/" <> name') + (, fromJust checksum) + <$> liftIO (mkURI $ "https://download.dlackware.com/hosted-sources/" <> name' <> "/" <> downloadFileName) downloadWithTemplate :: Package.DownloadTemplate -> Text -> Text -> SlackBuilderT (URI, Digest MD5) downloadWithTemplate downloadTemplate packagePath version = do