installing non-haskell binaries with cabal

hello, I would like to distribute a shell script as part of my haskell project. How can I tell cabal to install the script as an executable? Cheers, Misha

On Mon, 2008-06-09 at 23:35 +0200, Misha Aizatulin wrote:
hello,
I would like to distribute a shell script as part of my haskell project. How can I tell cabal to install the script as an executable?
At the moment there is no easy way of doing that. It can be installed as a data file pretty easily but not into the $bindir. You'd have to write a custom Setup.hs script and change the postInst hook. Use LocalBuildInfo.absoluteInstallDirs to get the bindir. Duncan

On 2008.06.09 23:36:19 +0100, Duncan Coutts
On Mon, 2008-06-09 at 23:35 +0200, Misha Aizatulin wrote:
hello,
I would like to distribute a shell script as part of my haskell project. How can I tell cabal to install the script as an executable?
At the moment there is no easy way of doing that. It can be installed as a data file pretty easily but not into the $bindir.
You'd have to write a custom Setup.hs script and change the postInst hook. Use LocalBuildInfo.absoluteInstallDirs to get the bindir.
Duncan
And of course, at that point, you'd be better off just writing the script in Haskell. (Seriously, I had to do that for the Roguestar packages. It was hardly any trouble at all - Haskell is a better scripting language than I think people give it credit for.) -- gwern SADRS CTP Dateline Mac-10 Alex Sears Ceridian botux Artful industrial

gwern0:
On 2008.06.09 23:36:19 +0100, Duncan Coutts
scribbled 0.5K characters: On Mon, 2008-06-09 at 23:35 +0200, Misha Aizatulin wrote:
hello,
I would like to distribute a shell script as part of my haskell project. How can I tell cabal to install the script as an executable?
At the moment there is no easy way of doing that. It can be installed as a data file pretty easily but not into the $bindir.
You'd have to write a custom Setup.hs script and change the postInst hook. Use LocalBuildInfo.absoluteInstallDirs to get the bindir.
Duncan
And of course, at that point, you'd be better off just writing the script in Haskell.
(Seriously, I had to do that for the Roguestar packages. It was hardly any trouble at all - Haskell is a better scripting language than I think people give it credit for.)
I'd agree here. It probably is easier to rewrite it in Haskell (just use system everywhere), and keep easy distribution via cabal-install. -- Don

On Mon, 2008-06-09 at 16:22 -0700, Don Stewart wrote:
On 2008.06.09 23:36:19 +0100, Duncan Coutts
scribbled 0.5K characters: On Mon, 2008-06-09 at 23:35 +0200, Misha Aizatulin wrote:
hello,
I would like to distribute a shell script as part of my haskell project. How can I tell cabal to install the script as an
executable?
At the moment there is no easy way of doing that. It can be
installed as
a data file pretty easily but not into the $bindir.
You'd have to write a custom Setup.hs script and change the
hook. Use LocalBuildInfo.absoluteInstallDirs to get the bindir.
Duncan
And of course, at that point, you'd be better off just writing the
gwern0: postInst script in Haskell.
(Seriously, I had to do that for the Roguestar packages. It was
hardly
any trouble at all - Haskell is a better scripting language than I think people give it credit for.)
I'd agree here. It probably is easier to rewrite it in Haskell (just use system everywhere), and keep easy distribution via cabal-install.
Yikes. Every time I learn something new about Cabal, it's /always/ some new limitation, never a new feature. Are there any plans to someday permit doing things with Cabal the Cabal developers haven't added specific code for yet? jcc

On Mon, 2008-06-09 at 16:37 -0700, Jonathan Cast wrote:
On Mon, 2008-06-09 at 16:22 -0700, Don Stewart wrote:
And of course, at that point, you'd be better off just writing the
gwern0: script in Haskell.
(Seriously, I had to do that for the Roguestar packages. It was
hardly
any trouble at all - Haskell is a better scripting language than I think people give it credit for.)
I'd agree here. It probably is easier to rewrite it in Haskell (just use system everywhere), and keep easy distribution via cabal-install.
Yikes. Every time I learn something new about Cabal, it's /always/ some new limitation, never a new feature. Are there any plans to someday permit doing things with Cabal the Cabal developers haven't added specific code for yet?
All these things are already possible (if not easy) using custom code in the Setup.hs script and/or using a ./configure script. Duncan

