[darcs-users] darcs patch: DRAFT: Teach Cabal to install manpage.

Petr Rockai me at mornfall.net
Sun Mar 15 09:59:44 UTC 2009


Trent W.Buck <trentbuck at gmail.com> writes:
>  postConf isn't working here, and I don't know why.  I get the
>  following, but ls can see doc/darcs.1, and I confirmed with
>  getCurrentDirectory that $PWD is in the right place.  So WTF?
Do you mean postBuild instead of postConf?

>  $ cabal copy --destdir=`mktemp -d`
>  [2 of 2] Compiling Main             ( Setup.lhs, dist/setup/Main.o )
>  Linking ./dist/setup/setup ...
>  Installing library in
>  /tmp/tmp.HMnIvPPrnP/home/twb/.cabal/lib/darcs-2.2.0/ghc-6.10.1
>  Installing executable(s) in /tmp/tmp.HMnIvPPrnP/home/twb/.cabal/bin
>  setup: doc/darcs.1 : copyFile: does not exist (No such file or directory)
Yes, this is pretty weird. Can you strace?

> hunk ./Setup.lhs 90
>      -- Call the ordinary build code
>      buildHook simpleUserHooks pkg' lbi' hooks flags,

> +  postBuild = \ _ _ _ _ -> do
> +                -- Create darcs.1
> +                system "dist/build/darcs/darcs help manpage >doc/darcs.1"
> +                return (),
> +  postCopy = \ _ _ pkg lbi -> do
> +               -- Install darcs.1 into ${mandir}.
> +               let dir = mandir $ absoluteInstallDirs pkg lbi NoCopyDest
> +               copyFile "doc/darcs.1 " $ dir </> "man1/darcs.1",
However, working or not, this is wrong, you should not create the manpage in
the source tree. Instead, you need to create it somewhere under
dist/... Moreover, hardcoding "dist" is not the best idea ever either. See this
code in runTests:

    cwd <- getCurrentDirectory
    let abs = isAbsolute $ buildDir lbi
        path = (if abs then id else (cwd </>))
               (buildDir lbi </> "darcs")

You could probably factor that out and use it in your code as well (or maybe
something like this is already hidden in Cabal somewhere, I just haven't found
it.)

Yours,
   Petr.

-- 
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation


More information about the darcs-users mailing list