Remove Makefile from cabal tarball; man page building is now handled by a small haskell program.

This actually runs faster than building the man pages from the makefile
did. But the main purpose is to let Setup.hs import Build.Mans and so not
need the makefile.
This commit is contained in:
Joey Hess 2016-05-31 13:58:13 -04:00
parent 056a7f67a8
commit f4489cc415
Failed to extract signature
7 changed files with 95 additions and 33 deletions

58
Build/Mans.hs Normal file
View file

@ -0,0 +1,58 @@
{- Build man pages.
-
- Copyright 2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
{-# OPTIONS_GHC -fno-warn-tabs #-}
module Build.Mans where
import System.Directory
import System.FilePath
import Data.List
import Control.Monad
import System.Process
import System.Exit
import Data.Maybe
import Utility.Exception
main :: IO ()
main = do
mans <- buildMans
when (any isNothing mans) $
error "mdwn2man failed"
buildMans :: IO [Maybe FilePath]
buildMans = do
mansrc <- filter isManSrc <$> getDirectoryContents "doc"
createDirectoryIfMissing False "man"
forM mansrc $ \f -> do
let src = "doc" </> f
let dest = srcToDest src
srcm <- getModificationTime src
destm <- catchMaybeIO $ getModificationTime dest
if (Just srcm > destm)
then do
r <- system $ unwords
[ "./Build/mdwn2man"
, progName src
, "1"
, src
, "> " ++ dest
]
if r == ExitSuccess
then return (Just dest)
else return Nothing
else return (Just dest)
isManSrc :: FilePath -> Bool
isManSrc s = "git-annex" `isPrefixOf` (takeFileName s)
&& takeExtension s == ".mdwn"
srcToDest :: FilePath -> FilePath
srcToDest s = "man" </> progName s ++ ".1"
progName :: FilePath -> FilePath
progName = dropExtension . takeFileName

View file

@ -2,8 +2,6 @@
# Warning: hack
my $prog=shift;
$prog=~s/\.\d+$//;
$prog=~s/man\///;
my $section=shift;
print ".TH $prog $section\n";

View file

@ -3,6 +3,8 @@ git-annex (6.20160528) UNRELEASED; urgency=medium
* Improve SHA*E extension extraction code.
* Windows: Avoid terminating git-annex branch lines with \r\n when
union merging and performing transitions.
* Remove Makefile from cabal tarball; man page building is now handled by
a small haskell program.
-- Joey Hess <id@joeyh.name> Fri, 27 May 2016 13:12:48 -0400

View file

@ -1,4 +1,3 @@
mans=$(shell find doc -maxdepth 1 -name git-annex*.mdwn | sed -e 's/^doc/man/' -e 's/\.mdwn/\.1/')
all=git-annex mans docs
# set to "./Setup" if you lack a cabal program. Or can be set to "stack"
@ -31,9 +30,6 @@ git-annex: Build/SysConfig.hs
ln -sf dist/build/git-annex/git-annex git-annex; \
fi
man/%.1: doc/%.mdwn
./Build/mdwn2man $@ 1 $< > $@
# These are not built normally.
git-union-merge.1: doc/git-union-merge.mdwn
./Build/mdwn2man git-union-merge 1 doc/git-union-merge.mdwn > git-union-merge.1
@ -42,7 +38,7 @@ git-union-merge:
install-mans: mans
install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/man/man1
install -m 0644 $(mans) $(DESTDIR)$(PREFIX)/$(SHAREDIR)/man/man1
install -m 0644 man/*.1 $(DESTDIR)$(PREFIX)/$(SHAREDIR)/man/man1
install-docs: docs install-mans
install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/doc/git-annex
@ -80,25 +76,19 @@ else
IKIWIKI=ikiwiki
endif
mans: man $(mans)
man:
mkdir -p man
mans: Build/Mans
./Build/Mans
docs: mans
@if [ ! -e doc/index.mdwn ]; then \
echo "** doc/index.mdwn does not exist, skipping building docs (clone git-annex source to enable full docs build)" >&2; \
else \
LC_ALL=C TZ=UTC $(IKIWIKI) doc html -v --wikiname git-annex \
--plugin=goodstuff \
--no-usedirs --disable-plugin=openid --plugin=sidebar \
--underlaydir=/dev/null --set deterministic=1 \
--disable-plugin=shortcut --disable-plugin=smiley \
--plugin=comments --set comments_pagespec="*" \
--exclude='news/.*' --exclude='design/assistant/blog/*' \
--exclude='bugs/*' --exclude='todo/*' --exclude='forum/*' \
--exclude='users/*' --exclude='devblog/*' --exclude='thanks'; \
fi
LC_ALL=C TZ=UTC $(IKIWIKI) doc html -v --wikiname git-annex \
--plugin=goodstuff \
--no-usedirs --disable-plugin=openid --plugin=sidebar \
--underlaydir=/dev/null --set deterministic=1 \
--disable-plugin=shortcut --disable-plugin=smiley \
--plugin=comments --set comments_pagespec="*" \
--exclude='news/.*' --exclude='design/assistant/blog/*' \
--exclude='bugs/*' --exclude='todo/*' --exclude='forum/*' \
--exclude='users/*' --exclude='devblog/*' --exclude='thanks'
clean:
if [ "$(BUILDER)" != ./Setup ] && [ "$(BUILDER)" != cabal ]; then $(BUILDER) clean; fi
@ -106,7 +96,7 @@ clean:
doc/.ikiwiki html dist tags Build/SysConfig.hs \
Setup Build/InstallDesktopFile Build/EvilSplicer \
Build/Standalone Build/OSXMkLibs Build/LinuxMkLibs \
Build/DistributionUpdate Build/BuildVersion \
Build/DistributionUpdate Build/BuildVersion Build/Mans \
git-union-merge .tasty-rerun-log
find . -name \*.o -exec rm {} \;
find . -name \*.hi -exec rm {} \;
@ -121,6 +111,8 @@ Build/OSXMkLibs: Build/OSXMkLibs.hs
$(GHC) --make $@ -Wall -fno-warn-tabs
Build/LinuxMkLibs: Build/LinuxMkLibs.hs
$(GHC) --make $@ -Wall -fno-warn-tabs
Build/Mans: Build/Mans.hs
$(GHC) --make $@ -Wall -fno-warn-tabs
# Upload to hackage.
hackage:

View file

@ -14,11 +14,13 @@ import Control.Applicative
import Control.Monad
import System.Directory
import Data.List
import Data.Maybe
import Control.Exception
import qualified System.Info
import qualified Build.DesktopFile as DesktopFile
import qualified Build.Configure as Configure
import Build.Mans (buildMans)
import Utility.SafeCommand
main :: IO ()
@ -51,13 +53,10 @@ installManpages copyDest verbosity pkg lbi =
installOrdinaryFiles verbosity dstManDir =<< srcManpages
where
dstManDir = mandir (absoluteInstallDirs pkg lbi copyDest) </> "man1"
srcManpages = do
havemans <- boolSystem "make" [Param "mans"]
if havemans
then zip (repeat "man")
. filter (".1" `isSuffixOf`)
<$> getDirectoryContents "man"
else return []
-- If mdwn2man fails, perhaps because perl is not available,
-- we just skip installing man pages.
srcManpages = zip (repeat "man") . map takeFileName . catMaybes
<$> buildMans
installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
installDesktopFile copyDest _verbosity pkg lbi

View file

@ -0,0 +1,13 @@
[[!comment format=mdwn
username="joey"
subject="""comment 3"""
date="2016-05-31T17:18:09Z"
content="""
It could be that I made the wrong decision, but the tarball was being built
with hacks to include all those files before, and was still not complete
due to limits in what's allowed in tarballs on hackage.
The Makefile will be removed from the tarball in the next release,
which should I think make it clearer that the tarball is not intended for a
`make install` situation.
"""]]

View file

@ -139,7 +139,6 @@ Extra-Source-Files:
doc/git-annex-xmppgit.mdwn
doc/logo.svg
doc/logo_16x16.png
Makefile
Build/mdwn2man
Assistant/WebApp/routes
static/activityicon.gif
@ -663,6 +662,7 @@ Executable git-annex
Build.EvilSplicer
Build.InstallDesktopFile
Build.LinuxMkLibs
Build.Mans
Build.NullSoftInstaller
Build.OSXMkLibs
Build.Standalone