Show updatable local packages
All checks were successful
Build / audit (push) Successful in 8s
Build / test (push) Successful in 14m18s

This commit is contained in:
Eugen Wissner 2024-11-29 21:46:59 +01:00
parent 15cf346c61
commit e1ece39147
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
2 changed files with 20 additions and 12 deletions

View File

@ -35,7 +35,8 @@ import Data.Maybe (mapMaybe)
import qualified Text.URI as URI
import System.Directory (listDirectory)
import qualified Data.HashMap.Strict as HashMap
import SlackBuilder.Info (readInfoFile)
import SlackBuilder.Info (PackageInfo(..), readInfoFile)
import Control.Monad (unless)
autoUpdatable :: [PackageSettings] -> [PackageDescription]
autoUpdatable = mapMaybe go
@ -108,9 +109,10 @@ installed = do
<$> liftIO (listDirectory "/var/lib/pkgtools/packages")
traverse_ findInfo $ HashMap.intersectionWith (,) database listing
where
findInfo (installed'@Package.DataBaseEntry{ name }, fromRepository) = do
_ <- readInfoFile fromRepository name
liftIO $ print installed'
findInfo (installed'@Package.DataBaseEntry{ name, version }, fromRepository) = do
packageInfo <- readInfoFile fromRepository name
unless (version == getField @"version" packageInfo) $ liftIO $ putStrLn $
show installed' <> " (available: " <> Text.unpack (getField @"version" packageInfo) <> ")"
createDataBase entry@Package.DataBaseEntry{ name } =
HashMap.insert name entry
createEntry filename = createEntryFromChunks

View File

@ -14,12 +14,13 @@ import Options.Applicative
, ParserInfo(..)
, metavar
, argument
, helper
, str
, info
, fullDesc
, subparser
, command
, optional
, optional, progDesc
)
data SlackBuilderCommand
@ -28,15 +29,20 @@ data SlackBuilderCommand
| InstalledCommand
slackBuilderParser :: ParserInfo SlackBuilderCommand
slackBuilderParser = info slackBuilderCommand fullDesc
slackBuilderParser = info (helper <*> slackBuilderCommand) fullDesc
slackBuilderCommand :: Parser SlackBuilderCommand
slackBuilderCommand = subparser
$ command "check" (info checkCommand mempty)
<> command "up2date" (info up2DateCommand mempty)
<> command "installed" (info installedCommand mempty)
$ command "check" checkCommand
<> command "up2date" up2DateCommand
<> command "installed" installedCommand
where
checkCommand = pure CheckCommand
up2DateCommand = Up2DateCommand
checkCommand = info checkP $ progDesc "Check all configured slackbuilds for updates"
checkP = pure CheckCommand
up2DateP = Up2DateCommand
<$> 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