Install man pages as part of cabal 'copy' phase.

This commit is contained in:
John MacFarlane 2015-07-01 18:01:21 -07:00
parent 28cb50503b
commit 9ffd1babc7
5 changed files with 27 additions and 21 deletions

15
INSTALL
View file

@ -75,17 +75,12 @@ Quick install
--extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \ --extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \
-funicode_collation text-icu pandoc-citeproc -funicode_collation text-icu pandoc-citeproc
To build the `pandoc.1` man page: The `pandoc.1` man page will be built and installed automatically.
The build process shows you where it is installed: you may need
to set your `MANPATH` accordingly.
pandoc --print-default-data-file pandoc.1 > pandoc.1 The `pandoc-citeproc.1` man page will also be built and installed
automatically.
To build the `pandoc-citeproc` man pages, go to the pandoc-citeproc
build directory, and
cd man
make
The man page will be created in the `man1` subdirectory.
[GHC]: http://www.haskell.org/ghc/ [GHC]: http://www.haskell.org/ghc/
[Haskell platform]: http://hackage.haskell.org/platform/ [Haskell platform]: http://hackage.haskell.org/platform/

View file

@ -18,11 +18,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import Distribution.Simple import Distribution.Simple
import Distribution.Simple.PreProcess import Distribution.Simple.PreProcess
import Distribution.Simple.InstallDirs (mandir)
import Distribution.PackageDescription (PackageDescription(..), Executable(..)) import Distribution.PackageDescription (PackageDescription(..), Executable(..))
import System.Process ( rawSystem ) import System.Process ( rawSystem )
import System.FilePath ( (</>) ) import System.FilePath ( (</>) )
import System.Directory ( findExecutable ) import System.Directory ( findExecutable )
import Distribution.Simple.Utils (info, rawSystemExit) import Distribution.Simple.Utils (info, notice, rawSystemExit, installOrdinaryFile)
import Distribution.Simple.Setup import Distribution.Simple.Setup
import Distribution.Simple.LocalBuildInfo import Distribution.Simple.LocalBuildInfo
import Distribution.Verbosity import Distribution.Verbosity
@ -32,7 +33,11 @@ main = defaultMainWithHooks $ simpleUserHooks {
-- enable hsb2hs preprocessor for .hsb files -- enable hsb2hs preprocessor for .hsb files
hookedPreProcessors = [ppBlobSuffixHandler] hookedPreProcessors = [ppBlobSuffixHandler]
, postBuild = \args bf pkgdescr lbi -> , postBuild = \args bf pkgdescr lbi ->
makeManPages args bf pkgdescr lbi makeManPage args bf pkgdescr lbi
, postCopy = \_ flags pkg lbi ->
installManpage pkg lbi (fromFlag $ copyVerbosity flags)
NoCopyDest
} }
ppBlobSuffixHandler :: PPSuffixHandler ppBlobSuffixHandler :: PPSuffixHandler
@ -48,10 +53,10 @@ ppBlobSuffixHandler = ("hsb", \_ _ ->
return () return ()
}) })
makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo makeManPage :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo
-> IO () -> IO ()
makeManPages _ bf _ LocalBuildInfo{buildDir=buildDir} makeManPage _ bf _ LocalBuildInfo{buildDir=buildDir}
= do info verbosity "Creating data/pandoc.1" = do notice verbosity "Creating man/pandoc.1"
rawSystemExit verbosity progPath args rawSystemExit verbosity progPath args
where verbosity = fromFlagOrDefault normal $ buildVerbosity bf where verbosity = fromFlagOrDefault normal $ buildVerbosity bf
progPath = buildDir </> "pandoc" </> "pandoc" progPath = buildDir </> "pandoc" </> "pandoc"
@ -60,5 +65,12 @@ makeManPages _ bf _ LocalBuildInfo{buildDir=buildDir}
"--filter", "man/capitalizeHeaders.hs", "--filter", "man/capitalizeHeaders.hs",
"--filter", "man/removeNotes.hs", "--filter", "man/removeNotes.hs",
"--filter", "man/removeLinks.hs", "--filter", "man/removeLinks.hs",
"-o", "data/pandoc.1"] "-o", "man/pandoc.1"]
installManpage :: PackageDescription -> LocalBuildInfo
-> Verbosity -> CopyDest -> IO ()
installManpage pkg lbi verbosity copy = do
let mandest = mandir (absoluteInstallDirs pkg lbi copy) </>
"man1" </> "pandoc.1"
notice verbosity $ "Copying man page to " ++ mandest
installOrdinaryFile verbosity ("man" </> "pandoc.1") mandest

View file

@ -42,7 +42,7 @@ mkdir -p $DEST/share/doc/pandoc-citeproc
find $DIST -type d | xargs chmod 755 find $DIST -type d | xargs chmod 755
cp $SANDBOX/bin/pandoc $DEST/bin/ cp $SANDBOX/bin/pandoc $DEST/bin/
cp $SANDBOX/bin/pandoc-citeproc $DEST/bin/ cp $SANDBOX/bin/pandoc-citeproc $DEST/bin/
$SANDBOX/bin/pandoc --print-default-data-file pandoc.1 > $DEST/share/man/man1/pandoc.1 cp $SANDBOX/share/man/man1/pandoc.1 $DEST/share/man/man1/pandoc.1
gzip -9 $DEST/share/man/man1/pandoc.1 gzip -9 $DEST/share/man/man1/pandoc.1
cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/ cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
gzip -9 $DEST/share/man/man1/pandoc-citeproc.1 gzip -9 $DEST/share/man/man1/pandoc-citeproc.1

View file

@ -37,7 +37,7 @@ for f in pandoc pandoc-citeproc; do
cp $SANDBOX/bin/$f $DEST/bin/; cp $SANDBOX/bin/$f $DEST/bin/;
done done
cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/ cp $PANDOC_CITEPROC_PATH/man/man1/pandoc-citeproc.1 $DEST/share/man/man1/
$SANDBOX/bin/pandoc --print-default-data-file pandoc.1 > $DEST/share/man/man1/pandoc.1 cp $SANDBOX/share/man/man1/pandoc.1 $DEST/share/man/man1/pandoc.1
chown -R $ME:staff $DIST chown -R $ME:staff $DIST

View file

@ -106,8 +106,6 @@ Data-Files:
data/sample.lua data/sample.lua
-- documentation -- documentation
README, COPYRIGHT README, COPYRIGHT
-- man page (generated by Setup.hs after build:)
data/pandoc.1
Extra-Source-Files: Extra-Source-Files:
-- documentation -- documentation
INSTALL, BUGS, CONTRIBUTING.md, changelog INSTALL, BUGS, CONTRIBUTING.md, changelog
@ -206,6 +204,7 @@ Extra-Source-Files:
tests/epub/*.native tests/epub/*.native
tests/txt2tags.t2t tests/txt2tags.t2t
tests/twiki-reader.twiki tests/twiki-reader.twiki
Extra-Tmp-Files: man/pandoc.1
Source-repository head Source-repository head
type: git type: git