cabal2rpm - converts Haskell Cabal descriptions into RPM specs
tar zxf package.tar.gz
cabal2rpm package/Package.cabal > package.spec
# copy tarball into ~/rpm/SOURCES here
rpmbuild -ba package.spec
This tool converts Haskell Cabal package-descriptions (.cabal files)
into RPM spec files. It makes reasonable guesses at what should go
in the specs, but because ``Cabalized'' tarballs presently do not have a
standardized layout and naming conventions, you may need to make some
adjustments.
The syntax for using cabal2rpm is as follows:
cabal2rpm package.cabal [name=value...] > package.spec
The resulting RPM spec file can be fed to rpmbuild to build binary packages.
Note: All packages built by cabal2rpm are targeted to a specific release of GHC from the Fedora Haskell project. Thus if you build Cabal for GHC 6.2.2, you will end up with the following RPMs:
cabal-ghc622-0.5-1.i386.rpm
cabal-ghc622-debuginfo-0.5-1.i386.rpm
cabal-ghc622-0.5-1.src.rpm
The optional name-value pairs given on the command line are used to define or override variables used during the expansion of the RPM-spec template. (See also How variable expansion works.) You may want to override the default bindings for these commonly used variables.
rpm_name="mypackage"
Name to give the RPM package. You might need to change this if the capitalization of the Haskell package differs from the RPM name you want. (RPM names are usually all lowercase.) The default value is the prefix ``haskell-'' and then the lower-case version of the Cabal package's name.
rpm_version="1.2"
The version to give the RPM. The default value is the Cabal package's version with all dashes converted to underscores.
rpm_release="1.fc3"
The release to give the RPM. The default value is ``1''.
source="http://my.example.com/path/to/mypackage-1.2.tar.gz"
The location of the source tarball. In RPM specs, this is often a URL
that ends with the source tarball, but it can also be just the
tarball's name. By default it is the Cabal package's package-url
or, if that does not exist, @@lcname@@-@@version@@.tar.gz where
@@lcname@@ expands to the lower-case version of the Cabal package's
name and @@version@@ expands to the Cabal package's version.
tarballroot="mypackage"
Root directory that results from expanding the package tarball.
The default value is "@@lcname,name@@-@@version@@", where
lcname is the lowercase version of the Cabal package's name.
docs="README Changes"
Any documentation files that ought to be copied from the expanded tarball into the RPM's documentation directory.
Attached to the end of this Perl program is an RPM-spec template. (You can see the template by giving the command, ``cabal2rpm --template''.) Sprinkled throughout it are variable-expansion sites. To generate the RPM spec, all of the sites are expanded until they can be expanded no further. The resulting string is the final RPM spec.
The variables used in expansion are set to default values extracted from the Cabal package description that you supply and environmental conditions such as the version of GHC you are using. The default values are then overridden my your command-line bindings.
Variable expansion in the template works like this. Given the following expression site,
@@x1,x2,x3...|alt@@
the evaluator will first lookup x1 and, if it exists, substitute
its value for the site and stop. Otherwise, it will continue on with
x2, x3, and so on until it finds a value to use. If no such
value exists and there is an |alt clause in the expansion site,
alt will be used as the site's substitution; otherwise ??? will
be used and the evaluator will emit a warning.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Tom Moertel (tom@moertel.com)
2007-09-07