-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Order RPM packages by dependencies
--   
--   The rpmbuild-order tool orders RPM packages by dependencies, so that
--   they can be built in the correct order. It does this by reading RPM
--   package spec files and then topologically sorts them according to
--   their dependencies. The code originated from cabal-sort by Henning
--   Thielemann. It can also output the ordered dependencies or reverse
--   depends for one or more packages, provided all the packages are
--   checked out in neighboring directories. This is also useful to see
--   what packages are affected when a low-level package changes. It also
--   have support for setting RPM options for bcond etc, which can affect
--   dependencies. Since version 0.4 there is a library too.
@package rpmbuild-order
@version 0.4.2.1


-- | This module provides simple dependency graph making for rpm packages:
--   
--   <pre>
--   import <a>Distribution.RPM.Build.Graph</a>
--   
--   graph &lt;- <a>createGraph</a> ["pkg1", "pkg2", "../pkg3"]
--   </pre>
module Distribution.RPM.Build.Graph

-- | alias for a package dependency graph
type PackageGraph = Gr FilePath ()

-- | Create a directed dependency graph for a set of packages This is a
--   convenience wrapper for createGraph' False False True Nothing
createGraph :: [FilePath] -> IO PackageGraph

-- | Create a directed dependency graph for a set of packages setting rpm
--   options This is a convenience wrapper for <tt>createGraph'' rpmopts
--   False False True Nothing</tt>
createGraphRpmOpts :: [String] -> [FilePath] -> IO PackageGraph

-- | Create a directed dependency graph for a set of packages For the
--   (createGraph default) reverse deps graph the arrows point back from
--   the dependencies to the dependendent (parent/consumer) packages, and
--   this allows forward sorting by dependencies (ie lowest deps first).
--   
--   This is the same as <tt>createGraph'' []</tt>
createGraph' :: Bool -> Bool -> Bool -> Maybe FilePath -> [FilePath] -> IO PackageGraph

-- | Create a directed dependency graph for a set of packages For the
--   (createGraph default) reverse deps graph the arrows point back from
--   the dependencies to the dependendent (parent/consumer) packages, and
--   this allows forward sorting by dependencies (ie lowest deps first).
--   
--   Additionally this function allows passing options to rpmspec: eg
--   `--with bootstrap` etc
createGraph'' :: [String] -> Bool -> Bool -> Bool -> Maybe FilePath -> [FilePath] -> IO PackageGraph

-- | Get all of the dependencies of a subset of one or more packages within
--   full PackageGraph. The subset paths should be written in the same way
--   as for the graph.
dependencyNodes :: [FilePath] -> PackageGraph -> [FilePath]

-- | A flipped version of subgraph
subgraph' :: Gr a b -> [Node] -> Gr a b

-- | Return the bottom-up list of dependency layers of a graph
packageLayers :: PackageGraph -> [[FilePath]]

-- | The lowest dependencies of a PackageGraph
lowestLayer :: PackageGraph -> [FilePath]

-- | The lowest dependency nodes of a PackageGraph
lowestLayer' :: PackageGraph -> [LNode FilePath]

-- | The leaf (outer) packages of a PackageGraph
packageLeaves :: PackageGraph -> [FilePath]

-- | Returns packages independent of all the rest of the graph
separatePackages :: PackageGraph -> [FilePath]
instance GHC.Classes.Eq Distribution.RPM.Build.Graph.SourcePackage


-- | This module provides dependency sorting functions
--   
--   <pre>
--   import <a>Distribution.RPM.Build.Order</a>
--   
--   <a>dependencySort</a> ["pkg1", "pkg2", "../pkg3"]
--   
--   =&gt; ["pkg2", "../pkg3", "pkg1"]
--   </pre>
--   
--   where pkg1 depends on pkg3, which depends on pkg2 say.
--   
--   Package paths can be directories or spec files.
module Distribution.RPM.Build.Order

-- | sort packages by dependencies
dependencySort :: [FilePath] -> IO [FilePath]

-- | sort packages by dependencies with rpm options
dependencySortRpmOpts :: [String] -> [FilePath] -> IO [FilePath]

-- | dependency sort of packages in graph components
dependencySortParallel :: [FilePath] -> IO [[FilePath]]

-- | group packages in dependency layers, lowest first
dependencyLayers :: [FilePath] -> IO [[FilePath]]

-- | returns the leaves of a set of packages
leafPackages :: [FilePath] -> IO [FilePath]

-- | returns independent packages among a set of packages
independentPackages :: [FilePath] -> IO [FilePath]

-- | Used to control the output from sortGraph
data Components

-- | separate independent stacks
Parallel :: Components

-- | combine indepdendent stacks together
Combine :: Components

-- | only stack of pacakges
Connected :: Components

-- | only independent packages in the package set
Separate :: Components

-- | output sorted packages from a PackageGraph arrange by Components
sortGraph :: Components -> PackageGraph -> IO ()
