Refactor generation of git-annex.cabal and incorporate man pages.

The existing `sed | find | perl` hack in the Makefile was not
including the man pages in the generated git-annex.cabal.  I couldn't
figure out why it didn't work; running the `find | perl` part of the
command *did* list the man pages ...

So, I set up a new hack. It produces a cleaner .cabal file and
includes the man pages in the sdist.  I changed git-annex.cabal and
its generation as follows:

- git-annex.cabal is now generated by a here document in
  git-annex.cabal.template.sh.  The here document has inline file list
  insertion, whereas before the file lists were inserted with sed.

- The 'Extra-Source-Files:' field now only includes the non-source
  files: the man pages, plain text documentation, and license.

- The source dependencies are now listed in 'Other-Modules' sections
  in the 'Executable' and 'Test-Suite' sections.  The list of
  dependencies is generated by `gen-other-modules.sh`.

- The ./debian and ./doc are no longer included in the sdist package.
  These were not installed anywhere by `cabal install`.  A user that
  wants them could clone the git repo.

Running the tests with cabal is not yet working, i.e.

  cabal configure --enable-tests && cabal build && cabal test

and

  cabal install --enable-tests

fail to find Utility.Touch.  However, I did not break this: it doesn't
work for the git-annex package on Hackage either.  Next step is to
figure out how to deal with HSC in cabal ... or not bother, because
`make test` works.  I'm worried this is a cabal bug.

To test building from sdist, I've been running

  cd ../.. ; cabal sdist ; cd dist ; tar xf git-annex-3.20120605.tar.gz && cd git-annex-3.20120605 && rm -fr /tmp/git-annex && cabal install --prefix=/tmp/git-annex && tree -A /tmp/git-annex

in the dist directory.  Using `cabal-dev install` is a better test,
but is very slow.
This commit is contained in:
Nathan Collins 2012-06-10 19:24:15 -07:00
parent b86f201bdf
commit 7753b33c88
4 changed files with 62 additions and 9 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@ test
configure configure
Build/SysConfig.hs Build/SysConfig.hs
git-annex git-annex
git-annex.cabal
git-annex.1 git-annex.1
git-annex-shell.1 git-annex-shell.1
git-union-merge.1 git-union-merge.1

View file

@ -98,16 +98,20 @@ docs: $(mans)
clean: clean:
rm -rf tmp $(bins) $(mans) test configure *.tix .hpc $(sources) \ rm -rf tmp $(bins) $(mans) test configure *.tix .hpc $(sources) \
doc/.ikiwiki html dist $(clibs) doc/.ikiwiki html dist $(clibs) git-annex.cabal
# Workaround for cabal sdist not running Setup hooks, so I cannot # Workaround for cabal sdist not running Setup hooks, so I cannot
# generate a file list there. # generate a file list there.
sdist: clean sdist: clean $(mans)
@make $(mans) # Could make this a .PHONY, but it needs to be rerun each time,
@if [ ! -e git-annex.cabal.orig ]; then cp git-annex.cabal git-annex.cabal.orig; fi # unless we want to list a *lot* of dependencies.
@sed -e "s!\(Extra-Source-Files: \).*!\1$(shell find . -name .git -prune -or -not -name \\*.orig -not -type d -print | perl -ne 'print unless length >= 100')!i" < git-annex.cabal.orig > git-annex.cabal ./git-annex.cabal.template.sh > git-annex.cabal
@cabal sdist # Complains about not running 'configure' first, but adding
@mv git-annex.cabal.orig git-annex.cabal #
# cabal configure
#
# does not help.
cabal sdist
# Upload to hackage. # Upload to hackage.
hackage: sdist hackage: sdist

32
gen-other-modules.sh Executable file
View file

@ -0,0 +1,32 @@
#!/bin/bash
# Generate module list for 'Other-Modules:' field in git-annex.cabal.
# This would be simpler if the code were under ./src.
find Annex Annex.hs \
Backend Backend.hs \
Build \
Checks.hs \
CmdLine.hs \
Command Command.hs \
Common Common.hs \
Config.hs \
Crypto.hs \
Git Git.hs \
GitAnnex.hs \
GitAnnexShell.hs \
Init.hs \
Limit.hs \
Locations.hs \
Logs \
Messages Messages.hs \
Option.hs \
Remote Remote.hs \
Seek.hs \
Setup.hs \
Types Types.hs \
Upgrade Upgrade.hs \
Usage.hs \
Utility \
-name '*.hs' \
| sed -r -e 's!.hs!!' -e 's!/!.!g'

20
git-annex.cabal.template.sh Normal file → Executable file
View file

@ -1,3 +1,9 @@
#!/bin/bash
# Template for git-annex.cabal: the 'Other-Module:' fields are
# dynamically generated.
cat <<EOF
Name: git-annex Name: git-annex
Version: 3.20120605 Version: 3.20120605
Cabal-Version: >= 1.8 Cabal-Version: >= 1.8
@ -7,7 +13,6 @@ Author: Joey Hess
Stability: Stable Stability: Stable
Copyright: 2010-2012 Joey Hess Copyright: 2010-2012 Joey Hess
License-File: GPL License-File: GPL
Extra-Source-Files: use-make-sdist-instead
Homepage: http://git-annex.branchable.com/ Homepage: http://git-annex.branchable.com/
Build-type: Custom Build-type: Custom
Category: Utility Category: Utility
@ -25,6 +30,9 @@ Description:
versioned files, which is convenient for maintaining documents, Makefiles, versioned files, which is convenient for maintaining documents, Makefiles,
etc that are associated with annexed files but that benefit from full etc that are associated with annexed files but that benefit from full
revision control. revision control.
Extra-Source-Files:
git-annex.1 git-annex-shell.1
INSTALL README CHANGELOG NEWS GPL
Flag S3 Flag S3
Description: Enable S3 support Description: Enable S3 support
@ -36,7 +44,10 @@ Executable git-annex
pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP, pcre-light, extensible-exceptions, dataenc, SHA, process, json, HTTP,
base == 4.5.*, monad-control, transformers-base, lifted-base, base == 4.5.*, monad-control, transformers-base, lifted-base,
IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance
Other-Modules: Utility.Touch Other-Modules:
Utility.Touch
-- Auto-generated list of all Haskell modules:
`./gen-other-modules.sh | xargs -n1 -i echo ' '{}`
C-Sources: Utility/libdiskfree.c C-Sources: Utility/libdiskfree.c
Extensions: CPP Extensions: CPP
@ -53,8 +64,13 @@ Test-Suite test
base == 4.5.*, monad-control, transformers-base, lifted-base, base == 4.5.*, monad-control, transformers-base, lifted-base,
IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance
C-Sources: Utility/libdiskfree.c C-Sources: Utility/libdiskfree.c
Other-Modules:
Utility.Touch
-- Auto-generated list of all Haskell modules:
`./gen-other-modules.sh | xargs -n1 -i echo ' '{}`
Extensions: CPP Extensions: CPP
source-repository head source-repository head
type: git type: git
location: git://git-annex.branchable.com/ location: git://git-annex.branchable.com/
EOF