cab
A maintenance command of Haskell cabal packages
Kazu Yamamoto
"cab" is a MacPorts-like maintenance command of Haskell cabal packages. Some parts of this program are a wrapper to "ghc-pkg", "cabal", and "cabal-dev".
If you are always confused due to inconsistency of "ghc-pkg" and "cabal", or if you want a way to check all outdated packages, or if you want a way to remove outdated packages recursively, this command helps you.
"cab" is designed to maintain user packages only assuming that users use a Haskell Platform and don't want to touch the global packages.
"cab" is tested on both Mac and Windows and with both GHC 6.12.3 and GHC 7.0.2.
Usage
The following commands are provided:
- cab
- Display the help message.
- cab help [<command>]
- Display the help message of the command.
- cab sync
- Fetch the latest package index.
Command aliases: "update" - cab [-n] [-f <flags>] [-s <sandbox>] [install <package>] [<ver>]
- Install packages
- cab [-n] [-r] [-s <sandbox>] uninstall <package> [<ver>]
- Uninstall packages.
Command aliases: "uninstall", "delete", "remove", "unregister" - cab [-a] [-r] [-i] [-s <sandbox>] installed
- List installed packages.
Command aliases: "list" - cab [-f <flags>] [-s <sandbox>] [-t] configure
- Configure a cabal package.
Command aliases: "conf" - cab build
- Build a cabal package.
- cab clean
- Clean up a build directory.
- cab [-a] [-s <sandbox>] outdated
- Display outdated packages.
- cab [-s <sandbox>] info <package>
- Display information of a package.
- cab sdist
- Make tar.gz for source distribution.
Command aliases: "pack" - cab [-n]upload
- Uploading tar.gz to HackageDB. The "-n" option means "check uploading".
Command aliases: "up" - cab unpack <package>
- Untar a package in the current directory.
- cab [-a] [-r] [-i] [-s <sandbox>] deps <package> [<ver>]
- Show dependencies of this package.
- cab [-a] [-r] [-i] [-s <sandbox>] revdeps <package> [<ver>]
- Show reverse dependencies of this package.
Command aliases: "dependents" - cab [-s <sandbox>] check
- Check consistency of packages.
- cab genpaths
- Generate Paths_<pkg>.hs.
Command aliases: "genpath" - cab search <key>
- Search available packages by package name.
- cab [-s <sandbox>] env
- Show environment variables.
- cab [-s <sandbox>] add <source>
- Add a source directory.
Command aliases: "add-source" - cab [-s <sandbox>] test
- Run tests.
- cab doc
- Generate manuals.
Command aliases: "haddock", "man"
The following options are provided:
- --all, -a
- Show global packages in addition to user packages.
- --recursive, -r
- Follow dependencies recursively.
- --dry-run, -n
- Run without destructive operations.
- --info, -i
- Show license and author information.
- --help, -h
- Equivalent to the help command.
- --sandbox=<sandbox>, -s <sandbox>
- Specify a sandbox directory.
- --flags=<flags>, -f <flags>
- Specify flags.
- --test, -t
- Enable test
Stories
Catching up HackageDB
% cab sync % cab outdated foo 0.0.1 < 0.0.2 % cab delete -r foo Deleting foo 0.0.1 Deleting bar 2.0.5 % cab install bar
Installing a new package
Before installing, check whether or not a new package break user packages:
% cab -n install foo Reading available packages... Resolving dependencies... In order, the following would be installed: bar-1.0.9 (reinstall)
If you see "reinstall", please stop installing. You should consider to use a sandbox.
Developing
A sandbox is very useful to develop your package which requires new non-registered packages.
% cd <your_package> % cabal -s "~/.sandbox" install
If the CAB_SANDBOX_PATH environment variable is specified, you can ommit the "-s" option. To set the variable, the following command is useful:
% cab -s ~/.sandbox env export CAB_SANDBOX_PATH=/Users/kazu/.sandbox setenv CAB_SANDBOX_PATH /Users/kazu/.sandbox The following commands are not necessary in normal case. export GHC_PACKAGE_PATH=... setenv GHC_PACKAGE_PATH ...
Cut and pasete a necessary line to your shell.
If you use non-registered package, you should add it to your sandbox DB:
% cab -s ~/.sandbox add <your_package>
Understanding dependency
Dependency of a package:
% cab -r deps wai-app-file-cgi
attoparsec 0.8.5.0
blaze-builder 0.2.1.4
enumerator 0.4.9.1
network 2.2.1.10
wai 0.3.2
blaze-builder 0.2.1.4
enumerator 0.4.9.1
network 2.2.1.10
wai-app-static 0.0.1.4
blaze-html 0.4.1.0
blaze-builder 0.2.1.4
file-embed 0.0.3.1
unix-compat 0.2.1.1
wai 0.3.2
blaze-builder 0.2.1.4
enumerator 0.4.9.1
network 2.2.1.10
web-routes 0.23.4
network 2.2.1.10
utf8-string 0.3.6
Reverse dependency of a package:
% cab revdeps blaze-builder blaze-builder-enumerator 0.2.0.2 blaze-html 0.4.1.0 cookie 0.0.0 hamlet 0.7.3 http-enumerator 0.3.1 json-enumerator 0.0.1.1 mime-mail 0.1.0.1 wai 0.3.2 wai-app-file-cgi 0.0.2 wai-extra 0.3.3 warp 0.3.3 yesod-core 0.7.0.2 yesod-form 0.0.0.2
Dependency of all user packages:
% cab -s ~/.sandbox -r list ...
Install
Type as follows:
% cabal install cabal-dev % cabal install cab
You should add "~/.cabal/bin" to the PATH environment variable.
Mac
If you use Haskell Platform on Mac, the following operation is necessary. This is because "cabal-dev" does not read "~/.cabal/config".
% cd ~/.cabal % ln -s ~/Library/Haskell/repo-cache packages
Repository
The latest source code is available from github:
Acknowledgment
I thank shelarcy for his testing.