How do I create a suitable .tar.gz file for use with `cabal upload`?
Asked Answered
V

2

8

The standard way to share a Haskell library with other programmers is to create a Cabal package and upload it to http://hackage.haskell.org. I've written a library I wish to share, and I've successfully created a Cabal package using the guidelines online for creating cabal files. I've built the package and installed it locally—works fine. Now I want to upload it to Hackage. But cabal upload wants a .tar.gz file. There are reams of Cabal documentation, and I can't find what is supposed to go into this .tar.gz or how I'm supposed to create it.

Who knows, or knows where I can find out, how to create a .tar.gz that will work properly with cabal upload?

Valdes answered 6/4, 2010 at 19:23 Comment(3)
A vote to close? This is so on-topic...Bailiwick
@Thomas: Are you being snarky to a poster who has 3x your rep? Seriously?! :-P Bow to your elders already! :-PCampinas
I was being dead serious. This is definitely a programming-related question, and I was surprised to see that somebody had voted to close it as off-topic. Also, I bow.Bailiwick
B
12

From the wiki:

Since the code is cabalised, we can create a tarball with cabal-install directly (you can also use runhaskell Setup.hs sdist, but you need tar on your system 1):

$ cabal sdist
Building source dist for haq-0.0...
Source tarball created: dist/haq-0.0.tar.gz

This has the advantage that Cabal will do a bit more checking, and ensure that the tarball has the structure that HackageDB expects. Note that it does require the LICENSE file to exist. It packages up the files needed to build the project; to include other files (such as Test.hs in the above example, and our README), we need to add:

extra-source-files: Tests.hs README

to the .cabal file to have everything included.

Brackely answered 6/4, 2010 at 20:7 Comment(1)
Perfect! Thanks kindly. Especially for the extra-source-files tag!Valdes
T
4

Or if you're using darcs,

darcs dist

Note that cabal sdist will only pick up files listed in the .cabal file, so you might need to add READMEs etc under extra-source-files:

You can check you've a valid tarball with

cabal check

which runs the same tests that Hackage will run.

Tragicomedy answered 6/4, 2010 at 20:53 Comment(2)
Say, how come you haven't asked any questions?Epigastrium
He's dons. He knows everything.Bailiwick

© 2022 - 2024 — McMap. All rights reserved.