So, I've written a neat little program that can analyse Japanese text and give the user various statistics regarding Kanji usage therein and I'd like to release this program to the world. The problem is, I have no idea how to create a "release".
I realize that *nix systems often put executables (or symlinks) in places like /usr/bin, and that build scripts often put them there automatically, but it turns out I went and wrote this thing in Haskell.
Then just use cabal!
...I hear you say. Well I would, except that my program has a good amount of data files that it reads out of, and of course the program needs to know where those files are. By using cabal, would the executable not be thrown to some weird project filepath a la:
/usr/share/haskell/cabal/morecabal-1.0.4/myproject-1.3.4.1.a/thisisridiculous/
At current I run the executable out of its source directory, and it's looking for the data files in "./data". Is there a typical format for installation paths so I could tell my program ahead of time in the source where to look for the data?
My eventual goal is to make this an Arch Linux package. Can anyone help me get started?
For the curious, the git repo is here. Thanks in advance for any help you can give.
The portable way of referencing data files in a Cabal project is to name them in the data-files
property in your .cabal
file.
Cabal will generate a module called Paths_packagename
which defines a function
getDataFileName :: FilePath -> IO FilePath
which your code can use to determine where the data files got installed.
See: Accessing data files from package code
Have a look at how an existing Haskell project, such as Gitit is packaged for Arch linux. In particular, the PKGBUILD.
You can also download The gitit tarball and have a look at how to use the data-files:
directive in the gitit.cabal
file.
I don't read Haskell, but from what I understand of the source, the file Paths_gigit.hs
(which can be found here. ) is generated by cabal so that you only have to worry about relative paths. Then it's just a matter of importing it and using the getDataFileName
function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With