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

Trent W. Buck trentbuck at gmail.com
Sun Mar 15 11:28:24 UTC 2009


On Sun, Mar 15, 2009 at 10:59:44AM +0100, Petr Rockai wrote:
> 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?

I meant postCopy.

> >  $ 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?

Looking into it now.

> > 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.

I agree on all points.  I want to get it *working*, and only then
worry about getting it working *correctly*.

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

Will look into that eventually...

> 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.)

Distribution.Simple.InstallDirs.fromPathTemplate?  Just a guess.


More information about the darcs-users mailing list