Compare commits
No commits in common. "f51a0418ff4454c325cb1e3f844e5f635bfeaaac" and "6c0e2c2d24f380e5bdf6f1fce36ea7ee11afe6ea" have entirely different histories.
f51a0418ff
...
6c0e2c2d24
94
app/Main.hs
94
app/Main.hs
@ -64,9 +64,10 @@ autoUpdatable =
|
|||||||
template = Package.DownloadTemplate
|
template = Package.DownloadTemplate
|
||||||
$ Package.StaticPlaceholder "https://github.com/universal-ctags/ctags/archive/"
|
$ Package.StaticPlaceholder "https://github.com/universal-ctags/ctags/archive/"
|
||||||
:| templateTail
|
:| templateTail
|
||||||
in Package.Updater latest' $ reuploadWithTemplate template []
|
in Package.Updater latest' template
|
||||||
, category = "development"
|
, category = "development"
|
||||||
, name = "universal-ctags"
|
, name = "universal-ctags"
|
||||||
|
, reupload = Just []
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -76,9 +77,10 @@ autoUpdatable =
|
|||||||
template = Package.DownloadTemplate
|
template = Package.DownloadTemplate
|
||||||
$ Package.StaticPlaceholder "https://getcomposer.org/download/"
|
$ Package.StaticPlaceholder "https://getcomposer.org/download/"
|
||||||
:| [Package.VersionPlaceholder, Package.StaticPlaceholder "/composer.phar"]
|
:| [Package.VersionPlaceholder, Package.StaticPlaceholder "/composer.phar"]
|
||||||
in Package.Updater latest' $ downloadWithTemplate template
|
in Package.Updater latest' template
|
||||||
, category = "development"
|
, category = "development"
|
||||||
, name = "composer"
|
, name = "composer"
|
||||||
|
, reupload = Nothing
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -93,9 +95,10 @@ autoUpdatable =
|
|||||||
$ Package.StaticPlaceholder "https://github.com/jitsi/jitsi-meet-electron/releases/download/v"
|
$ Package.StaticPlaceholder "https://github.com/jitsi/jitsi-meet-electron/releases/download/v"
|
||||||
:| Package.VersionPlaceholder
|
:| Package.VersionPlaceholder
|
||||||
: [Package.StaticPlaceholder "/jitsi-meet-x86_64.AppImage"]
|
: [Package.StaticPlaceholder "/jitsi-meet-x86_64.AppImage"]
|
||||||
in Package.Updater latest' $ downloadWithTemplate template
|
in Package.Updater latest' template
|
||||||
, category = "network"
|
, category = "network"
|
||||||
, name = "jitsi-meet-desktop"
|
, name = "jitsi-meet-desktop"
|
||||||
|
, reupload = Nothing
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -114,9 +117,10 @@ autoUpdatable =
|
|||||||
$ Package.StaticPlaceholder "https://www.php.net/distributions/php-"
|
$ Package.StaticPlaceholder "https://www.php.net/distributions/php-"
|
||||||
:| Package.VersionPlaceholder
|
:| Package.VersionPlaceholder
|
||||||
: [Package.StaticPlaceholder ".tar.xz"]
|
: [Package.StaticPlaceholder ".tar.xz"]
|
||||||
in Package.Updater latest' $ downloadWithTemplate template
|
in Package.Updater latest' template
|
||||||
, category = "development"
|
, category = "development"
|
||||||
, name = "php82"
|
, name = "php82"
|
||||||
|
, reupload = Nothing
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -136,9 +140,10 @@ autoUpdatable =
|
|||||||
$ Package.StaticPlaceholder "https://github.com/kovidgoyal/kitty/releases/download/v"
|
$ Package.StaticPlaceholder "https://github.com/kovidgoyal/kitty/releases/download/v"
|
||||||
:| Package.VersionPlaceholder
|
:| Package.VersionPlaceholder
|
||||||
: templateTail
|
: templateTail
|
||||||
in Package.Updater latest' $ reuploadWithTemplate template [RawCommand "go" ["mod", "vendor"]]
|
in Package.Updater latest' template
|
||||||
, category = "system"
|
, category = "system"
|
||||||
, name = "kitty"
|
, name = "kitty"
|
||||||
|
, reupload = Just [RawCommand "go" ["mod", "vendor"]]
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -155,9 +160,10 @@ autoUpdatable =
|
|||||||
: Package.StaticPlaceholder "/rdiff-backup-"
|
: Package.StaticPlaceholder "/rdiff-backup-"
|
||||||
: Package.VersionPlaceholder
|
: Package.VersionPlaceholder
|
||||||
: [Package.StaticPlaceholder ".tar.gz"]
|
: [Package.StaticPlaceholder ".tar.gz"]
|
||||||
in Package.Updater latest' $ reuploadWithTemplate template []
|
in Package.Updater latest' template
|
||||||
, category = "system"
|
, category = "system"
|
||||||
, name = "rdiff-backup"
|
, name = "rdiff-backup"
|
||||||
|
, reupload = Just mempty
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -174,9 +180,10 @@ autoUpdatable =
|
|||||||
template = Package.DownloadTemplate $ pure
|
template = Package.DownloadTemplate $ pure
|
||||||
$ Package.StaticPlaceholder
|
$ Package.StaticPlaceholder
|
||||||
"https://binaries.webex.com/WebexDesktop-Ubuntu-Official-Package/Webex.deb"
|
"https://binaries.webex.com/WebexDesktop-Ubuntu-Official-Package/Webex.deb"
|
||||||
in Package.Updater latest' $ downloadWithTemplate template
|
in Package.Updater latest' template
|
||||||
, category = "network"
|
, category = "network"
|
||||||
, name = "webex"
|
, name = "webex"
|
||||||
|
, reupload = Nothing
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -193,9 +200,10 @@ autoUpdatable =
|
|||||||
: Package.StaticPlaceholder "/librsync-"
|
: Package.StaticPlaceholder "/librsync-"
|
||||||
: Package.VersionPlaceholder
|
: Package.VersionPlaceholder
|
||||||
: [Package.StaticPlaceholder ".tar.gz"]
|
: [Package.StaticPlaceholder ".tar.gz"]
|
||||||
in Package.Updater latest' $ reuploadWithTemplate template []
|
in Package.Updater latest' template
|
||||||
, category = "libraries"
|
, category = "libraries"
|
||||||
, name = "librsync"
|
, name = "librsync"
|
||||||
|
, reupload = Just mempty
|
||||||
, downloaders = []
|
, downloaders = []
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -211,9 +219,10 @@ autoUpdatable =
|
|||||||
: Package.StaticPlaceholder "/dmd."
|
: Package.StaticPlaceholder "/dmd."
|
||||||
: Package.VersionPlaceholder
|
: Package.VersionPlaceholder
|
||||||
: [Package.StaticPlaceholder ".linux.tar.xz"]
|
: [Package.StaticPlaceholder ".linux.tar.xz"]
|
||||||
in Package.Updater latest' $ downloadWithTemplate template
|
in Package.Updater latest' template
|
||||||
, category = "development"
|
, category = "development"
|
||||||
, name = "dmd"
|
, name = "dmd"
|
||||||
|
, reupload = Nothing
|
||||||
, downloaders = mempty
|
, downloaders = mempty
|
||||||
}
|
}
|
||||||
, Package
|
, Package
|
||||||
@ -226,16 +235,17 @@ autoUpdatable =
|
|||||||
template = Package.DownloadTemplate
|
template = Package.DownloadTemplate
|
||||||
$ Package.StaticPlaceholder "https://codeload.github.com/dlang/tools/tar.gz/v"
|
$ Package.StaticPlaceholder "https://codeload.github.com/dlang/tools/tar.gz/v"
|
||||||
:| [Package.VersionPlaceholder]
|
:| [Package.VersionPlaceholder]
|
||||||
in Package.Updater latest' $ reuploadWithTemplate template []
|
in Package.Updater latest' template
|
||||||
, category = "development"
|
, category = "development"
|
||||||
, name = "d-tools"
|
, name = "d-tools"
|
||||||
|
, reupload = Just []
|
||||||
, downloaders =
|
, downloaders =
|
||||||
let dubArguments = GhArguments{ owner = "dlang", name = "dub", transform = Nothing}
|
let dubArguments = GhArguments{ owner = "dlang", name = "dub", transform = Nothing}
|
||||||
latestDub = latestGitHub dubArguments pure
|
latestDub = latestGitHub dubArguments pure
|
||||||
dubTemplate = Package.DownloadTemplate
|
dubTemplate = Package.DownloadTemplate
|
||||||
$ Package.StaticPlaceholder "https://codeload.github.com/dlang/dub/tar.gz/v"
|
$ Package.StaticPlaceholder "https://codeload.github.com/dlang/dub/tar.gz/v"
|
||||||
:| [Package.VersionPlaceholder]
|
:| [Package.VersionPlaceholder]
|
||||||
in [Package.Updater latestDub $ downloadWithTemplate dubTemplate]
|
in [Package.Updater latestDub dubTemplate]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -245,9 +255,9 @@ up2Date = for_ autoUpdatable go
|
|||||||
go package = getAndLogLatest package
|
go package = getAndLogLatest package
|
||||||
>>= mapM_ (updatePackageIfRequired package)
|
>>= mapM_ (updatePackageIfRequired package)
|
||||||
>> liftIO (putStrLn "")
|
>> liftIO (putStrLn "")
|
||||||
getAndLogLatest Package{ latest = Package.Updater{ detectLatest }, name }
|
getAndLogLatest Package{ latest = Package.Updater getLatest _, name }
|
||||||
= liftIO (putStrLn $ Text.unpack name <> ": Retreiving the latest version.")
|
= liftIO (putStrLn $ Text.unpack name <> ": Retreiving the latest version.")
|
||||||
>> detectLatest
|
>> getLatest
|
||||||
|
|
||||||
updatePackageIfRequired :: Package -> Text -> SlackBuilderT ()
|
updatePackageIfRequired :: Package -> Text -> SlackBuilderT ()
|
||||||
updatePackageIfRequired package@Package{..} version = do
|
updatePackageIfRequired package@Package{..} version = do
|
||||||
@ -275,60 +285,42 @@ 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
|
updateDownload package (Package.Updater updater downloadTemplate) = updater
|
||||||
>>= getVersion (Text.pack $ Text.unpack category </> Text.unpack name) . fromJust
|
>>= renderAndDownload package downloadTemplate . fromJust
|
||||||
|
|
||||||
cloneFromGit :: URI -> Text -> Text -> Text -> SlackBuilderT (URI, Digest MD5)
|
renderAndDownload :: Package -> Package.DownloadTemplate -> Text -> SlackBuilderT (URI, Digest MD5)
|
||||||
cloneFromGit repo tagPrefix packagePath version = do
|
renderAndDownload Package{..} downloadTemplate version = do
|
||||||
repository' <- SlackBuilderT $ asks repository
|
let packagePath = category <> "/" <> name
|
||||||
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
|
|
||||||
repository' <- SlackBuilderT $ asks repository
|
repository' <- SlackBuilderT $ asks repository
|
||||||
uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version
|
uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version
|
||||||
let downloadFileName = URI.unRText
|
let downloadFileName = URI.unRText
|
||||||
$ NonEmpty.last $ snd $ fromJust $ URI.uriPath uri'
|
$ NonEmpty.last $ snd $ fromJust $ URI.uriPath uri'
|
||||||
relativeTarball = packagePath <> "/" <> downloadFileName
|
relativeTarball = packagePath <> "/" <> downloadFileName
|
||||||
tarball = repository' </> Text.unpack relativeTarball
|
tarball = repository' </> Text.unpack relativeTarball
|
||||||
|
liftIO $ putStrLn
|
||||||
|
$ "Downloading " <> Text.unpack (URI.render uri') <> " to " <> tarball <> "."
|
||||||
checksum <- fromJust <$> download uri' tarball
|
checksum <- fromJust <$> download uri' tarball
|
||||||
pure (uri', checksum)
|
download' <- handleReupload uri' relativeTarball downloadFileName
|
||||||
|
|
||||||
reuploadWithTemplate :: Package.DownloadTemplate -> [CmdSpec] -> Text -> Text -> SlackBuilderT (URI, Digest MD5)
|
|
||||||
reuploadWithTemplate downloadTemplate commands packagePath version = do
|
|
||||||
(uri', checksum) <- downloadWithTemplate downloadTemplate packagePath version
|
|
||||||
let downloadFileName = URI.unRText
|
|
||||||
$ NonEmpty.last $ snd $ fromJust $ URI.uriPath uri'
|
|
||||||
relativeTarball = packagePath <> "/" <> downloadFileName
|
|
||||||
download' <- handleReupload relativeTarball downloadFileName
|
|
||||||
|
|
||||||
pure (download', checksum)
|
pure (download', checksum)
|
||||||
where
|
where
|
||||||
name' = Text.pack $ takeBaseName $ Text.unpack packagePath
|
handleReupload uri' relativeTarball downloadFileName = do
|
||||||
handleReupload relativeTarball downloadFileName = do
|
|
||||||
repository' <- SlackBuilderT $ asks repository
|
repository' <- SlackBuilderT $ asks repository
|
||||||
case commands of
|
case reupload of
|
||||||
[] -> uploadTarball relativeTarball downloadFileName
|
Just [] -> uploadTarball relativeTarball downloadFileName
|
||||||
_ ->
|
Just commands ->
|
||||||
let tarballPath = repository' </> Text.unpack relativeTarball
|
let tarballPath = repository' </> Text.unpack relativeTarball
|
||||||
packedDirectory = takeBaseName $ dropExtension tarballPath
|
packedDirectory = takeBaseName $ dropExtension tarballPath
|
||||||
in liftIO (callProcess "tar" ["xvf", tarballPath])
|
in liftIO (callProcess "tar" ["xvf", tarballPath])
|
||||||
>> liftIO (traverse (defaultCreateProcess packedDirectory) commands)
|
>> liftIO (traverse (defaultCreateProcess packedDirectory) commands)
|
||||||
>> liftIO (callProcess "tar" ["Jcvf", tarballPath, packedDirectory])
|
>> liftIO (callProcess "tar" ["Jcvf", tarballPath, packedDirectory])
|
||||||
>> uploadTarball relativeTarball downloadFileName
|
>> uploadTarball relativeTarball downloadFileName
|
||||||
|
Nothing -> pure uri'
|
||||||
uploadTarball relativeTarball downloadFileName
|
uploadTarball relativeTarball downloadFileName
|
||||||
= liftIO (putStrLn $ "Upload the source tarball " <> Text.unpack relativeTarball)
|
= liftIO (putStrLn $ "Upload the source tarball " <> Text.unpack relativeTarball)
|
||||||
>> uploadCommand relativeTarball ("/" <> name')
|
>> uploadCommand relativeTarball ("/" <> name)
|
||||||
>> liftIO (mkURI $ "https://download.dlackware.com/hosted-sources/" <> name' <> "/" <> downloadFileName)
|
>> liftIO (mkURI $ "https://download.dlackware.com/hosted-sources/" <> name <> "/" <> downloadFileName)
|
||||||
defaultCreateProcess cwd' cmdSpec
|
defaultCreateProcess cwd' cmdSpec
|
||||||
= flip withCreateProcess (const . const . const waitForProcess)
|
= flip withCreateProcess (const . const . const waitForProcess)
|
||||||
$ CreateProcess
|
$ CreateProcess
|
||||||
@ -349,19 +341,13 @@ reuploadWithTemplate downloadTemplate commands packagePath version = do
|
|||||||
, child_group = Nothing
|
, child_group = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
renderAndDownload :: Package -> Text -> SlackBuilderT (URI, Digest MD5)
|
|
||||||
renderAndDownload Package{..} version = do
|
|
||||||
let packagePath = category <> "/" <> name
|
|
||||||
Package.Updater _ getVersion = latest
|
|
||||||
|
|
||||||
getVersion packagePath version
|
|
||||||
|
|
||||||
updatePackage :: Package -> PackageInfo -> Text -> SlackBuilderT ()
|
updatePackage :: Package -> PackageInfo -> Text -> SlackBuilderT ()
|
||||||
updatePackage package@Package{..} info version = do
|
updatePackage package@Package{..} info version = do
|
||||||
let packagePath = category <> "/" <> name
|
let packagePath = category <> "/" <> name
|
||||||
|
Package.Updater _ downloadTemplate = latest
|
||||||
|
|
||||||
repository' <- SlackBuilderT $ asks repository
|
repository' <- SlackBuilderT $ asks repository
|
||||||
mainDownload <- renderAndDownload package version
|
mainDownload <- renderAndDownload package downloadTemplate version
|
||||||
moreDownloads <- traverse (updateDownload package) downloaders
|
moreDownloads <- traverse (updateDownload package) downloaders
|
||||||
let (allDownloads, allChecksums) = unzip $ mainDownload : moreDownloads
|
let (allDownloads, allChecksums) = unzip $ mainDownload : moreDownloads
|
||||||
let infoFilePath = repository' </> Text.unpack packagePath
|
let infoFilePath = repository' </> Text.unpack packagePath
|
||||||
|
@ -17,6 +17,7 @@ import qualified Text.URI as URI
|
|||||||
import Crypto.Hash (Digest, MD5)
|
import Crypto.Hash (Digest, MD5)
|
||||||
import SlackBuilder.Trans
|
import SlackBuilder.Trans
|
||||||
import Control.Monad.Catch (MonadThrow)
|
import Control.Monad.Catch (MonadThrow)
|
||||||
|
import System.Process (CmdSpec(..))
|
||||||
|
|
||||||
-- | Contains information how a package can be updated.
|
-- | Contains information how a package can be updated.
|
||||||
data Package = Package
|
data Package = Package
|
||||||
@ -24,6 +25,7 @@ data Package = Package
|
|||||||
, downloaders :: [Updater]
|
, downloaders :: [Updater]
|
||||||
, category :: Text
|
, category :: Text
|
||||||
, name :: Text
|
, name :: Text
|
||||||
|
, reupload :: Maybe [CmdSpec]
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Download URI with the MD5 checksum of the target.
|
-- | Download URI with the MD5 checksum of the target.
|
||||||
@ -77,7 +79,4 @@ renderDownloadWithVersion (DownloadTemplate components) version =
|
|||||||
f VersionPlaceholder = (version <>)
|
f VersionPlaceholder = (version <>)
|
||||||
|
|
||||||
-- | Function used to get the latest version of a source.
|
-- | Function used to get the latest version of a source.
|
||||||
data Updater = Updater
|
data Updater = Updater (SlackBuilderT (Maybe Text)) DownloadTemplate
|
||||||
{ detectLatest :: SlackBuilderT (Maybe Text)
|
|
||||||
, getVersion :: Text -> Text -> SlackBuilderT (URI, Digest MD5)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user