From 3a6d17952b247682f1cb794ef27b26c9b007f00d Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 20 Oct 2023 15:53:48 +0200 Subject: [PATCH] Allow looking on the text page for the latest version --- Rakefile | 21 --------------------- app/Main.hs | 21 +++++++++++++++++++++ app/SlackBuilder/CommandLine.hs | 11 +++++++---- app/SlackBuilder/Updater.hs | 6 +++--- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/Rakefile b/Rakefile index 9cf1c36..45a6821 100644 --- a/Rakefile +++ b/Rakefile @@ -43,27 +43,6 @@ task :hhvm, [:version] do |_, arguments| update_slackbuild_version 'development/hhvm', package.version 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 = { 'dmd' => [SlackBuilder::LatestText.new('https://downloads.dlang.org/releases/LATEST')] }.freeze diff --git a/app/Main.hs b/app/Main.hs index 99be344..27ae118 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -2,6 +2,8 @@ module Main ( main ) where +import Data.Char (isNumber) +import Control.Applicative (Applicative(liftA2)) import Data.List.NonEmpty (NonEmpty(..)) import qualified Data.List.NonEmpty as NonEmpty import Control.Monad.IO.Class (MonadIO(..)) @@ -147,6 +149,25 @@ autoUpdatable = , name = "rdiff-backup" , 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 () diff --git a/app/SlackBuilder/CommandLine.hs b/app/SlackBuilder/CommandLine.hs index 1375b6e..53a6bfb 100644 --- a/app/SlackBuilder/CommandLine.hs +++ b/app/SlackBuilder/CommandLine.hs @@ -7,6 +7,7 @@ module SlackBuilder.CommandLine ) where import Data.Text (Text) +import qualified Data.Text as Text import Options.Applicative ( Parser , ParserInfo(..) @@ -29,7 +30,6 @@ data SlackBuilderCommand | CloneCommand Text Text Text | DownloadAndDeployCommand Text Text | Up2DateCommand - deriving (Eq, Show) data PackagistArguments = PackagistArguments { vendor :: Text @@ -42,11 +42,14 @@ data GhArguments = GhArguments , transform :: Maybe Text } deriving (Eq, Show) -newtype TextArguments = TextArguments Text - deriving (Eq, Show) +data TextArguments = TextArguments + { versionPicker :: Text -> Text + , textURL :: Text + } textArguments :: Parser TextArguments -textArguments = TextArguments <$> argument str (metavar "URL") +textArguments = TextArguments Text.strip + <$> argument str (metavar "URL") slackBuilderParser :: ParserInfo SlackBuilderCommand slackBuilderParser = info slackBuilderCommand fullDesc diff --git a/app/SlackBuilder/Updater.hs b/app/SlackBuilder/Updater.hs index 864e466..1ebf7fe 100644 --- a/app/SlackBuilder/Updater.hs +++ b/app/SlackBuilder/Updater.hs @@ -107,11 +107,11 @@ latestPackagist PackagistArguments{..} = do >>= fmap (version . fst) . Vector.uncons latestText :: TextArguments -> SlackBuilderT (Maybe Text) -latestText (TextArguments textArguments) = do - uri <- liftIO $ useHttpsURI <$> mkURI textArguments +latestText TextArguments{..} = do + uri <- liftIO $ useHttpsURI <$> mkURI textURL packagistResponse <- traverse (runReq defaultHttpConfig . go . fst) uri - pure $ Text.strip . Text.Encoding.decodeASCII . responseBody + pure $ versionPicker . Text.Encoding.decodeUtf8 . responseBody <$> packagistResponse where go uri = req GET uri NoReqBody bsResponse mempty