Show updatable local packages
This commit is contained in:
parent
15cf346c61
commit
e1ece39147
10
src/Main.hs
10
src/Main.hs
@ -35,7 +35,8 @@ import Data.Maybe (mapMaybe)
|
|||||||
import qualified Text.URI as URI
|
import qualified Text.URI as URI
|
||||||
import System.Directory (listDirectory)
|
import System.Directory (listDirectory)
|
||||||
import qualified Data.HashMap.Strict as HashMap
|
import qualified Data.HashMap.Strict as HashMap
|
||||||
import SlackBuilder.Info (readInfoFile)
|
import SlackBuilder.Info (PackageInfo(..), readInfoFile)
|
||||||
|
import Control.Monad (unless)
|
||||||
|
|
||||||
autoUpdatable :: [PackageSettings] -> [PackageDescription]
|
autoUpdatable :: [PackageSettings] -> [PackageDescription]
|
||||||
autoUpdatable = mapMaybe go
|
autoUpdatable = mapMaybe go
|
||||||
@ -108,9 +109,10 @@ installed = do
|
|||||||
<$> liftIO (listDirectory "/var/lib/pkgtools/packages")
|
<$> liftIO (listDirectory "/var/lib/pkgtools/packages")
|
||||||
traverse_ findInfo $ HashMap.intersectionWith (,) database listing
|
traverse_ findInfo $ HashMap.intersectionWith (,) database listing
|
||||||
where
|
where
|
||||||
findInfo (installed'@Package.DataBaseEntry{ name }, fromRepository) = do
|
findInfo (installed'@Package.DataBaseEntry{ name, version }, fromRepository) = do
|
||||||
_ <- readInfoFile fromRepository name
|
packageInfo <- readInfoFile fromRepository name
|
||||||
liftIO $ print installed'
|
unless (version == getField @"version" packageInfo) $ liftIO $ putStrLn $
|
||||||
|
show installed' <> " (available: " <> Text.unpack (getField @"version" packageInfo) <> ")"
|
||||||
createDataBase entry@Package.DataBaseEntry{ name } =
|
createDataBase entry@Package.DataBaseEntry{ name } =
|
||||||
HashMap.insert name entry
|
HashMap.insert name entry
|
||||||
createEntry filename = createEntryFromChunks
|
createEntry filename = createEntryFromChunks
|
||||||
|
@ -14,12 +14,13 @@ import Options.Applicative
|
|||||||
, ParserInfo(..)
|
, ParserInfo(..)
|
||||||
, metavar
|
, metavar
|
||||||
, argument
|
, argument
|
||||||
|
, helper
|
||||||
, str
|
, str
|
||||||
, info
|
, info
|
||||||
, fullDesc
|
, fullDesc
|
||||||
, subparser
|
, subparser
|
||||||
, command
|
, command
|
||||||
, optional
|
, optional, progDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
data SlackBuilderCommand
|
data SlackBuilderCommand
|
||||||
@ -28,15 +29,20 @@ data SlackBuilderCommand
|
|||||||
| InstalledCommand
|
| InstalledCommand
|
||||||
|
|
||||||
slackBuilderParser :: ParserInfo SlackBuilderCommand
|
slackBuilderParser :: ParserInfo SlackBuilderCommand
|
||||||
slackBuilderParser = info slackBuilderCommand fullDesc
|
slackBuilderParser = info (helper <*> slackBuilderCommand) fullDesc
|
||||||
|
|
||||||
slackBuilderCommand :: Parser SlackBuilderCommand
|
slackBuilderCommand :: Parser SlackBuilderCommand
|
||||||
slackBuilderCommand = subparser
|
slackBuilderCommand = subparser
|
||||||
$ command "check" (info checkCommand mempty)
|
$ command "check" checkCommand
|
||||||
<> command "up2date" (info up2DateCommand mempty)
|
<> command "up2date" up2DateCommand
|
||||||
<> command "installed" (info installedCommand mempty)
|
<> command "installed" installedCommand
|
||||||
where
|
where
|
||||||
checkCommand = pure CheckCommand
|
checkCommand = info checkP $ progDesc "Check all configured slackbuilds for updates"
|
||||||
up2DateCommand = Up2DateCommand
|
checkP = pure CheckCommand
|
||||||
|
up2DateP = Up2DateCommand
|
||||||
<$> optional (argument str (metavar "PKGNAM"))
|
<$> optional (argument str (metavar "PKGNAM"))
|
||||||
installedCommand = pure InstalledCommand
|
up2DateCommand = info up2DateP
|
||||||
|
$ progDesc "Update a single or multiple slackbuild in the configured repository"
|
||||||
|
installedCommand = info installedP
|
||||||
|
$ progDesc "Find local packages that can be updated using the configured repository"
|
||||||
|
installedP = pure InstalledCommand
|
||||||
|
Loading…
Reference in New Issue
Block a user