Allow looking on the text page for the latest version

This commit is contained in:
Eugen Wissner 2023-10-20 15:53:48 +02:00
parent 4105ffa91f
commit 3a6d17952b
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
4 changed files with 31 additions and 28 deletions

View File

@ -43,27 +43,6 @@ task :hhvm, [:version] do |_, arguments|
update_slackbuild_version 'development/hhvm', package.version update_slackbuild_version 'development/hhvm', package.version
end end
task :webex do
tarball = 'slackbuilds/network/webex/Webex.deb'
uri = 'https://binaries.webex.com/WebexDesktop-Ubuntu-Official-Package/Webex.deb'
checksum = SlackBuilder.download URI(uri), tarball
last_stdout, = Open3.pipeline_r ['ar', 'p', tarball, 'control.tar.gz'], ['tar', 'zxO', './control']
version = last_stdout.read.lines
.find { |line| line.start_with? 'Version: ' }
.split.last
package = Package.new 'network/webex',
version: version,
homepage: 'https://www.webex.com'
write_info package,
downloads: [Download.new(uri, checksum, is64: true)]
update_slackbuild_version 'network/webex', package.version
commit 'network/webex', package.version
end
AUTO_UPDATABLE = { AUTO_UPDATABLE = {
'dmd' => [SlackBuilder::LatestText.new('https://downloads.dlang.org/releases/LATEST')] 'dmd' => [SlackBuilder::LatestText.new('https://downloads.dlang.org/releases/LATEST')]
}.freeze }.freeze

View File

@ -2,6 +2,8 @@ module Main
( main ( main
) where ) where
import Data.Char (isNumber)
import Control.Applicative (Applicative(liftA2))
import Data.List.NonEmpty (NonEmpty(..)) import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty import qualified Data.List.NonEmpty as NonEmpty
import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.IO.Class (MonadIO(..))
@ -147,6 +149,25 @@ autoUpdatable =
, name = "rdiff-backup" , name = "rdiff-backup"
, reupload = Just mempty , reupload = Just mempty
} }
, Package
{ latest =
let needle = "Linux—"
textArguments = TextArguments
{ textURL = "https://help.webex.com/en-us/article/mqkve8/Webex-App-%7C-Release-notes"
, versionPicker = Text.takeWhile (liftA2 (||) (== '.') isNumber)
. Text.drop (Text.length needle)
. 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' template
, category = "network"
, name = "webex"
, reupload = Nothing
}
] ]
up2Date :: SlackBuilderT () up2Date :: SlackBuilderT ()

View File

@ -7,6 +7,7 @@ module SlackBuilder.CommandLine
) where ) where
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as Text
import Options.Applicative import Options.Applicative
( Parser ( Parser
, ParserInfo(..) , ParserInfo(..)
@ -29,7 +30,6 @@ data SlackBuilderCommand
| CloneCommand Text Text Text | CloneCommand Text Text Text
| DownloadAndDeployCommand Text Text | DownloadAndDeployCommand Text Text
| Up2DateCommand | Up2DateCommand
deriving (Eq, Show)
data PackagistArguments = PackagistArguments data PackagistArguments = PackagistArguments
{ vendor :: Text { vendor :: Text
@ -42,11 +42,14 @@ data GhArguments = GhArguments
, transform :: Maybe Text , transform :: Maybe Text
} deriving (Eq, Show) } deriving (Eq, Show)
newtype TextArguments = TextArguments Text data TextArguments = TextArguments
deriving (Eq, Show) { versionPicker :: Text -> Text
, textURL :: Text
}
textArguments :: Parser TextArguments textArguments :: Parser TextArguments
textArguments = TextArguments <$> argument str (metavar "URL") textArguments = TextArguments Text.strip
<$> argument str (metavar "URL")
slackBuilderParser :: ParserInfo SlackBuilderCommand slackBuilderParser :: ParserInfo SlackBuilderCommand
slackBuilderParser = info slackBuilderCommand fullDesc slackBuilderParser = info slackBuilderCommand fullDesc

View File

@ -107,11 +107,11 @@ latestPackagist PackagistArguments{..} = do
>>= fmap (version . fst) . Vector.uncons >>= fmap (version . fst) . Vector.uncons
latestText :: TextArguments -> SlackBuilderT (Maybe Text) latestText :: TextArguments -> SlackBuilderT (Maybe Text)
latestText (TextArguments textArguments) = do latestText TextArguments{..} = do
uri <- liftIO $ useHttpsURI <$> mkURI textArguments uri <- liftIO $ useHttpsURI <$> mkURI textURL
packagistResponse <- traverse (runReq defaultHttpConfig . go . fst) uri packagistResponse <- traverse (runReq defaultHttpConfig . go . fst) uri
pure $ Text.strip . Text.Encoding.decodeASCII . responseBody pure $ versionPicker . Text.Encoding.decodeUtf8 . responseBody
<$> packagistResponse <$> packagistResponse
where where
go uri = req GET uri NoReqBody bsResponse mempty go uri = req GET uri NoReqBody bsResponse mempty