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 # Warning: hack
my $prog=shift; my $prog=shift;
$prog=~s/\.\d+$//;
$prog=~s/man\///;
my $section=shift; my $section=shift;
print ".TH $prog $section\n"; print ".TH $prog $section\n";

View file

@ -3,6 +3,8 @@ git-annex (6.20160528) UNRELEASED; urgency=medium
* Improve SHA*E extension extraction code. * Improve SHA*E extension extraction code.
* Windows: Avoid terminating git-annex branch lines with \r\n when * Windows: Avoid terminating git-annex branch lines with \r\n when
union merging and performing transitions. 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 -- 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 all=git-annex mans docs
# set to "./Setup" if you lack a cabal program. Or can be set to "stack" # 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; \ ln -sf dist/build/git-annex/git-annex git-annex; \
fi fi
man/%.1: doc/%.mdwn
./Build/mdwn2man $@ 1 $< > $@
# These are not built normally. # These are not built normally.
git-union-merge.1: doc/git-union-merge.mdwn git-union-merge.1: doc/git-union-merge.mdwn
./Build/mdwn2man git-union-merge 1 doc/git-union-merge.mdwn > git-union-merge.1 ./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-mans: mans
install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/man/man1 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-docs: docs install-mans
install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/doc/git-annex install -d $(DESTDIR)$(PREFIX)/$(SHAREDIR)/doc/git-annex
@ -80,15 +76,10 @@ else
IKIWIKI=ikiwiki IKIWIKI=ikiwiki
endif endif
mans: man $(mans) mans: Build/Mans
./Build/Mans
man:
mkdir -p man
docs: 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 \ LC_ALL=C TZ=UTC $(IKIWIKI) doc html -v --wikiname git-annex \
--plugin=goodstuff \ --plugin=goodstuff \
--no-usedirs --disable-plugin=openid --plugin=sidebar \ --no-usedirs --disable-plugin=openid --plugin=sidebar \
@ -97,8 +88,7 @@ docs: mans
--plugin=comments --set comments_pagespec="*" \ --plugin=comments --set comments_pagespec="*" \
--exclude='news/.*' --exclude='design/assistant/blog/*' \ --exclude='news/.*' --exclude='design/assistant/blog/*' \
--exclude='bugs/*' --exclude='todo/*' --exclude='forum/*' \ --exclude='bugs/*' --exclude='todo/*' --exclude='forum/*' \
--exclude='users/*' --exclude='devblog/*' --exclude='thanks'; \ --exclude='users/*' --exclude='devblog/*' --exclude='thanks'
fi
clean: clean:
if [ "$(BUILDER)" != ./Setup ] && [ "$(BUILDER)" != cabal ]; then $(BUILDER) clean; fi if [ "$(BUILDER)" != ./Setup ] && [ "$(BUILDER)" != cabal ]; then $(BUILDER) clean; fi
@ -106,7 +96,7 @@ clean:
doc/.ikiwiki html dist tags Build/SysConfig.hs \ doc/.ikiwiki html dist tags Build/SysConfig.hs \
Setup Build/InstallDesktopFile Build/EvilSplicer \ Setup Build/InstallDesktopFile Build/EvilSplicer \
Build/Standalone Build/OSXMkLibs Build/LinuxMkLibs \ Build/Standalone Build/OSXMkLibs Build/LinuxMkLibs \
Build/DistributionUpdate Build/BuildVersion \ Build/DistributionUpdate Build/BuildVersion Build/Mans \
git-union-merge .tasty-rerun-log git-union-merge .tasty-rerun-log
find . -name \*.o -exec rm {} \; find . -name \*.o -exec rm {} \;
find . -name \*.hi -exec rm {} \; find . -name \*.hi -exec rm {} \;
@ -121,6 +111,8 @@ Build/OSXMkLibs: Build/OSXMkLibs.hs
$(GHC) --make $@ -Wall -fno-warn-tabs $(GHC) --make $@ -Wall -fno-warn-tabs
Build/LinuxMkLibs: Build/LinuxMkLibs.hs Build/LinuxMkLibs: Build/LinuxMkLibs.hs
$(GHC) --make $@ -Wall -fno-warn-tabs $(GHC) --make $@ -Wall -fno-warn-tabs
Build/Mans: Build/Mans.hs
$(GHC) --make $@ -Wall -fno-warn-tabs
# Upload to hackage. # Upload to hackage.
hackage: hackage:

View file

@ -14,11 +14,13 @@ import Control.Applicative
import Control.Monad import Control.Monad
import System.Directory import System.Directory
import Data.List import Data.List
import Data.Maybe
import Control.Exception import Control.Exception
import qualified System.Info import qualified System.Info
import qualified Build.DesktopFile as DesktopFile import qualified Build.DesktopFile as DesktopFile
import qualified Build.Configure as Configure import qualified Build.Configure as Configure
import Build.Mans (buildMans)
import Utility.SafeCommand import Utility.SafeCommand
main :: IO () main :: IO ()
@ -51,13 +53,10 @@ installManpages copyDest verbosity pkg lbi =
installOrdinaryFiles verbosity dstManDir =<< srcManpages installOrdinaryFiles verbosity dstManDir =<< srcManpages
where where
dstManDir = mandir (absoluteInstallDirs pkg lbi copyDest) </> "man1" dstManDir = mandir (absoluteInstallDirs pkg lbi copyDest) </> "man1"
srcManpages = do -- If mdwn2man fails, perhaps because perl is not available,
havemans <- boolSystem "make" [Param "mans"] -- we just skip installing man pages.
if havemans srcManpages = zip (repeat "man") . map takeFileName . catMaybes
then zip (repeat "man") <$> buildMans
. filter (".1" `isSuffixOf`)
<$> getDirectoryContents "man"
else return []
installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO () installDesktopFile :: CopyDest -> Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()
installDesktopFile copyDest _verbosity pkg lbi 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/git-annex-xmppgit.mdwn
doc/logo.svg doc/logo.svg
doc/logo_16x16.png doc/logo_16x16.png
Makefile
Build/mdwn2man Build/mdwn2man
Assistant/WebApp/routes Assistant/WebApp/routes
static/activityicon.gif static/activityicon.gif
@ -663,6 +662,7 @@ Executable git-annex
Build.EvilSplicer Build.EvilSplicer
Build.InstallDesktopFile Build.InstallDesktopFile
Build.LinuxMkLibs Build.LinuxMkLibs
Build.Mans
Build.NullSoftInstaller Build.NullSoftInstaller
Build.OSXMkLibs Build.OSXMkLibs
Build.Standalone Build.Standalone