packages feed

aura 3.1.8 → 3.1.9

raw patch · 7 files changed

+80/−20 lines, 7 filesdep ~aurPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aur

API changes (from Hackage documentation)

+ Aura.Cache: AndUninstalled :: CleanMode
+ Aura.Cache: Quantity :: CleanMode
+ Aura.Cache: data CleanMode
+ Aura.Cache: instance GHC.Classes.Eq Aura.Cache.CleanMode
+ Aura.Cache: instance GHC.Show.Show Aura.Cache.CleanMode

Files

CHANGELOG.md view
@@ -1,5 +1,27 @@ # Aura Changelog +## 3.1.9 (2020-09-11)++#### Added++- Pass `-u` to `-Cc` to save N installed packages, and remove all uninstalled ones. Example:++```+> sudo aura -Cc 3 -u+aura >>= The cache contains 1706 packages, consuming 7324 megabytes.+aura >>= 3 versions of each installed package will be kept.+aura >>= The rest will be deleted. Okay? [Y/n] n+```++Otherwise, the usual behaviour of `-Cc` is to save N packages in the cache,+regardless of if they are installed or not.++#### Fixed++- AUR packages with `+` in their name (e.g. `libc++`) can be searched and installed. [#630]++[#630]: https://github.com/fosskers/aura/issues/630+ ## 3.1.8 (2020-08-23)  #### Changed
aura.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.2 name:               aura-version:            3.1.8+version:            3.1.9 synopsis:           A secure package manager for Arch Linux and the AUR. description:   Aura is a package manager for Arch Linux. It connects to both the@@ -43,7 +43,7 @@     , base        >=4.12   && <5     , bytestring  ^>=0.10     , containers  ^>=0.6-    , megaparsec  >=7      && <9+    , megaparsec  >=7      && <10     , rio         ^>=0.1.17     , text        ^>=1.2     , versions    ^>=3.5.4@@ -51,7 +51,7 @@ common libexec   build-depends:     , aeson                        >=1.2 && <1.6-    , aur                          ^>=7.0+    , aur                          ^>=7.0.4     , http-client                  >=0.5 && <0.8     , prettyprinter                >=1.2 && <1.8     , prettyprinter-ansi-terminal  ^>=1.1
exec/Aura/Commands/C.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE BangPatterns       #-}+{-# LANGUAGE LambdaCase         #-} {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE TypeApplications   #-} @@ -29,6 +29,8 @@ import           Aura.State import           Aura.Types import           Aura.Utils (nes)+import           Control.Monad.Trans.Maybe+import           Control.Scheduler (Comp(..), traverseConcurrently) import           RIO import           RIO.Directory import qualified RIO.List as L@@ -111,8 +113,8 @@  -- | Keeps a certain number of package files in the cache according to -- a number provided by the user. The rest are deleted.-cleanCache :: Word -> RIO Env ()-cleanCache toSave+cleanCache :: Word -> CleanMode -> RIO Env ()+cleanCache toSave mode   | toSave == 0 = do       ss <- asks settings       warn ss cleanCache_2@@ -125,9 +127,10 @@       beforeBytes <- liftIO $ cacheSize beforeCache       notify ss $ cleanCache_7 (fromIntegral $ M.size c) beforeBytes       -- Proceed with user confirmation ---      warn ss $ cleanCache_3 toSave+      let msg = bool cleanCache_9 cleanCache_3 $ mode == Quantity+      warn ss $ msg toSave       withOkay ss cleanCache_4 cleanCache_5 $ do-        clean toSave beforeCache+        clean toSave mode beforeCache         afterCache <- liftIO $ cacheContents cachePath         afterBytes <- liftIO $ cacheSize afterCache         notify ss $ cleanCache_8 (beforeBytes - afterBytes)@@ -138,14 +141,38 @@   bytes <- foldl' (+) 0 <$> traverse (getFileSize . ppPath) (M.elems cache)   pure . floor @Double $ fromIntegral bytes / 1_048_576  -- 1024 * 1024 -clean :: Word -> Cache -> RIO Env ()-clean toSave (Cache cache) = do+clean :: Word -> CleanMode -> Cache -> RIO Env ()+clean toSave mode (Cache cache) = do   ss <- asks settings+  keep <- toKeep   notify ss cleanCache_6-  let !files    = M.elems cache-      grouped   = take (fromIntegral toSave) . reverse <$> groupByName files-      toRemove  = files L.\\ fold grouped-  liftIO $ traverse_ (removeFile . ppPath) toRemove+  liftIO . traverse_ (removeFile . ppPath) $ toRemove keep+  where+    files :: [PackagePath]+    files = M.elems cache++    toKeep :: RIO Env [PackagePath]+    toKeep = case mode of+      Quantity       -> pure $ grouped >>= recent+      AndUninstalled -> do+        env <- asks (envOf . settings)+        fold . catMaybes <$> liftIO (traverseConcurrently Par' (f env) grouped)++    f :: Environment -> [PackagePath] -> IO (Maybe [PackagePath])+    f _ []       = pure Nothing+    f e ps@(a:_) = runMaybeT $ do+      pn <- MaybeT . pure $ simplepkg a+      void . MaybeT . isInstalled e $ spName pn+      pure $ recent ps++    recent :: [PackagePath] -> [PackagePath]+    recent = take (fromIntegral toSave) . reverse++    grouped :: [[PackagePath]]+    grouped = groupByName files++    toRemove :: [PackagePath] -> [PackagePath]+    toRemove keep = files L.\\ keep  -- | Only package files with a version not in any PkgState will be -- removed.
exec/Aura/Flags.hs view
@@ -7,9 +7,9 @@   , AurOp(..), BackupOp(..), CacheOp(..), LogOp(..), OrphanOp(..), AnalysisOp(..)   ) where -import           Aura.Cache (defaultPackageCache)+import           Aura.Cache (CleanMode(..), defaultPackageCache) import           Aura.Pacman (defaultLogFile, pacmanConfFile)-import           Aura.Settings+import           Aura.Settings hiding (switch) import           Aura.Types import           Aura.Utils (Traversal') import           Options.Applicative@@ -270,7 +270,7 @@  data CacheOp   = CacheBackup !FilePath-  | CacheClean  !Word+  | CacheClean  !Word !CleanMode   | CacheCleanNotSaved   | CacheSearch !Text   deriving (Show)@@ -341,7 +341,9 @@   where bigC = flag' () (long "downgrade" <> short 'C' <> help "Interact with the package cache.")         mods = backup <|> clean <|> clean' <|> search         backup = CacheBackup <$> option (eitherReader absFilePath) (long "backup" <> short 'b' <> metavar "PATH" <> help "Backup the package cache to a given directory." <> hidden)-        clean  = CacheClean  <$> option auto (long "clean" <> short 'c' <> metavar "N" <> help "Save the most recent N versions of a package in the cache, deleting the rest." <> hidden)+        clean  = CacheClean+          <$> option auto (long "clean" <> short 'c' <> metavar "N" <> help "Save the most recent N versions of a package in the cache, deleting the rest." <> hidden)+          <*> flag Quantity AndUninstalled (long "uninstalled" <> short 'u' <> help "Add to -c. Clears out any uninstalled packages from the cache.")         clean' = flag' CacheCleanNotSaved (long "notsaved" <> help "Clean out any cached package files which doesn't appear in any saved state." <> hidden)         search = CacheSearch <$> strOption (long "search" <> short 's' <> metavar "STRING" <> help "Search the package cache via a search string." <> hidden) 
exec/aura.hs view
@@ -128,7 +128,7 @@     Right (Cache o) -> case o of       Right ps                -> sudo $ C.downgradePackages ps       Left (CacheSearch s)    -> C.searchCache s-      Left (CacheClean n)     -> sudo $ C.cleanCache n+      Left (CacheClean n u)   -> sudo $ C.cleanCache n u       Left CacheCleanNotSaved -> sudo C.cleanNotSaved       Left (CacheBackup pth)  -> sudo $ C.backupCache pth     Right (Log o) -> case o of@@ -144,7 +144,7 @@       Just (AnalysisFile fp) -> P.exploitsFromFile fp       Just (AnalysisDir fp)  -> P.exploitsFromFile $ fp </> "PKGBUILD"       Just AnalysisAudit     -> P.audit-    Right Version   -> liftIO $ (versionInfo env) >>= animateVersionMsg ss auraVersion+    Right Version   -> liftIO $ versionInfo env >>= animateVersionMsg ss auraVersion     Right Languages -> displayOutputLanguages     Right ViewConf  -> viewConfFile 
lib/Aura/Cache.hs view
@@ -12,6 +12,7 @@   ( -- * Types     Cache(..)   , cacheContents+  , CleanMode(..)     -- * Misc.   , defaultPackageCache   , cacheMatches@@ -31,6 +32,10 @@  -- | Every package in the current cache, paired with its original filename. newtype Cache = Cache { _cache :: Map SimplePkg PackagePath }++-- | For manipulating the specifics of the cache cleaning process.+data CleanMode = Quantity | AndUninstalled+  deriving (Eq, Show)  -- | The default location of the package cache: \/var\/cache\/pacman\/pkg\/ defaultPackageCache :: FilePath
lib/Aura/Languages.hs view
@@ -1188,6 +1188,10 @@    Spanish     -> bytes <> " megabytes liberados."    _           -> bytes <> " megabytes freed." +cleanCache_9 :: Word -> Language -> Doc AnsiStyle+cleanCache_9 (bt . tshow -> w) = \case+  _ -> w <> " versions of each installed package will be kept."+ -- NEEDS TRANSLATION cleanNotSaved_1 :: Language -> Doc AnsiStyle cleanNotSaved_1 = \case