Compare commits
3 Commits
5e161c3dad
...
8a69240d88
Author | SHA1 | Date | |
---|---|---|---|
8a69240d88
|
|||
3a6d17952b
|
|||
4105ffa91f
|
57
Rakefile
57
Rakefile
@ -10,7 +10,6 @@ require 'open3'
|
|||||||
require_relative 'config/config'
|
require_relative 'config/config'
|
||||||
require_relative 'lib/package'
|
require_relative 'lib/package'
|
||||||
require_relative 'lib/download'
|
require_relative 'lib/download'
|
||||||
require_relative 'lib/up2date'
|
|
||||||
|
|
||||||
task :dmd, [:version] do |_, arguments|
|
task :dmd, [:version] do |_, arguments|
|
||||||
raise 'Version is not specified.' unless arguments.key? :version
|
raise 'Version is not specified.' unless arguments.key? :version
|
||||||
@ -42,59 +41,3 @@ 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
|
|
||||||
|
|
||||||
task 'rdiff-backup', [:version] do |_, arguments|
|
|
||||||
raise 'Version is not specified.' unless arguments.key? :version
|
|
||||||
|
|
||||||
package = Package.new 'system/rdiff-backup',
|
|
||||||
version: arguments[:version],
|
|
||||||
homepage: 'https://rdiff-backup.net/',
|
|
||||||
requires: ['librsync']
|
|
||||||
|
|
||||||
uri = "https://github.com/rdiff-backup/rdiff-backup/releases/download/v#{arguments[:version]}/rdiff-backup-#{arguments[:version]}.tar.gz"
|
|
||||||
tarball = "system/rdiff-backup/rdiff-backup-#{arguments[:version]}.tar.gz"
|
|
||||||
checksum = SlackBuilder.download_and_deploy URI(uri), tarball
|
|
||||||
download = "https://download.dlackware.com/hosted-sources/rdiff-backup/rdiff-backup-#{arguments[:version]}.tar.gz"
|
|
||||||
|
|
||||||
write_info package, downloads: [Download.new(download, checksum)]
|
|
||||||
update_slackbuild_version 'system/rdiff-backup', arguments[:version]
|
|
||||||
|
|
||||||
commit 'system/rdiff-backup', arguments[:version]
|
|
||||||
end
|
|
||||||
|
|
||||||
AUTO_UPDATABLE = {
|
|
||||||
'rdiff-backup' => [SlackBuilder::GitHub.new('rdiff-backup', 'rdiff-backup', 'rdiff-backup')],
|
|
||||||
'dmd' => [SlackBuilder::LatestText.new('https://downloads.dlang.org/releases/LATEST')]
|
|
||||||
}.freeze
|
|
||||||
|
|
||||||
task :up2date do
|
|
||||||
AUTO_UPDATABLE.each do |key, value|
|
|
||||||
repository, updater = value
|
|
||||||
latest_version = SlackBuilder.check_for_latest key, repository
|
|
||||||
next if latest_version.nil? || updater.nil?
|
|
||||||
|
|
||||||
puts "Would like to update #{key} to #{latest_version} (y/N)? "
|
|
||||||
updater.update latest_version if $stdin.gets.chomp.downcase.start_with? 'y'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
136
app/Main.hs
136
app/Main.hs
@ -2,10 +2,12 @@ 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(..))
|
||||||
import Data.Maybe (fromJust, fromMaybe)
|
import Data.Maybe (fromJust)
|
||||||
import Options.Applicative (execParser)
|
import Options.Applicative (execParser)
|
||||||
import SlackBuilder.CommandLine
|
import SlackBuilder.CommandLine
|
||||||
import SlackBuilder.Config
|
import SlackBuilder.Config
|
||||||
@ -21,9 +23,9 @@ import SlackBuilder.Download
|
|||||||
import SlackBuilder.Package (Package(..))
|
import SlackBuilder.Package (Package(..))
|
||||||
import qualified SlackBuilder.Package as Package
|
import qualified SlackBuilder.Package as Package
|
||||||
import Text.URI (mkURI)
|
import Text.URI (mkURI)
|
||||||
import Data.Foldable (for_)
|
import Data.Foldable (for_, find)
|
||||||
import qualified Text.URI as URI
|
import qualified Text.URI as URI
|
||||||
import System.FilePath ((</>), (<.>), dropExtension, takeBaseName)
|
import System.FilePath ((</>), (<.>), dropExtension, takeBaseName, makeRelative, splitFileName)
|
||||||
import SlackBuilder.Info
|
import SlackBuilder.Info
|
||||||
import Text.Megaparsec (parse, errorBundlePretty)
|
import Text.Megaparsec (parse, errorBundlePretty)
|
||||||
import GHC.Records (HasField(..))
|
import GHC.Records (HasField(..))
|
||||||
@ -35,6 +37,16 @@ import System.Process
|
|||||||
, withCreateProcess
|
, withCreateProcess
|
||||||
, waitForProcess
|
, waitForProcess
|
||||||
)
|
)
|
||||||
|
import System.Console.ANSI
|
||||||
|
( setSGR
|
||||||
|
, SGR(..)
|
||||||
|
, ColorIntensity(..)
|
||||||
|
, Color(..)
|
||||||
|
, ConsoleLayer(..)
|
||||||
|
)
|
||||||
|
import System.Directory (listDirectory, doesDirectoryExist)
|
||||||
|
import Control.Monad (filterM)
|
||||||
|
import Data.List (isPrefixOf, isSuffixOf)
|
||||||
|
|
||||||
autoUpdatable :: [Package]
|
autoUpdatable :: [Package]
|
||||||
autoUpdatable =
|
autoUpdatable =
|
||||||
@ -93,7 +105,8 @@ autoUpdatable =
|
|||||||
, transform = Nothing
|
, transform = Nothing
|
||||||
}
|
}
|
||||||
checkVersion x
|
checkVersion x
|
||||||
| Text.isPrefixOf "php-8.2." x = Text.stripPrefix "php-" x
|
| not $ Text.isInfixOf "RC" x
|
||||||
|
, Text.isPrefixOf "php-8.2." x = Text.stripPrefix "php-" x
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
latest' = latestGitHub ghArguments checkVersion
|
latest' = latestGitHub ghArguments checkVersion
|
||||||
template = Package.DownloadTemplate
|
template = Package.DownloadTemplate
|
||||||
@ -127,12 +140,89 @@ autoUpdatable =
|
|||||||
, name = "kitty"
|
, name = "kitty"
|
||||||
, reupload = Just [RawCommand "go" ["mod", "vendor"]]
|
, reupload = Just [RawCommand "go" ["mod", "vendor"]]
|
||||||
}
|
}
|
||||||
|
, Package
|
||||||
|
{ latest =
|
||||||
|
let ghArguments = GhArguments
|
||||||
|
{ owner = "rdiff-backup"
|
||||||
|
, name = "rdiff-backup"
|
||||||
|
, transform = Nothing
|
||||||
|
}
|
||||||
|
latest' = latestGitHub ghArguments $ Text.stripPrefix "v"
|
||||||
|
template = Package.DownloadTemplate
|
||||||
|
$ Package.StaticPlaceholder "https://github.com/rdiff-backup/rdiff-backup/releases/download/v"
|
||||||
|
:| Package.VersionPlaceholder
|
||||||
|
: Package.StaticPlaceholder "/rdiff-backup-"
|
||||||
|
: Package.VersionPlaceholder
|
||||||
|
: [Package.StaticPlaceholder ".tar.gz"]
|
||||||
|
in Package.Updater latest' template
|
||||||
|
, category = "system"
|
||||||
|
, 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
|
||||||
|
}
|
||||||
|
, Package
|
||||||
|
{ latest =
|
||||||
|
let ghArguments = GhArguments
|
||||||
|
{ owner = "librsync"
|
||||||
|
, name = "librsync"
|
||||||
|
, transform = Nothing
|
||||||
|
}
|
||||||
|
latest' = latestGitHub ghArguments $ Text.stripPrefix "v"
|
||||||
|
template = Package.DownloadTemplate
|
||||||
|
$ Package.StaticPlaceholder "https://github.com/librsync/librsync/archive/v"
|
||||||
|
:| Package.VersionPlaceholder
|
||||||
|
: Package.StaticPlaceholder "/librsync-"
|
||||||
|
: Package.VersionPlaceholder
|
||||||
|
: [Package.StaticPlaceholder ".tar.gz"]
|
||||||
|
in Package.Updater latest' template
|
||||||
|
, category = "libraries"
|
||||||
|
, name = "librsync"
|
||||||
|
, reupload = Just mempty
|
||||||
|
}
|
||||||
|
, Package
|
||||||
|
{ latest =
|
||||||
|
let textArguments = TextArguments
|
||||||
|
{ textURL = "https://downloads.dlang.org/releases/LATEST"
|
||||||
|
, versionPicker = Text.strip
|
||||||
|
}
|
||||||
|
latest' = latestText textArguments
|
||||||
|
template = Package.DownloadTemplate
|
||||||
|
$ Package.StaticPlaceholder "https://downloads.dlang.org/releases/2.x/"
|
||||||
|
:| Package.VersionPlaceholder
|
||||||
|
: Package.StaticPlaceholder "/dmd."
|
||||||
|
: Package.VersionPlaceholder
|
||||||
|
: [Package.StaticPlaceholder ".linux.tar.xz"]
|
||||||
|
in Package.Updater latest' template
|
||||||
|
, category = "development"
|
||||||
|
, name = "dmd"
|
||||||
|
, reupload = Nothing
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
up2Date :: SlackBuilderT ()
|
up2Date :: SlackBuilderT ()
|
||||||
up2Date = for_ autoUpdatable go
|
up2Date = for_ autoUpdatable go
|
||||||
where
|
where
|
||||||
go package = getAndLogLatest package >>= mapM_ (updatePackageIfRequired package)
|
go package = getAndLogLatest package
|
||||||
|
>>= mapM_ (updatePackageIfRequired package)
|
||||||
|
>> liftIO (putStrLn "")
|
||||||
getAndLogLatest Package{ latest = Package.Updater getLatest _, name }
|
getAndLogLatest Package{ latest = Package.Updater getLatest _, name }
|
||||||
= liftIO (putStrLn $ Text.unpack name <> ": Retreiving the latest version.")
|
= liftIO (putStrLn $ Text.unpack name <> ": Retreiving the latest version.")
|
||||||
>> getLatest
|
>> getLatest
|
||||||
@ -146,8 +236,11 @@ updatePackageIfRequired package@Package{..} version = do
|
|||||||
case parse parseInfoFile packagePath infoContents of
|
case parse parseInfoFile packagePath infoContents of
|
||||||
Right parsedInfoFile
|
Right parsedInfoFile
|
||||||
| version == getField @"version" parsedInfoFile ->
|
| version == getField @"version" parsedInfoFile ->
|
||||||
liftIO $ Text.IO.putStrLn
|
liftIO $ do
|
||||||
|
setSGR [SetColor Foreground Dull Green]
|
||||||
|
Text.IO.putStrLn
|
||||||
$ name <> " is up to date (Version " <> version <> ")."
|
$ name <> " is up to date (Version " <> version <> ")."
|
||||||
|
setSGR [Reset]
|
||||||
| otherwise -> updatePackage package parsedInfoFile version
|
| otherwise -> updatePackage package parsedInfoFile version
|
||||||
Left errorBundle -> liftIO $ putStr $ errorBundlePretty errorBundle
|
Left errorBundle -> liftIO $ putStr $ errorBundlePretty errorBundle
|
||||||
|
|
||||||
@ -215,6 +308,17 @@ updatePackage Package{..} info version = do
|
|||||||
, child_group = Nothing
|
, child_group = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findCategory :: FilePath -> IO [FilePath]
|
||||||
|
findCategory currentDirectory = do
|
||||||
|
contents <- liftIO $ listDirectory currentDirectory
|
||||||
|
case find (isSuffixOf ".info") contents of
|
||||||
|
Just _ -> pure [currentDirectory]
|
||||||
|
Nothing -> do
|
||||||
|
let contents' = (currentDirectory </>) <$> filter (not . isPrefixOf ".") contents
|
||||||
|
directories <- filterM doesDirectoryExist contents'
|
||||||
|
subCategories <- traverse findCategory directories
|
||||||
|
pure $ concat subCategories
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
programCommand <- execParser slackBuilderParser
|
programCommand <- execParser slackBuilderParser
|
||||||
@ -223,12 +327,14 @@ main = do
|
|||||||
$ runSlackBuilderT
|
$ runSlackBuilderT
|
||||||
$ executeCommand programCommand
|
$ executeCommand programCommand
|
||||||
|
|
||||||
Text.IO.putStrLn $ fromMaybe "" latestVersion
|
maybe (pure ()) Text.IO.putStrLn latestVersion
|
||||||
where
|
where
|
||||||
executeCommand = \case
|
executeCommand = \case
|
||||||
TextCommand textArguments -> latestText textArguments
|
CategoryCommand _packageName -> do
|
||||||
GhCommand ghArguments@GhArguments{ transform }
|
repository' <- SlackBuilderT $ asks repository
|
||||||
-> latestGitHub ghArguments $ chooseTransformFunction transform
|
categories <- liftIO $ findCategory repository'
|
||||||
|
liftIO $ print $ splitFileName . makeRelative repository' <$> categories
|
||||||
|
pure Nothing
|
||||||
SlackBuildCommand packagePath version ->
|
SlackBuildCommand packagePath version ->
|
||||||
updateSlackBuildVersion packagePath version >> pure Nothing
|
updateSlackBuildVersion packagePath version >> pure Nothing
|
||||||
CommitCommand packagePath version ->
|
CommitCommand packagePath version ->
|
||||||
@ -246,13 +352,3 @@ main = do
|
|||||||
DownloadAndDeployCommand uri' tarball -> fmap (Text.pack . show)
|
DownloadAndDeployCommand uri' tarball -> fmap (Text.pack . show)
|
||||||
<$> downloadAndDeploy uri' tarball
|
<$> downloadAndDeploy uri' tarball
|
||||||
Up2DateCommand -> up2Date >> pure Nothing
|
Up2DateCommand -> up2Date >> pure Nothing
|
||||||
chooseTransformFunction (Just "php") = phpTransform
|
|
||||||
chooseTransformFunction (Just "rdiff-backup") = Text.stripPrefix "v"
|
|
||||||
chooseTransformFunction _ = stripPrefix "v"
|
|
||||||
stripPrefix prefix string = Just
|
|
||||||
$ fromMaybe string
|
|
||||||
$ Text.stripPrefix prefix string
|
|
||||||
phpTransform version
|
|
||||||
| (majorPrefix, _patchVersion) <- Text.breakOnEnd "." version
|
|
||||||
, majorPrefix == "php-8.2." = Just $ Text.drop (Text.length "php-") version
|
|
||||||
| otherwise = Nothing
|
|
||||||
|
@ -16,12 +16,11 @@ import Options.Applicative
|
|||||||
, info
|
, info
|
||||||
, fullDesc
|
, fullDesc
|
||||||
, subparser
|
, subparser
|
||||||
, command, optional
|
, command,
|
||||||
)
|
)
|
||||||
|
|
||||||
data SlackBuilderCommand
|
data SlackBuilderCommand
|
||||||
= TextCommand TextArguments
|
= CategoryCommand Text
|
||||||
| GhCommand GhArguments
|
|
||||||
| SlackBuildCommand Text Text
|
| SlackBuildCommand Text Text
|
||||||
| CommitCommand Text Text
|
| CommitCommand Text Text
|
||||||
| ExistsCommand Text
|
| ExistsCommand Text
|
||||||
@ -30,7 +29,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
|
||||||
@ -43,25 +41,17 @@ 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 = TextArguments <$> argument str (metavar "URL")
|
|
||||||
|
|
||||||
ghArguments :: Parser GhArguments
|
|
||||||
ghArguments = GhArguments
|
|
||||||
<$> argument str (metavar "OWNER")
|
|
||||||
<*> argument str (metavar "NAME")
|
|
||||||
<*> optional (argument str (metavar "TRANSFORM"))
|
|
||||||
|
|
||||||
slackBuilderParser :: ParserInfo SlackBuilderCommand
|
slackBuilderParser :: ParserInfo SlackBuilderCommand
|
||||||
slackBuilderParser = info slackBuilderCommand fullDesc
|
slackBuilderParser = info slackBuilderCommand fullDesc
|
||||||
|
|
||||||
slackBuilderCommand :: Parser SlackBuilderCommand
|
slackBuilderCommand :: Parser SlackBuilderCommand
|
||||||
slackBuilderCommand = subparser
|
slackBuilderCommand = subparser
|
||||||
$ command "text" (info (TextCommand <$> textArguments) mempty)
|
$ command "category" (info categoryCommand mempty)
|
||||||
<> command "github" (info (GhCommand <$> ghArguments) mempty)
|
|
||||||
<> command "slackbuild" (info slackBuildCommand mempty)
|
<> command "slackbuild" (info slackBuildCommand mempty)
|
||||||
<> command "commit" (info commitCommand mempty)
|
<> command "commit" (info commitCommand mempty)
|
||||||
<> command "exists" (info existsCommand mempty)
|
<> command "exists" (info existsCommand mempty)
|
||||||
@ -71,6 +61,8 @@ slackBuilderCommand = subparser
|
|||||||
<> command "deploy" (info deployCommand mempty)
|
<> command "deploy" (info deployCommand mempty)
|
||||||
<> command "up2date" (info up2DateCommand mempty)
|
<> command "up2date" (info up2DateCommand mempty)
|
||||||
where
|
where
|
||||||
|
categoryCommand = CategoryCommand
|
||||||
|
<$> argument str (metavar "PKGNAM")
|
||||||
slackBuildCommand = SlackBuildCommand
|
slackBuildCommand = SlackBuildCommand
|
||||||
<$> argument str (metavar "PATH")
|
<$> argument str (metavar "PATH")
|
||||||
<*> argument str (metavar "VERSION")
|
<*> argument str (metavar "VERSION")
|
||||||
|
@ -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
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'net/http'
|
|
||||||
require 'json'
|
|
||||||
require_relative '../config/config'
|
|
||||||
require 'term/ansicolor'
|
|
||||||
|
|
||||||
module SlackBuilder
|
|
||||||
extend Term::ANSIColor
|
|
||||||
|
|
||||||
# Remote repository for a single package.
|
|
||||||
class Repository
|
|
||||||
# Request the latest tag in the given repository.
|
|
||||||
def latest
|
|
||||||
raise NotImplementedError
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Reads the list fo tags from the GitHub API.
|
|
||||||
class GitHub < Repository
|
|
||||||
def initialize(owner, name, version_transform = nil)
|
|
||||||
super()
|
|
||||||
|
|
||||||
@owner = owner
|
|
||||||
@name = name
|
|
||||||
@version_transform = version_transform
|
|
||||||
end
|
|
||||||
|
|
||||||
def latest
|
|
||||||
`./bin/slackbuilder github #{@owner} #{@name} #{@version_transform}`.strip
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Reads a remote LATEST file.
|
|
||||||
class LatestText < Repository
|
|
||||||
def initialize(latest_url)
|
|
||||||
super()
|
|
||||||
|
|
||||||
@latest_url = latest_url
|
|
||||||
end
|
|
||||||
|
|
||||||
def latest
|
|
||||||
`./bin/slackbuilder text #{@latest_url}`.strip
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module_function
|
|
||||||
|
|
||||||
# Checks if there is a new version for the package and returns the latest
|
|
||||||
# version if an update is available, otherwise returns nil.
|
|
||||||
def check_for_latest(package_name, repository)
|
|
||||||
package = find_package_info package_name
|
|
||||||
latest_version = repository.latest
|
|
||||||
|
|
||||||
if package.version == latest_version
|
|
||||||
puts green "#{package_name} is up to date (Version #{package.version})."
|
|
||||||
nil
|
|
||||||
else
|
|
||||||
puts red "#{package_name}: Current version is #{package.version}, #{latest_version} is available."
|
|
||||||
latest_version
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private_class_method def find_package_info(package_name)
|
|
||||||
package_path = Pathname.new Dir.glob("#{CONFIG[:repository]}/*/#{package_name}").first
|
|
||||||
package_category = package_path.dirname.basename.to_s
|
|
||||||
Package.parse("#{package_category}/#{package_name}", File.read("#{package_path}/#{package_name}.info"))
|
|
||||||
end
|
|
||||||
end
|
|
@ -20,6 +20,7 @@ common dependencies
|
|||||||
base ^>= 4.16.4.0,
|
base ^>= 4.16.4.0,
|
||||||
bytestring ^>= 0.11.0,
|
bytestring ^>= 0.11.0,
|
||||||
cryptonite >= 0.30,
|
cryptonite >= 0.30,
|
||||||
|
directory ^>= 1.3.8,
|
||||||
filepath ^>= 1.4.2,
|
filepath ^>= 1.4.2,
|
||||||
megaparsec ^>= 9.5,
|
megaparsec ^>= 9.5,
|
||||||
modern-uri ^>= 0.3.6,
|
modern-uri ^>= 0.3.6,
|
||||||
@ -67,6 +68,7 @@ executable slackbuilder
|
|||||||
SlackBuilder.Updater
|
SlackBuilder.Updater
|
||||||
build-depends:
|
build-depends:
|
||||||
aeson ^>= 2.2.0,
|
aeson ^>= 2.2.0,
|
||||||
|
ansi-terminal ^>= 1.0,
|
||||||
conduit ^>= 1.3.5,
|
conduit ^>= 1.3.5,
|
||||||
http-client ^>= 0.7,
|
http-client ^>= 0.7,
|
||||||
optparse-applicative ^>= 0.18.1,
|
optparse-applicative ^>= 0.18.1,
|
||||||
|
Reference in New Issue
Block a user