Make is64 property part of the updater
This commit is contained in:
parent
7edb811dc2
commit
2802194063
@ -34,7 +34,6 @@ data Package = Package
|
||||
data Download = Download
|
||||
{ download :: URI
|
||||
, md5sum :: Digest MD5
|
||||
, is64 :: Bool
|
||||
} deriving (Eq, Show)
|
||||
|
||||
-- | Package maintainer information.
|
||||
@ -74,5 +73,6 @@ renderDownloadWithVersion (DownloadTemplate components) version =
|
||||
-- | Function used to get the latest version of a source.
|
||||
data Updater = Updater
|
||||
{ detectLatest :: SlackBuilderT (Maybe Text)
|
||||
, is64 :: Bool
|
||||
, getVersion :: Text -> Text -> SlackBuilderT Download
|
||||
}
|
||||
|
155
src/Main.hs
155
src/Main.hs
@ -60,7 +60,6 @@ autoUpdatable =
|
||||
[ Package
|
||||
{ latest =
|
||||
let ghArguments = PackageOwner{ owner = "universal-ctags", name = "ctags" }
|
||||
latest' = latestGitHub ghArguments stableTagTransform
|
||||
templateTail =
|
||||
[ Package.VersionPlaceholder
|
||||
, Package.StaticPlaceholder "/ctags-"
|
||||
@ -70,7 +69,11 @@ autoUpdatable =
|
||||
template = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://github.com/universal-ctags/ctags/archive/"
|
||||
:| templateTail
|
||||
in Package.Updater latest' $ reuploadWithTemplate template []
|
||||
in Package.Updater
|
||||
{ detectLatest = latestGitHub ghArguments stableTagTransform
|
||||
, getVersion = reuploadWithTemplate template []
|
||||
, is64 = False
|
||||
}
|
||||
, category = "development"
|
||||
, name = "universal-ctags"
|
||||
, downloaders = mempty
|
||||
@ -78,11 +81,14 @@ autoUpdatable =
|
||||
, Package
|
||||
{ latest =
|
||||
let packagistArguments = PackageOwner{ owner = "composer", name = "composer" }
|
||||
latest' = latestPackagist packagistArguments
|
||||
template = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://getcomposer.org/download/"
|
||||
:| [Package.VersionPlaceholder, Package.StaticPlaceholder "/composer.phar"]
|
||||
in Package.Updater latest' $ downloadWithTemplate template False
|
||||
in Package.Updater
|
||||
{ detectLatest = latestPackagist packagistArguments
|
||||
, getVersion = downloadWithTemplate template
|
||||
, is64 = False
|
||||
}
|
||||
, category = "development"
|
||||
, name = "composer"
|
||||
, downloaders = mempty
|
||||
@ -93,12 +99,15 @@ autoUpdatable =
|
||||
{ owner = "jitsi"
|
||||
, name = "jitsi-meet-electron"
|
||||
}
|
||||
latest' = latestGitHub ghArguments $ Text.stripPrefix "v"
|
||||
template = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://github.com/jitsi/jitsi-meet-electron/releases/download/v"
|
||||
:| Package.VersionPlaceholder
|
||||
: [Package.StaticPlaceholder "/jitsi-meet-x86_64.AppImage"]
|
||||
in Package.Updater latest' $ downloadWithTemplate template False
|
||||
in Package.Updater
|
||||
{ detectLatest = latestGitHub ghArguments $ Text.stripPrefix "v"
|
||||
, getVersion = downloadWithTemplate template
|
||||
, is64 = True
|
||||
}
|
||||
, category = "network"
|
||||
, name = "jitsi-meet-desktop"
|
||||
, downloaders = mempty
|
||||
@ -113,12 +122,15 @@ autoUpdatable =
|
||||
| not $ Text.isInfixOf "RC" x
|
||||
, Text.isPrefixOf "php-8.2." x = Text.stripPrefix "php-" x
|
||||
| otherwise = Nothing
|
||||
latest' = latestGitHub ghArguments checkVersion
|
||||
template = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://www.php.net/distributions/php-"
|
||||
:| Package.VersionPlaceholder
|
||||
: [Package.StaticPlaceholder ".tar.xz"]
|
||||
in Package.Updater latest' $ downloadWithTemplate template False
|
||||
in Package.Updater
|
||||
{ detectLatest = latestGitHub ghArguments checkVersion
|
||||
, getVersion = downloadWithTemplate template
|
||||
, is64 = False
|
||||
}
|
||||
, category = "development"
|
||||
, name = "php82"
|
||||
, downloaders = mempty
|
||||
@ -129,7 +141,6 @@ autoUpdatable =
|
||||
{ owner = "kovidgoyal"
|
||||
, name = "kitty"
|
||||
}
|
||||
latest' = latestGitHub ghArguments stableTagTransform
|
||||
templateTail =
|
||||
[ Package.StaticPlaceholder "/kitty-"
|
||||
, Package.VersionPlaceholder
|
||||
@ -139,7 +150,11 @@ autoUpdatable =
|
||||
$ Package.StaticPlaceholder "https://github.com/kovidgoyal/kitty/releases/download/v"
|
||||
:| Package.VersionPlaceholder
|
||||
: templateTail
|
||||
in Package.Updater latest' $ reuploadWithTemplate template [RawCommand "go" ["mod", "vendor"]]
|
||||
in Package.Updater
|
||||
{ detectLatest = latestGitHub ghArguments stableTagTransform
|
||||
, getVersion = reuploadWithTemplate template [RawCommand "go" ["mod", "vendor"]]
|
||||
, is64 = False
|
||||
}
|
||||
, category = "system"
|
||||
, name = "kitty"
|
||||
, downloaders = mempty
|
||||
@ -150,14 +165,17 @@ autoUpdatable =
|
||||
{ owner = "rdiff-backup"
|
||||
, name = "rdiff-backup"
|
||||
}
|
||||
latest' = latestGitHub ghArguments $ Text.stripPrefix "v"
|
||||
template = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://github.com/rdiff-backup/rdiff-backup/releases/download/v"
|
||||
:| Package.VersionPlaceholder
|
||||
: Package.StaticPlaceholder "/rdiff-backup-"
|
||||
: Package.VersionPlaceholder
|
||||
: [Package.StaticPlaceholder ".tar.gz"]
|
||||
in Package.Updater latest' $ reuploadWithTemplate template []
|
||||
in Package.Updater
|
||||
{ detectLatest = latestGitHub ghArguments $ Text.stripPrefix "v"
|
||||
, getVersion = reuploadWithTemplate template []
|
||||
, is64 = False
|
||||
}
|
||||
, category = "system"
|
||||
, name = "rdiff-backup"
|
||||
, downloaders = mempty
|
||||
@ -172,11 +190,14 @@ autoUpdatable =
|
||||
. snd
|
||||
. Text.breakOn needle
|
||||
}
|
||||
latest' = latestText textArguments
|
||||
template = Package.DownloadTemplate $ pure
|
||||
$ Package.StaticPlaceholder
|
||||
"https://binaries.webex.com/WebexDesktop-Ubuntu-Official-Package/Webex.deb"
|
||||
in Package.Updater latest' $ downloadWithTemplate template True
|
||||
in Package.Updater
|
||||
{ detectLatest = latestText textArguments
|
||||
, getVersion = downloadWithTemplate template
|
||||
, is64 = True
|
||||
}
|
||||
, category = "network"
|
||||
, name = "webex"
|
||||
, downloaders = mempty
|
||||
@ -187,14 +208,17 @@ autoUpdatable =
|
||||
{ owner = "librsync"
|
||||
, name = "librsync"
|
||||
}
|
||||
latest' = latestGitHub ghArguments $ Text.stripPrefix "v"
|
||||
template = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://github.com/librsync/librsync/archive/v"
|
||||
:| Package.VersionPlaceholder
|
||||
: Package.StaticPlaceholder "/librsync-"
|
||||
: Package.VersionPlaceholder
|
||||
: [Package.StaticPlaceholder ".tar.gz"]
|
||||
in Package.Updater latest' $ reuploadWithTemplate template []
|
||||
in Package.Updater
|
||||
{ detectLatest = latestGitHub ghArguments $ Text.stripPrefix "v"
|
||||
, getVersion = reuploadWithTemplate template []
|
||||
, is64 = True
|
||||
}
|
||||
, category = "libraries"
|
||||
, name = "librsync"
|
||||
, downloaders = mempty
|
||||
@ -205,14 +229,17 @@ autoUpdatable =
|
||||
{ textURL = "https://downloads.dlang.org/releases/LATEST"
|
||||
, versionPicker = Text.strip
|
||||
}
|
||||
latest' = latestText textArguments
|
||||
template = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://downloads.dlang.org/releases/2.x/"
|
||||
:| Package.VersionPlaceholder
|
||||
: Package.StaticPlaceholder "/dmd."
|
||||
: Package.VersionPlaceholder
|
||||
: [Package.StaticPlaceholder ".linux.tar.xz"]
|
||||
in Package.Updater latest' $ downloadWithTemplate template False
|
||||
in Package.Updater
|
||||
{ detectLatest = latestText textArguments
|
||||
, getVersion = downloadWithTemplate template
|
||||
, is64 = False
|
||||
}
|
||||
, category = "development"
|
||||
, name = "dmd"
|
||||
, downloaders = mempty
|
||||
@ -223,29 +250,44 @@ autoUpdatable =
|
||||
{ textURL = "https://downloads.dlang.org/releases/LATEST"
|
||||
, versionPicker = Text.strip
|
||||
}
|
||||
latest' = latestText textArguments
|
||||
template = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://codeload.github.com/dlang/tools/tar.gz/v"
|
||||
:| [Package.VersionPlaceholder]
|
||||
in Package.Updater latest' $ reuploadWithTemplate template []
|
||||
in Package.Updater
|
||||
{ detectLatest = latestText textArguments
|
||||
, getVersion = reuploadWithTemplate template []
|
||||
, is64 = False
|
||||
}
|
||||
, category = "development"
|
||||
, name = "d-tools"
|
||||
, downloaders =
|
||||
let dubArguments = PackageOwner{ owner = "dlang", name = "dub" }
|
||||
dscannerArguments = PackageOwner{ owner = "dlang-community", name = "D-Scanner" }
|
||||
dcdArguments = PackageOwner{ owner = "dlang-community", name = "DCD" }
|
||||
latestDub = latestGitHub dubArguments stableTagTransform
|
||||
latestDscanner = latestGitHub dscannerArguments stableTagTransform
|
||||
latestDcd = latestGitHub dcdArguments stableTagTransform
|
||||
latestDub = Package.Updater
|
||||
{ detectLatest = latestGitHub dubArguments stableTagTransform
|
||||
, getVersion = downloadWithTemplate dubTemplate
|
||||
, is64 = False
|
||||
}
|
||||
latestDscanner = Package.Updater
|
||||
{ detectLatest = latestGitHub dscannerArguments stableTagTransform
|
||||
, getVersion = cloneFromGit dscannerURI "v"
|
||||
, is64 = False
|
||||
}
|
||||
dcdURI = [uri|https://github.com/dlang-community/DCD.git|]
|
||||
latestDcd = Package.Updater
|
||||
{ detectLatest = latestGitHub dcdArguments stableTagTransform
|
||||
, getVersion = cloneFromGit dcdURI "v"
|
||||
, is64 = False
|
||||
}
|
||||
dubTemplate = Package.DownloadTemplate
|
||||
$ Package.StaticPlaceholder "https://codeload.github.com/dlang/dub/tar.gz/v"
|
||||
:| [Package.VersionPlaceholder]
|
||||
dscannerURI = [uri|https://github.com/dlang-community/D-Scanner.git|]
|
||||
dcdURI = [uri|https://github.com/dlang-community/DCD.git|]
|
||||
in Map.fromList
|
||||
[ ("DUB", Package.Updater latestDub $ downloadWithTemplate dubTemplate False)
|
||||
, ("DSCANNER", Package.Updater latestDscanner $ cloneFromGit dscannerURI "v")
|
||||
, ("DCD", Package.Updater latestDcd $ cloneFromGit dcdURI "v")
|
||||
[ ("DUB", latestDub)
|
||||
, ("DSCANNER", latestDscanner)
|
||||
, ("DCD", latestDcd)
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -307,11 +349,21 @@ updatePackageIfRequired package version
|
||||
= checkUpdateAvailability package version
|
||||
>>= mapM_ (updatePackage package version)
|
||||
|
||||
updateDownload :: Package -> Package.Updater -> SlackBuilderT (Package.Download, Text)
|
||||
updateDownload Package{..} Package.Updater{..} = do
|
||||
data DownloadUpdated = DownloadUpdated
|
||||
{ result :: Package.Download
|
||||
, version :: Text
|
||||
, is64 :: Bool
|
||||
} deriving (Eq, Show)
|
||||
|
||||
updateDownload :: Text -> Package.Updater -> SlackBuilderT DownloadUpdated
|
||||
updateDownload packagePath Package.Updater{..} = do
|
||||
latestDownloadVersion <- fromJust <$> detectLatest
|
||||
result <- getVersion (Text.pack $ Text.unpack category </> Text.unpack name) latestDownloadVersion
|
||||
pure (result, latestDownloadVersion)
|
||||
result <- getVersion packagePath latestDownloadVersion
|
||||
pure $ DownloadUpdated
|
||||
{ result = result
|
||||
, version = latestDownloadVersion
|
||||
, is64 = is64
|
||||
}
|
||||
|
||||
cloneFromGit :: URI -> Text -> Text -> Text -> SlackBuilderT Package.Download
|
||||
cloneFromGit repo tagPrefix packagePath version = do
|
||||
@ -322,12 +374,11 @@ cloneFromGit repo tagPrefix packagePath version = do
|
||||
(uri', checksum) <- fromJust <$> cloneAndUpload (URI.render repo) relativeTarball tagPrefix
|
||||
pure $ Package.Download
|
||||
{ md5sum = checksum
|
||||
, is64 = False
|
||||
, download = uri'
|
||||
}
|
||||
|
||||
downloadWithTemplate :: Package.DownloadTemplate -> Bool -> Text -> Text -> SlackBuilderT Package.Download
|
||||
downloadWithTemplate downloadTemplate is64' packagePath version = do
|
||||
downloadWithTemplate :: Package.DownloadTemplate -> Text -> Text -> SlackBuilderT Package.Download
|
||||
downloadWithTemplate downloadTemplate packagePath version = do
|
||||
repository' <- SlackBuilderT $ asks repository
|
||||
uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version
|
||||
let downloadFileName = URI.unRText
|
||||
@ -335,18 +386,18 @@ downloadWithTemplate downloadTemplate is64' packagePath version = do
|
||||
relativeTarball = packagePath <> "/" <> downloadFileName
|
||||
tarball = repository' </> Text.unpack relativeTarball
|
||||
checksum <- fromJust <$> download uri' tarball
|
||||
pure $ Package.Download uri' checksum is64'
|
||||
pure $ Package.Download uri' checksum
|
||||
|
||||
reuploadWithTemplate :: Package.DownloadTemplate -> [CmdSpec] -> Text -> Text -> SlackBuilderT Package.Download
|
||||
reuploadWithTemplate downloadTemplate commands packagePath version = do
|
||||
Package.Download{ download = uri', md5sum = checksum } <-
|
||||
downloadWithTemplate downloadTemplate False packagePath version
|
||||
downloadWithTemplate downloadTemplate packagePath version
|
||||
let downloadFileName = URI.unRText
|
||||
$ NonEmpty.last $ snd $ fromJust $ URI.uriPath uri'
|
||||
relativeTarball = packagePath <> "/" <> downloadFileName
|
||||
download' <- handleReupload (Text.unpack relativeTarball) downloadFileName
|
||||
|
||||
pure $ Package.Download download' checksum False
|
||||
pure $ Package.Download download' checksum
|
||||
where
|
||||
name' = Text.pack $ takeBaseName $ Text.unpack packagePath
|
||||
handleReupload relativeTarball downloadFileName = do
|
||||
@ -384,33 +435,29 @@ reuploadWithTemplate downloadTemplate commands packagePath version = do
|
||||
, child_group = Nothing
|
||||
}
|
||||
|
||||
renderAndDownload :: Package -> Text -> SlackBuilderT Package.Download
|
||||
renderAndDownload Package{..} version = do
|
||||
let packagePath = category <> "/" <> name
|
||||
Package.Updater _ getVersion = latest
|
||||
|
||||
getVersion packagePath version
|
||||
|
||||
updatePackage :: Package -> Text -> PackageInfo -> SlackBuilderT ()
|
||||
updatePackage package@Package{..} version info = do
|
||||
updatePackage Package{..} version info = do
|
||||
let packagePath = category <> "/" <> name
|
||||
|
||||
repository' <- SlackBuilderT $ asks repository
|
||||
mainDownload <- renderAndDownload package version
|
||||
moreDownloads <- traverse (updateDownload package) downloaders
|
||||
let (downloads64, allDownloads) = partition (getField @"is64")
|
||||
$ mainDownload : toList (fst <$> moreDownloads)
|
||||
mainDownload <- (, getField @"is64" latest)
|
||||
<$> getField @"getVersion" latest packagePath version
|
||||
moreDownloads <- traverse (updateDownload packagePath) downloaders
|
||||
let (downloads64, allDownloads) = partition snd
|
||||
$ mainDownload
|
||||
: (liftA2 (,) (getField @"result") (getField @"is64") <$> toList moreDownloads)
|
||||
let infoFilePath = repository' </> Text.unpack packagePath
|
||||
</> (Text.unpack name <.> "info")
|
||||
package' = info
|
||||
{ version = version
|
||||
, downloads = getField @"download" <$> allDownloads
|
||||
, checksums = getField @"md5sum" <$> allDownloads
|
||||
, downloadX64 = getField @"download" <$> downloads64
|
||||
, checksumX64 = getField @"md5sum" <$> downloads64
|
||||
, downloads = getField @"download" . fst <$> allDownloads
|
||||
, checksums = getField @"md5sum" . fst <$> allDownloads
|
||||
, downloadX64 = getField @"download" . fst <$> downloads64
|
||||
, checksumX64 = getField @"md5sum" . fst <$> downloads64
|
||||
}
|
||||
liftIO $ Text.IO.writeFile infoFilePath $ generate package'
|
||||
updateSlackBuildVersion packagePath version $ snd <$> moreDownloads
|
||||
updateSlackBuildVersion packagePath version
|
||||
$ getField @"version" <$> moreDownloads
|
||||
|
||||
commit packagePath version
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user