cabal-sort: Topologically sort cabal packages
If you have a bunch of packages you may want to compile or recompile, then you need an order of compilation that meets the dependencies. Given a number of cabal package files, this program reads all those files and emits them topologically sorted according to their dependencies. This way you can compile many packages at once, say if a very low-level package has changed.
For compiling a couple of packages from their local darcs repositories in the right order, you may run something like
for dir in `find . -name "*.cabal" | fgrep -v _darcs | xargs cabal-sort --info=dir`; do (cd $dir && cabal install); done
Note that cabal-install does this automatically since version 0.10 when you call it will multiple directory names as arguments. However, when the constraint solver in cabal-install fails you may still use cabal-sort for an automated build.
For uploading a set of packages to Hackage in the right order you may run
for dir in `find . -name "*.cabal" | fgrep -v _darcs | xargs cabal-sort --info=dir`; do (cd $dir && rm dist/*.tar.gz && cabal sdist && cabal upload dist/*.tar.gz); done
Sometimes you have to inspect a number of packages manually, e.g. in order to adapt your packages to a new GHC version. In this case I found it useful to run
for dir in `find . -name "*.cabal" | fgrep -v _darcs | xargs cabal-sort --info=dir`; do (cd $dir; bash); done
This way you start a local shell for every package.
Then you can easily access commands in the shell history
that you already run for previous packages,
e.g. editor *.cabal
.
After you finished a package,
you switch to the next package
simply by leaving the shell by calling exit
.
Problem 1: Given packages A, B, C, where C depends on B and B depends on A, and you call
cabal-sort C.cabal A.cabal
then the emitted order of packages may be wrong, because cabal-sort does not get to know the dependency of C on B. Even if the order is correct, B.cabal is missing in the output and thus the list of cabal files cannot immediately be used for a sequence of cabal-install runs.
Problem 2: We ignore flags and merge all dependencies. This may lead to dependency cycles that cannot occur for any flag assignment.
You also have options --parallel
and --makefile
that support parallel compilation.
The first option is for manual parallelization
and the second one allows you to compile parallelly using
make
's -j
/--jobs
option.
There is a second program called ghc-pkg-dep
that finds recursively all packages that a set of packages depends on.
Duplicates are eliminated and the packages are given topologically sorted,
such that you can use this for recompilation of the packages.
The packages must already be registered with ghc-pkg
.
ghc-pkg-dep pkgA-0.1 pkgB-2.3 pkgC-0.1.2
On GHC versions before 7.0 ghc-pkg runs quite slowly.
In order to not get bored you may run the program with --verbose=2
option.
Related packages: rpmbuild-order
Downloads
- cabal-sort-0.1.2.tar.gz [browse] (Cabal source package)
- Package description (revised from the package)
Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.0.1, 0.0.2, 0.0.2.1, 0.0.3, 0.0.3.1, 0.0.4, 0.0.4.1, 0.0.4.2, 0.0.5, 0.0.5.1, 0.0.5.2, 0.0.5.3, 0.0.5.4, 0.0.5.5, 0.1, 0.1.1, 0.1.1.1, 0.1.1.2, 0.1.2 |
---|---|
Dependencies | base (>=2 && <5), bytestring (>=0.9.1 && <0.13), Cabal (>=3.8 && <3.13), comfort-graph (>=0.0.4 && <0.1), containers (>=0.2 && <0.8), directory (>=1 && <1.4), explicit-exception (>=0.1.6 && <0.3), filepath (>=1.1 && <1.6), non-empty (>=0.3.3 && <0.4), optparse-applicative (>=0.18 && <0.19), process (>=1.0 && <1.7), shell-utility (>=0.1 && <0.2), transformers (>=0.2 && <0.7), utility-ht (>=0.0.12 && <0.1) [details] |
Tested with | ghc ==6.10.4, ghc ==6.12.3, ghc ==8.0.2, ghc ==8.6.5 |
License | BSD-3-Clause |
Author | Henning Thielemann <haskell@henning-thielemann.de> |
Maintainer | Henning Thielemann <haskell@henning-thielemann.de> |
Revised | Revision 1 made by HenningThielemann at 2024-04-30T12:46:53Z |
Category | Distribution |
Home page | https://hub.darcs.net/thielema/cabal-sort/ |
Source repo | head: darcs get https://hub.darcs.net/thielema/cabal-sort/ this: darcs get https://hub.darcs.net/thielema/cabal-sort/ --tag 0.1.2 |
Uploaded | by HenningThielemann at 2023-09-29T19:30:18Z |
Distributions | LTSHaskell:0.1.2, Stackage:0.1.2 |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Executables | ghc-pkg-dep, cabal-sort |
Downloads | 11210 total (26 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs not available [build log] Last success reported on 2023-09-29 [all 1 reports] |