On Wed, 2008-06-11 at 11:08 +0100, Duncan Coutts wrote:
On Mon, 2008-06-09 at 16:37 -0700, Jonathan Cast wrote:
On Mon, 2008-06-09 at 16:22 -0700, Don Stewart wrote:
And of course, at that point, you'd be better off just writing the
gwern0: script in Haskell.
(Seriously, I had to do that for the Roguestar packages. It was
hardly
any trouble at all - Haskell is a better scripting language than I think people give it credit for.)
I'd agree here. It probably is easier to rewrite it in Haskell (just use system everywhere), and keep easy distribution via cabal-install.
Yikes. Every time I learn something new about Cabal, it's /always/ some new limitation, never a new feature. Are there any plans to someday permit doing things with Cabal the Cabal developers haven't added specific code for yet?
All these things are already possible (if not easy) using custom code in the Setup.hs script and/or using a ./configure script.
I assume the claim above about cabal-install failing to install such a package is incorrect, right? Beyond which, to paraphrase what I tell my boss at work, I can get Setup.lhs to do anything I want, it's written in a Turing-complete language. But I'd rather not use a tool I'm going to have to fight. jcc

On Wed, Jun 11, 2008 at 06:41:37AM -0700, Jonathan Cast wrote:
On Wed, 2008-06-11 at 11:08 +0100, Duncan Coutts wrote:
All these things are already possible (if not easy) using custom code in the Setup.hs script and/or using a ./configure script.
I assume the claim above about cabal-install failing to install such a package is incorrect, right?
Beyond which, to paraphrase what I tell my boss at work, I can get Setup.lhs to do anything I want, it's written in a Turing-complete language. But I'd rather not use a tool I'm going to have to fight.
Indeed, that's the advantage of using systems like autoconf and make: they're written with extensibility in mind. David

On Wed, 2008-06-11 at 06:41 -0700, Jonathan Cast wrote:
Yikes. Every time I learn something new about Cabal, it's /always/ some new limitation, never a new feature. Are there any plans to someday permit doing things with Cabal the Cabal developers haven't added specific code for yet?
All these things are already possible (if not easy) using custom code in the Setup.hs script and/or using a ./configure script.
I assume the claim above about cabal-install failing to install such a package is incorrect, right?
Right. cabal-install works perfectly well with packages that use custom Setup.hs scripts. It picks a suitable version of the Cabal library to build them with.
Beyond which, to paraphrase what I tell my boss at work, I can get Setup.lhs to do anything I want, it's written in a Turing-complete language. But I'd rather not use a tool I'm going to have to fight.
The honest situation is this: the Setup.hs can override hooks into pretty much every phase of configuration, build and installation (see UserHooks module) and you can use any of the base and other core libs to do what you want. So yes, you can do pretty much anything, however the API to get information out of Cabal and to use its functions is of variable utility and stability because the API that setup.hs scripts are expected to use has never been carefully delineated or designed. We now know a lot more about how it *should* be designed but that's not of any immediate help to you. So as people say, once you start to need a custom Setup.hs things become rather harder. On the other hand it is still probably a good deal easier than writing a custom build system with make + autoconf and making that easy to deploy. If you find specific tasks you'd like to be able to do but are currently tricky then file feature requests. Duncan

Duncan Coutts wrote:
If you find specific tasks you'd like to be able to do but are currently tricky then file feature requests.
that was just my plan, here is the ticket: http://hackage.haskell.org/trac/hackage/ticket/293 Misha

On Mon, 9 Jun 2008, Don Stewart wrote:
gwern0:
And of course, at that point, you'd be better off just writing the script in Haskell.
(Seriously, I had to do that for the Roguestar packages. It was hardly any trouble at all - Haskell is a better scripting language than I think people give it credit for.)
I'd agree here. It probably is easier to rewrite it in Haskell (just use system everywhere), and keep easy distribution via cabal-install.
I think Haskell code is also more portable than bash code.

Gwern Branwen wrote:
And of course, at that point, you'd be better off just writing the script in Haskell.
I'd still be happy if cabal better supported heterogeneous projects, where some parts are written in another language. Count it as my feature request - seems to be be quite easy as far as executable installation is concerned. There are many reasons to write some utilities in another language, like * legacy code * a two-liner shell script is small, where an equivalent compiled haskell code may be hundreds of kbs (looks like cabal doesn't allow to install haskell scripts, only compiled code) * my editor does syntax highlighting for pure shell scripts but not for shell scripts wrapped in haskell * love for pipes, subshells, perl regular expressions, etc. If you want an example, look at ghc: it comes with perl scripts. Cheers, Misha
participants (7)
-
David Roundy
-
Don Stewart
-
Duncan Coutts
-
Gwern Branwen
-
Henning Thielemann
-
Jonathan Cast
-
Misha Aizatulin