rpmbuild-order 0.4.9 → 0.4.10
raw patch · 6 files changed
+81/−49 lines, 6 filesdep ~directoryPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: directory
API changes (from Hackage documentation)
+ Distribution.RPM.Build.Graph: Combine :: Components
+ Distribution.RPM.Build.Graph: Connected :: Components
+ Distribution.RPM.Build.Graph: Parallel :: Components
+ Distribution.RPM.Build.Graph: Separate :: Components
+ Distribution.RPM.Build.Graph: data Components
+ Distribution.RPM.Build.Graph: depsGraphDeps :: Bool -> [String] -> Bool -> [String] -> [String] -> Bool -> Maybe FilePath -> [FilePath] -> [FilePath] -> IO PackageGraph
+ Distribution.RPM.Build.Graph: topsortGraph :: Components -> PackageGraph -> [[String]]
Files
- ChangeLog.md +6/−1
- README.md +1/−1
- rpmbuild-order.cabal +3/−3
- src/Distribution/RPM/Build/Graph.hs +56/−29
- src/Distribution/RPM/Build/Order.hs +7/−15
- test/Spec.hs +8/−0
ChangeLog.md view
@@ -1,4 +1,9 @@-# 0.4.9 (2022-08-XX)+# 0.4.10 (2022-10-28)+- Graph: add depsGraphDeps which takes a list of possible deps+- Graph: add topsortGraph (factored out of sortGraph)+- tests: add testcase for deps command++# 0.4.9 (2022-08-25) - Graph rpmspecDynBuildRequires: error if no srpm generated - Order: add depsPackages and factor out depsGraph to Graph
README.md view
@@ -13,7 +13,7 @@ ``` $ rpmbuild-order --version-0.4.9+0.4.10 $ rpmbuild-order --help Order packages by build dependencies
rpmbuild-order.cabal view
@@ -1,5 +1,5 @@ Name: rpmbuild-order-Version: 0.4.9+Version: 0.4.10 License: BSD3 License-File: LICENSE Author: Jens Petersen <petersen@redhat.com>,@@ -43,7 +43,6 @@ Executable rpmbuild-order Build-Depends: base < 5,- directory, extra, fgl, optparse-applicative,@@ -72,7 +71,7 @@ Distribution.RPM.Build.Order Build-Depends: base < 5, case-insensitive,- directory,+ directory >= 1.2.5, extra >= 1.6.4, filepath, fgl >= 5.5.4,@@ -104,6 +103,7 @@ ghc-options: -Wall build-depends: base >= 4 && < 5+ , directory , extra , hspec >= 1.3 , rpmbuild-order
src/Distribution/RPM/Build/Graph.hs view
@@ -32,11 +32,14 @@ separatePackages, printGraph, renderGraph,- depsGraph+ depsGraph,+ depsGraphDeps,+ Components (..),+ topsortGraph, ) where import qualified Data.CaseInsensitive as CI-import Data.Graph.Inductive.Query.DFS (scc, xdfsWith)+import Data.Graph.Inductive.Query.DFS (components, scc, topsort', xdfsWith) import Data.Graph.Inductive.Query.SP (sp) import Data.Graph.Inductive.PatriciaTree (Gr) import qualified Data.Graph.Inductive.Graph as G@@ -51,23 +54,12 @@ import SimpleCmd import System.Directory (doesDirectoryExist, doesFileExist, getCurrentDirectory, withCurrentDirectory,-#if MIN_VERSION_directory(1,2,5) listDirectory-#else- getDirectoryContents-#endif ) import System.Exit (exitFailure) import System.FilePath import System.IO.Extra (withTempDir) -#if !MIN_VERSION_directory(1,2,5)-listDirectory :: FilePath -> IO [FilePath]-listDirectory path =- filter f <$> getDirectoryContents path- where f filename = filename /= "." && filename /= ".."-#endif- data SourcePackage = SourcePackage { packagePath :: FilePath,@@ -303,18 +295,6 @@ then Nothing else error' $ f ++ " not found" -#if !MIN_VERSION_simple_cmd(0,2,4)- filesWithExtension :: FilePath -> String -> IO [FilePath]- filesWithExtension dir ext =- filter (ext `isExtensionOf`) <$> listDirectory dir--#if !MIN_VERSION_filepath(1,4,2)- isExtensionOf :: String -> FilePath -> Bool- isExtensionOf ext@('.':_) = isSuffixOf ext . takeExtensions- isExtensionOf ext = isSuffixOf ('.':ext) . takeExtensions-#endif-#endif- extractMetadata :: FilePath -> ([String],[String]) -> [String] -> ([String],[String]) extractMetadata _ acc [] = acc extractMetadata pkg acc@(provs,brs) (l:ls) =@@ -522,10 +502,57 @@ -> Maybe FilePath -- ^ subdir for packages -> [FilePath] -- ^ list of package paths -> IO PackageGraph -- ^ dependency graph of the packages-depsGraph rev rpmopts verbose excludedPkgs ignoredBRs lenient mdir pkgs = do+depsGraph rev rpmopts verbose excludedPkgs ignoredBRs lenient mdir pkgs =+ listDirectory "." >>=+ depsGraphDeps rev rpmopts verbose excludedPkgs ignoredBRs lenient mdir pkgs++-- | Given a list of one or more packages and a list of potential dependencies,+-- return a package dependency graph+--+-- @since 0.4.10+depsGraphDeps :: Bool -- ^ whether to look for reverse dependencies+ -> [String] -- ^ rpm options+ -> Bool -- ^ verbose output+ -> [String] -- ^ packages to exclude+ -> [String] -- ^ buildrequires to ignore+ -> Bool -- ^ allow rpmspec failures+ -> Maybe FilePath -- ^ subdir for packages+ -> [FilePath] -- ^ list of package paths+ -> [FilePath] -- ^ list of potential dependency paths+ -> IO PackageGraph -- ^ dependency graph of the packages+depsGraphDeps rev rpmopts verbose excludedPkgs ignoredBRs lenient mdir pkgs deps = do unlessM (and <$> mapM doesDirectoryExist pkgs) $ errorWithoutStackTrace "Please use package directory paths"- listDirectory "." >>=- -- filter out dotfiles- createGraph3 ignoredBRs rpmopts verbose lenient (not rev) mdir . filter ((/= '.') . head) . filter (`notElem` excludedPkgs) >>=+ -- filter out dotfiles+ createGraph3 ignoredBRs rpmopts verbose lenient (not rev) mdir (filter ((/= '.') . head) (filter (`notElem` excludedPkgs) deps)) >>= createGraph2 rpmopts verbose lenient True mdir . dependencyNodes pkgs++-- | Used to control the output from sortGraph+data Components = Parallel -- ^ separate independent stacks+ | Combine -- ^ combine indepdendent stacks together+ | Connected -- ^ only stack of packages+ | Separate -- ^ only independent packages in the package set++-- | topological sort packages from a PackageGraph arranged by Components+--+-- @since 0.4.10+topsortGraph :: Components -> PackageGraph -> [[String]]+topsortGraph opt graph =+ case opt of+ Parallel -> map (topsort' . subgraph' graph) (components graph)+ Combine -> pure $ topsort' graph+ Connected ->+ map (topsort' . subgraph' graph) $ filter ((>1) . length) (components graph)+ Separate -> pure $ separatePackages graph++#if !MIN_VERSION_simple_cmd(0,2,4)+filesWithExtension :: FilePath -> String -> IO [FilePath]+filesWithExtension dir ext =+ filter (ext `isExtensionOf`) <$> listDirectory dir++#if !MIN_VERSION_filepath(1,4,2)+isExtensionOf :: String -> FilePath -> Bool+isExtensionOf ext@('.':_) = isSuffixOf ext . takeExtensions+isExtensionOf ext = isSuffixOf ('.':ext) . takeExtensions+#endif+#endif
src/Distribution/RPM/Build/Order.hs view
@@ -30,7 +30,7 @@ #if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>)) #endif-import Data.List (intercalate)+import Data.List (intersperse) import Data.Graph.Inductive.Query.DFS (topsort', components) import Distribution.RPM.Build.Graph@@ -70,24 +70,16 @@ graph <- createGraph pkgs return $ separatePackages graph --- | Used to control the output from sortGraph-data Components = Parallel -- ^ separate independent stacks- | Combine -- ^ combine indepdendent stacks together- | Connected -- ^ only stack of packages- | Separate -- ^ only independent packages in the package set- -- | output sorted packages from a PackageGraph arrange by Components sortGraph :: Components -> PackageGraph -> IO () sortGraph opt graph =- -- FIXME output list(s) instead- putStrLn $+ mapM_ (putStrLn . unwords) $ case opt of- Parallel ->- intercalate "\n\n" $ map (unwords . topsort' . subgraph' graph) (components graph)- Combine -> (unwords . topsort') graph- Connected ->- intercalate "\n\n" $ map (unwords . topsort' . subgraph' graph) $ filter ((>1) . length) (components graph)- Separate -> unlines $ separatePackages graph+ Parallel -> intersperse ["\n"]+ Combine -> id+ Connected -> intersperse ["\n"]+ Separate -> id+ $ topsortGraph opt graph -- | Given a list of one or more packages, look for dependencies -- in neighboring packages and output them in a topological order
test/Spec.hs view
@@ -4,6 +4,7 @@ --import Distribution.RPM.Build.Graph import Distribution.RPM.Build.Order import SimpleCmd+import System.Directory (withCurrentDirectory) import System.Posix.Files main :: IO ()@@ -79,6 +80,13 @@ it "sort A B" $ cmd "rpmbuild-order" ["sort", pkg "A", pkg "B"] >>= (`shouldBe` unwords [pkg "B", pkg "A"])++ it "deps A" $+ withCurrentDirectory "test/pkgs" $+ cmd "rpmbuild-order"+ ["deps", "-x", "dynbr", "-x", "1", "-x", "2", "-x", "C", "A"] >>=+ (`shouldBe` unwords ["B", "A"])+ setupSymlinks :: IO () setupSymlinks =