Support x86-64 only downloads
All checks were successful
Build / audit (push) Successful in 16m16s
Build / test (push) Successful in 15m47s

This commit is contained in:
Eugen Wissner 2023-12-12 18:51:44 +01:00
parent 6a063b2cc4
commit eb68629653
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
4 changed files with 24 additions and 13 deletions

View File

@ -1,3 +1,4 @@
-- | Configuration file.
module SlackBuilder.Config module SlackBuilder.Config
( Settings(..) ( Settings(..)
, MaintainerSettings(..) , MaintainerSettings(..)

View File

@ -1,3 +1,4 @@
-- | Info file parsing and printing.
module SlackBuilder.Info module SlackBuilder.Info
( PackageInfo(..) ( PackageInfo(..)
, generate , generate
@ -113,7 +114,7 @@ generate pkg = Lazy.Text.toStrict $ Text.Builder.toLazyText builder
builder = "PRGNAM=\"" <> Text.Builder.fromString (pkgname pkg) <> "\"\n" builder = "PRGNAM=\"" <> Text.Builder.fromString (pkgname pkg) <> "\"\n"
<> "VERSION=\"" <> Text.Builder.fromText (version pkg) <> "\"\n" <> "VERSION=\"" <> Text.Builder.fromText (version pkg) <> "\"\n"
<> "HOMEPAGE=\"" <> Text.Builder.fromText (homepage pkg) <> "\"\n" <> "HOMEPAGE=\"" <> Text.Builder.fromText (homepage pkg) <> "\"\n"
<> generateMultiEntry "DOWNLOAD" (render <$> downloads pkg) <> downloadEntry
<> generateMultiEntry "MD5SUM" (digestToText <$> checksums pkg) <> generateMultiEntry "MD5SUM" (digestToText <$> checksums pkg)
<> generateMultiEntry "DOWNLOAD_x86_64" (render <$> downloadX64 pkg) <> generateMultiEntry "DOWNLOAD_x86_64" (render <$> downloadX64 pkg)
<> generateMultiEntry "MD5SUM_x86_64" (digestToText <$> checksumX64 pkg) <> generateMultiEntry "MD5SUM_x86_64" (digestToText <$> checksumX64 pkg)
@ -122,6 +123,10 @@ generate pkg = Lazy.Text.toStrict $ Text.Builder.toLazyText builder
<> "EMAIL=\"" <> Text.Builder.fromText (email pkg) <> "\"\n" <> "EMAIL=\"" <> Text.Builder.fromText (email pkg) <> "\"\n"
fromByteStringWords = Text.Builder.fromText fromByteStringWords = Text.Builder.fromText
. Text.unwords . fmap Text.decodeUtf8 . Text.unwords . fmap Text.decodeUtf8
downloadEntry
| null $ downloads pkg
, not $ null $ downloadX64 pkg = "DOWNLOAD=\"UNSUPPORTED\"\n"
| otherwise = generateMultiEntry "DOWNLOAD" $ render <$> downloads pkg
generateMultiEntry :: Text -> [Text] -> Text.Builder generateMultiEntry :: Text -> [Text] -> Text.Builder
generateMultiEntry name entries = Text.Builder.fromText name generateMultiEntry name entries = Text.Builder.fromText name

View File

@ -1,3 +1,4 @@
-- | Transformers and exceptions.
module SlackBuilder.Trans module SlackBuilder.Trans
( SlackBuilderException(..) ( SlackBuilderException(..)
, SlackBuilderT(..) , SlackBuilderT(..)

View File

@ -49,7 +49,7 @@ import System.Console.ANSI
) )
import System.Directory (listDirectory, doesDirectoryExist) import System.Directory (listDirectory, doesDirectoryExist)
import Control.Monad (filterM) import Control.Monad (filterM)
import Data.List (isPrefixOf, isSuffixOf) import Data.List (isPrefixOf, isSuffixOf, partition)
autoUpdatable :: [Package] autoUpdatable :: [Package]
autoUpdatable = autoUpdatable =
@ -78,7 +78,7 @@ 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' $ downloadWithTemplate template False
, category = "development" , category = "development"
, name = "composer" , name = "composer"
, downloaders = mempty , downloaders = mempty
@ -95,7 +95,7 @@ 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' $ downloadWithTemplate template False
, category = "network" , category = "network"
, name = "jitsi-meet-desktop" , name = "jitsi-meet-desktop"
, downloaders = mempty , downloaders = mempty
@ -116,7 +116,7 @@ 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' $ downloadWithTemplate template False
, category = "development" , category = "development"
, name = "php82" , name = "php82"
, downloaders = mempty , downloaders = mempty
@ -176,7 +176,7 @@ 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' $ downloadWithTemplate template True
, category = "network" , category = "network"
, name = "webex" , name = "webex"
, downloaders = mempty , downloaders = mempty
@ -213,7 +213,7 @@ 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' $ downloadWithTemplate template False
, category = "development" , category = "development"
, name = "dmd" , name = "dmd"
, downloaders = mempty , downloaders = mempty
@ -244,7 +244,7 @@ autoUpdatable =
dscannerURI = [uri|https://github.com/dlang-community/D-Scanner.git|] dscannerURI = [uri|https://github.com/dlang-community/D-Scanner.git|]
dcdURI = [uri|https://github.com/dlang-community/DCD.git|] dcdURI = [uri|https://github.com/dlang-community/DCD.git|]
in Map.fromList in Map.fromList
[ ("DUB", Package.Updater latestDub $ downloadWithTemplate dubTemplate) [ ("DUB", Package.Updater latestDub $ downloadWithTemplate dubTemplate False)
, ("DSCANNER", Package.Updater latestDscanner $ cloneFromGit dscannerURI "v") , ("DSCANNER", Package.Updater latestDscanner $ cloneFromGit dscannerURI "v")
, ("DCD", Package.Updater latestDcd $ cloneFromGit dcdURI "v") , ("DCD", Package.Updater latestDcd $ cloneFromGit dcdURI "v")
] ]
@ -327,8 +327,8 @@ cloneFromGit repo tagPrefix packagePath version = do
(flip . flip Package.Download) (fromJust checksum) False (flip . flip Package.Download) (fromJust checksum) False
<$> liftIO (mkURI $ "https://download.dlackware.com/hosted-sources/" <> name' <> "/" <> downloadFileName) <$> liftIO (mkURI $ "https://download.dlackware.com/hosted-sources/" <> name' <> "/" <> downloadFileName)
downloadWithTemplate :: Package.DownloadTemplate -> Text -> Text -> SlackBuilderT Package.Download downloadWithTemplate :: Package.DownloadTemplate -> Bool -> Text -> Text -> SlackBuilderT Package.Download
downloadWithTemplate downloadTemplate packagePath version = do downloadWithTemplate downloadTemplate is64' 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
@ -336,11 +336,12 @@ downloadWithTemplate downloadTemplate packagePath version = do
relativeTarball = packagePath <> "/" <> downloadFileName relativeTarball = packagePath <> "/" <> downloadFileName
tarball = repository' </> Text.unpack relativeTarball tarball = repository' </> Text.unpack relativeTarball
checksum <- fromJust <$> download uri' tarball checksum <- fromJust <$> download uri' tarball
pure $ Package.Download uri' checksum False pure $ Package.Download uri' checksum is64'
reuploadWithTemplate :: Package.DownloadTemplate -> [CmdSpec] -> Text -> Text -> SlackBuilderT Package.Download reuploadWithTemplate :: Package.DownloadTemplate -> [CmdSpec] -> Text -> Text -> SlackBuilderT Package.Download
reuploadWithTemplate downloadTemplate commands packagePath version = do reuploadWithTemplate downloadTemplate commands packagePath version = do
Package.Download{ download = uri', md5sum = checksum } <- downloadWithTemplate downloadTemplate packagePath version Package.Download{ download = uri', md5sum = checksum } <-
downloadWithTemplate downloadTemplate False packagePath 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
@ -398,13 +399,16 @@ updatePackage package@Package{..} version info = do
repository' <- SlackBuilderT $ asks repository repository' <- SlackBuilderT $ asks repository
mainDownload <- renderAndDownload package version mainDownload <- renderAndDownload package version
moreDownloads <- traverse (updateDownload package) downloaders moreDownloads <- traverse (updateDownload package) downloaders
let allDownloads = mainDownload : toList (fst <$> moreDownloads) let (downloads64, allDownloads) = partition (getField @"is64")
$ mainDownload : toList (fst <$> moreDownloads)
let infoFilePath = repository' </> Text.unpack packagePath let infoFilePath = repository' </> Text.unpack packagePath
</> (Text.unpack name <.> "info") </> (Text.unpack name <.> "info")
package' = info package' = info
{ version = version { version = version
, downloads = getField @"download" <$> allDownloads , downloads = getField @"download" <$> allDownloads
, checksums = getField @"md5sum" <$> allDownloads , checksums = getField @"md5sum" <$> allDownloads
, downloadX64 = getField @"download" <$> downloads64
, checksumX64 = getField @"md5sum" <$> downloads64
} }
liftIO $ Text.IO.writeFile infoFilePath $ generate package' liftIO $ Text.IO.writeFile infoFilePath $ generate package'
updateSlackBuildVersion packagePath version $ snd <$> moreDownloads updateSlackBuildVersion packagePath version $ snd <$> moreDownloads