Include repackaging command into configuration
This commit is contained in:
parent
d9bfd2941c
commit
8168804d71
@ -36,6 +36,7 @@ data PackageSettings = PackageSettings
|
|||||||
, github :: Maybe (Text, Text)
|
, github :: Maybe (Text, Text)
|
||||||
, packagist :: Maybe (Text, Text)
|
, packagist :: Maybe (Text, Text)
|
||||||
, text :: Maybe (Text, [String])
|
, text :: Maybe (Text, [String])
|
||||||
|
, repackage :: Maybe [String]
|
||||||
} deriving (Eq, Show)
|
} deriving (Eq, Show)
|
||||||
|
|
||||||
settingsCodec :: Toml.TomlCodec Settings
|
settingsCodec :: Toml.TomlCodec Settings
|
||||||
@ -59,7 +60,8 @@ packageSettingsCodec = PackageSettings
|
|||||||
<*> Toml.bool "is64" .= is64
|
<*> Toml.bool "is64" .= is64
|
||||||
<*> Toml.dioptional (Toml.table githubCodec "github") .= github
|
<*> Toml.dioptional (Toml.table githubCodec "github") .= github
|
||||||
<*> Toml.dioptional (Toml.table packagistCodec "packagist") .= packagist
|
<*> Toml.dioptional (Toml.table packagistCodec "packagist") .= packagist
|
||||||
<*> Toml.dioptional (Toml.table textCodec "text") .= text
|
<*> Toml.dioptional (Toml.table textCodec "text") .= text
|
||||||
|
<*> Toml.dioptional (Toml.arrayOf Toml._String "repackage") .= repackage
|
||||||
where
|
where
|
||||||
githubCodec = Toml.pair (Toml.text "owner") (Toml.text "name")
|
githubCodec = Toml.pair (Toml.text "owner") (Toml.text "name")
|
||||||
packagistCodec = Toml.pair (Toml.text "owner") (Toml.text "name")
|
packagistCodec = Toml.pair (Toml.text "owner") (Toml.text "name")
|
||||||
|
27
src/Main.hs
27
src/Main.hs
@ -24,7 +24,6 @@ import qualified SlackBuilder.Package as Package
|
|||||||
import Text.URI.QQ (uri)
|
import Text.URI.QQ (uri)
|
||||||
import Data.Foldable (find, traverse_)
|
import Data.Foldable (find, traverse_)
|
||||||
import GHC.Records (HasField(..))
|
import GHC.Records (HasField(..))
|
||||||
import System.Process (CmdSpec(..))
|
|
||||||
import System.Console.ANSI
|
import System.Console.ANSI
|
||||||
( setSGR
|
( setSGR
|
||||||
, SGR(..)
|
, SGR(..)
|
||||||
@ -43,7 +42,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
||||||
, getVersion = reuploadWithTemplate template []
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "universal-ctags"
|
, name = "universal-ctags"
|
||||||
@ -56,7 +55,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestPackagist packagistArguments
|
{ detectLatest = latestPackagist packagistArguments
|
||||||
, getVersion = downloadWithTemplate template
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "composer"
|
, name = "composer"
|
||||||
@ -69,7 +68,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(v)*"
|
{ detectLatest = latestGitHub ghArguments "(v)*"
|
||||||
, getVersion = downloadWithTemplate template
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "jitsi-meet-desktop"
|
, name = "jitsi-meet-desktop"
|
||||||
@ -82,7 +81,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(php-)8.2.\\d"
|
{ detectLatest = latestGitHub ghArguments "(php-)8.2.\\d"
|
||||||
, getVersion = downloadWithTemplate template
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "php82"
|
, name = "php82"
|
||||||
@ -95,7 +94,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
||||||
, getVersion = reuploadWithTemplate template [RawCommand "go" ["mod", "vendor"]]
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "kitty"
|
, name = "kitty"
|
||||||
@ -108,7 +107,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
||||||
, getVersion = reuploadWithTemplate template []
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "rdiff-backup"
|
, name = "rdiff-backup"
|
||||||
@ -121,7 +120,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestText textArguments "(Linux—)*"
|
{ detectLatest = latestText textArguments "(Linux—)*"
|
||||||
, getVersion = downloadWithTemplate template
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "webex"
|
, name = "webex"
|
||||||
@ -134,7 +133,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
||||||
, getVersion = reuploadWithTemplate template []
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "librsync"
|
, name = "librsync"
|
||||||
@ -147,7 +146,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestText textArguments "\\."
|
{ detectLatest = latestText textArguments "\\."
|
||||||
, getVersion = downloadWithTemplate template
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "dmd"
|
, name = "dmd"
|
||||||
@ -160,7 +159,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestText textArguments "\\."
|
{ detectLatest = latestText textArguments "\\."
|
||||||
, getVersion = reuploadWithTemplate template []
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "d-tools"
|
, name = "d-tools"
|
||||||
@ -170,7 +169,7 @@ autoUpdatable packageSettings =
|
|||||||
dcdArguments = PackageOwner{ owner = "dlang-community", name = "DCD" }
|
dcdArguments = PackageOwner{ owner = "dlang-community", name = "DCD" }
|
||||||
latestDub = Package.Updater
|
latestDub = Package.Updater
|
||||||
{ detectLatest = latestGitHub dubArguments "(v)\\."
|
{ detectLatest = latestGitHub dubArguments "(v)\\."
|
||||||
, getVersion = reuploadWithTemplate dubTemplate []
|
, getVersion = reuploadWithTemplate dubTemplate
|
||||||
, is64 = False
|
, is64 = False
|
||||||
}
|
}
|
||||||
latestDscanner = Package.Updater
|
latestDscanner = Package.Updater
|
||||||
@ -199,7 +198,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
{ detectLatest = latestGitHub ghArguments "(v)\\."
|
||||||
, getVersion = downloadWithTemplate template
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "simde"
|
, name = "simde"
|
||||||
@ -212,7 +211,7 @@ autoUpdatable packageSettings =
|
|||||||
template = Package.DownloadTemplate $ getField @"template" setting
|
template = Package.DownloadTemplate $ getField @"template" setting
|
||||||
in Package.Updater
|
in Package.Updater
|
||||||
{ detectLatest = latestGitHub ghArguments "(release-)\\d.[02468].\\d"
|
{ detectLatest = latestGitHub ghArguments "(release-)\\d.[02468].\\d"
|
||||||
, getVersion = downloadWithTemplate template
|
, getVersion = repackageWithTemplate (getField @"repackage" setting) template
|
||||||
, is64 = getField @"is64" setting
|
, is64 = getField @"is64" setting
|
||||||
}
|
}
|
||||||
, name = "nginx"
|
, name = "nginx"
|
||||||
|
@ -8,6 +8,7 @@ module SlackBuilder.Update
|
|||||||
, downloadWithTemplate
|
, downloadWithTemplate
|
||||||
, getAndLogLatest
|
, getAndLogLatest
|
||||||
, handleException
|
, handleException
|
||||||
|
, repackageWithTemplate
|
||||||
, reuploadWithTemplate
|
, reuploadWithTemplate
|
||||||
, updatePackageIfRequired
|
, updatePackageIfRequired
|
||||||
) where
|
) where
|
||||||
@ -142,6 +143,12 @@ cloneFromGit repo tagPrefix packagePath version = do
|
|||||||
, download = uri'
|
, download = uri'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repackageWithTemplate :: Maybe [String] -> Package.DownloadTemplate -> Text -> Text -> SlackBuilderT Package.Download
|
||||||
|
repackageWithTemplate Nothing template' = downloadWithTemplate template'
|
||||||
|
repackageWithTemplate (Just (cmd : arguments)) template' =
|
||||||
|
reuploadWithTemplate' template' (RawCommand cmd arguments)
|
||||||
|
repackageWithTemplate (Just []) template' = reuploadWithTemplate template'
|
||||||
|
|
||||||
downloadWithTemplate :: Package.DownloadTemplate -> Text -> Text -> SlackBuilderT Package.Download
|
downloadWithTemplate :: Package.DownloadTemplate -> Text -> Text -> SlackBuilderT Package.Download
|
||||||
downloadWithTemplate downloadTemplate packagePath version = do
|
downloadWithTemplate downloadTemplate packagePath version = do
|
||||||
repository' <- SlackBuilderT $ asks repository
|
repository' <- SlackBuilderT $ asks repository
|
||||||
@ -149,8 +156,19 @@ downloadWithTemplate downloadTemplate packagePath version = do
|
|||||||
checksum <- download uri' $ repository' </> Text.unpack packagePath
|
checksum <- download uri' $ repository' </> Text.unpack packagePath
|
||||||
pure $ Package.Download uri' $ snd checksum
|
pure $ Package.Download uri' $ snd checksum
|
||||||
|
|
||||||
reuploadWithTemplate :: Package.DownloadTemplate -> [CmdSpec] -> Text -> Text -> SlackBuilderT Package.Download
|
reuploadWithTemplate :: Package.DownloadTemplate -> Text -> Text -> SlackBuilderT Package.Download
|
||||||
reuploadWithTemplate downloadTemplate commands packagePath version = do
|
reuploadWithTemplate downloadTemplate packagePath version = do
|
||||||
|
repository' <- SlackBuilderT $ asks repository
|
||||||
|
uri' <- liftIO $ Package.renderDownloadWithVersion downloadTemplate version
|
||||||
|
let packagePathRelativeToCurrent = repository' </> Text.unpack packagePath
|
||||||
|
(downloadedFileName, checksum) <- download uri' packagePathRelativeToCurrent
|
||||||
|
|
||||||
|
download' <- handleReupload packagePath
|
||||||
|
$ packagePathRelativeToCurrent </> downloadedFileName
|
||||||
|
pure $ Package.Download download' checksum
|
||||||
|
|
||||||
|
reuploadWithTemplate' :: Package.DownloadTemplate -> CmdSpec -> Text -> Text -> SlackBuilderT Package.Download
|
||||||
|
reuploadWithTemplate' downloadTemplate commands 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 = Text.unpack
|
let downloadFileName = Text.unpack
|
||||||
@ -158,22 +176,16 @@ reuploadWithTemplate downloadTemplate commands packagePath version = do
|
|||||||
$ NonEmpty.last $ snd $ fromJust $ URI.uriPath uri'
|
$ NonEmpty.last $ snd $ fromJust $ URI.uriPath uri'
|
||||||
packagePathRelativeToCurrent = repository' </> Text.unpack packagePath
|
packagePathRelativeToCurrent = repository' </> Text.unpack packagePath
|
||||||
|
|
||||||
(relativeTarball', checksum) <- case commands of
|
changedArchiveRootName <- extractRemote uri' packagePathRelativeToCurrent
|
||||||
[] -> do
|
let relativeTarball = packagePathRelativeToCurrent
|
||||||
(downloadedFileName, checksum) <- download uri' packagePathRelativeToCurrent
|
</> fromMaybe downloadFileName changedArchiveRootName
|
||||||
pure (packagePathRelativeToCurrent </> downloadedFileName, checksum)
|
(relativeTarball', checksum) <- prepareSource relativeTarball
|
||||||
_ -> do
|
|
||||||
changedArchiveRootName <- extractRemote uri' packagePathRelativeToCurrent
|
|
||||||
let relativeTarball = packagePathRelativeToCurrent
|
|
||||||
</> fromMaybe downloadFileName changedArchiveRootName
|
|
||||||
prepareSource relativeTarball
|
|
||||||
|
|
||||||
download' <- handleReupload relativeTarball'
|
download' <- handleReupload packagePath relativeTarball'
|
||||||
pure $ Package.Download download' checksum
|
pure $ Package.Download download' checksum
|
||||||
where
|
where
|
||||||
category' = Text.pack $ takeBaseName $ Text.unpack packagePath
|
|
||||||
prepareSource tarballPath =
|
prepareSource tarballPath =
|
||||||
liftIO (traverse (defaultCreateProcess tarballPath) commands)
|
liftIO (defaultCreateProcess tarballPath commands)
|
||||||
>> liftIO (tarCompress tarballPath)
|
>> liftIO (tarCompress tarballPath)
|
||||||
<* liftIO (removeDirectoryRecursive tarballPath)
|
<* liftIO (removeDirectoryRecursive tarballPath)
|
||||||
tarCompress tarballPath =
|
tarCompress tarballPath =
|
||||||
@ -182,13 +194,6 @@ reuploadWithTemplate downloadTemplate commands packagePath version = do
|
|||||||
in fmap (appendTarExtension tarballPath,)
|
in fmap (appendTarExtension tarballPath,)
|
||||||
$ withCurrentDirectory (takeDirectory tarballPath)
|
$ withCurrentDirectory (takeDirectory tarballPath)
|
||||||
$ createLzmaTarball archiveBaseFilename (appendTarExtension archiveBaseFilename)
|
$ createLzmaTarball archiveBaseFilename (appendTarExtension archiveBaseFilename)
|
||||||
handleReupload relativeTarball = do
|
|
||||||
liftIO $ putStrLn $ "Upload the source tarball " <> relativeTarball
|
|
||||||
uploadSource relativeTarball category'
|
|
||||||
|
|
||||||
hostedSources $ NonEmpty.cons category'
|
|
||||||
$ pure $ Text.pack $ takeFileName relativeTarball
|
|
||||||
|
|
||||||
defaultCreateProcess cwd' cmdSpec
|
defaultCreateProcess cwd' cmdSpec
|
||||||
= flip withCreateProcess (const . const . const waitForProcess)
|
= flip withCreateProcess (const . const . const waitForProcess)
|
||||||
$ CreateProcess
|
$ CreateProcess
|
||||||
@ -209,6 +214,16 @@ reuploadWithTemplate downloadTemplate commands packagePath version = do
|
|||||||
, child_group = Nothing
|
, child_group = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleReupload :: Text -> String -> SlackBuilderT URI
|
||||||
|
handleReupload packagePath relativeTarball = do
|
||||||
|
liftIO $ putStrLn $ "Upload the source tarball " <> relativeTarball
|
||||||
|
uploadSource relativeTarball category'
|
||||||
|
|
||||||
|
hostedSources $ NonEmpty.cons category'
|
||||||
|
$ pure $ Text.pack $ takeFileName relativeTarball
|
||||||
|
where
|
||||||
|
category' = Text.pack $ takeBaseName $ Text.unpack packagePath
|
||||||
|
|
||||||
updatePackage :: PackageUpdateData -> PackageInfo -> SlackBuilderT ()
|
updatePackage :: PackageUpdateData -> PackageInfo -> SlackBuilderT ()
|
||||||
updatePackage PackageUpdateData{..} info = do
|
updatePackage PackageUpdateData{..} info = do
|
||||||
let packagePath = category <> "/" <> getField @"name" description
|
let packagePath = category <> "/" <> getField @"name" description
|
||||||
|
Loading…
Reference in New Issue
Block a user