Allow looking on the text page for the latest version
This commit is contained in:
		
							
								
								
									
										21
									
								
								Rakefile
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								app/Main.hs
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								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 ()
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user