Support cloning downloads

This commit is contained in:
Eugen Wissner 2023-10-28 04:04:52 +02:00
parent fa6d93c5ca
commit f51a0418ff

View File

@ -275,8 +275,22 @@ updatePackageIfRequired package@Package{..} version = do
Left errorBundle -> liftIO $ putStr $ errorBundlePretty errorBundle Left errorBundle -> liftIO $ putStr $ errorBundlePretty errorBundle
updateDownload :: Package -> Package.Updater -> SlackBuilderT (URI, Digest MD5) updateDownload :: Package -> Package.Updater -> SlackBuilderT (URI, Digest MD5)
updateDownload package Package.Updater{ detectLatest } = detectLatest updateDownload Package{..} Package.Updater{..} = detectLatest
>>= renderAndDownload package . fromJust >>= 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 :: Package.DownloadTemplate -> Text -> Text -> SlackBuilderT (URI, Digest MD5)
downloadWithTemplate downloadTemplate packagePath version = do downloadWithTemplate downloadTemplate packagePath version = do