add a filelist for cabal sdist
I hate hard-coded 40 kilobyte lone file lists, and just once would like to see a build system that does not assume it's a good idea to have a file list, or a hardcoded file list, or a file list that can only be generated with a crippled form of globs. But not today, thank you cabal.
This commit is contained in:
parent
20565027cc
commit
b3ab44f8bb
3 changed files with 28 additions and 13 deletions
2
Makefile
2
Makefile
|
@ -84,7 +84,7 @@ docs: $(mans)
|
||||||
clean:
|
clean:
|
||||||
rm -rf build $(bins) $(mans) test configure *.tix .hpc \
|
rm -rf build $(bins) $(mans) test configure *.tix .hpc \
|
||||||
StatFS.hs Touch.hs SysConfig.hs Remote/S3.hs
|
StatFS.hs Touch.hs SysConfig.hs Remote/S3.hs
|
||||||
rm -rf doc/.ikiwiki html
|
rm -rf doc/.ikiwiki html dist
|
||||||
find . \( -name \*.o -or -name \*.hi \) -exec rm {} \;
|
find . \( -name \*.o -or -name \*.hi \) -exec rm {} \;
|
||||||
|
|
||||||
.PHONY: $(bins) test install
|
.PHONY: $(bins) test install
|
||||||
|
|
37
configure.hs
37
configure.hs
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import Data.List
|
import Data.List
|
||||||
|
import Data.String.Utils
|
||||||
|
import System.Cmd.Utils
|
||||||
|
|
||||||
import TestConfig
|
import TestConfig
|
||||||
|
|
||||||
|
@ -56,24 +58,36 @@ unicodeFilePath = do
|
||||||
{- Pulls package version out of the changelog. -}
|
{- Pulls package version out of the changelog. -}
|
||||||
getVersion :: Test
|
getVersion :: Test
|
||||||
getVersion = do
|
getVersion = do
|
||||||
|
version <- getVersionString
|
||||||
|
return $ Config "packageversion" (StringConfig version)
|
||||||
|
|
||||||
|
getVersionString :: IO String
|
||||||
|
getVersionString = do
|
||||||
changelog <- readFile "CHANGELOG"
|
changelog <- readFile "CHANGELOG"
|
||||||
let verline = head $ lines changelog
|
let verline = head $ lines changelog
|
||||||
let version = middle (words verline !! 1)
|
return $ middle (words verline !! 1)
|
||||||
|
|
||||||
-- Replace Version field in cabal file, so I don't have to maintain
|
|
||||||
-- the version there too.
|
|
||||||
cabal <- readFile cabalfile
|
|
||||||
writeFile tmpcabalfile $ unlines $ map (setversion version) $ lines cabal
|
|
||||||
renameFile tmpcabalfile cabalfile
|
|
||||||
|
|
||||||
return $ Config "packageversion" (StringConfig version)
|
|
||||||
where
|
where
|
||||||
middle s = drop 1 $ take (length s - 1) s
|
middle s = drop 1 $ take (length s - 1) s
|
||||||
|
|
||||||
|
{- Set up cabal file with version. -}
|
||||||
|
cabalSetup :: IO ()
|
||||||
|
cabalSetup = do
|
||||||
|
version <- getVersionString
|
||||||
|
(_, filelist) <- pipeLinesFrom "find" (words ". -name .git -prune -o -name dist -prune -o -not -name *.hi -not -name *.o -not -name configure -not -name *.tmp -type f -print")
|
||||||
|
cabal <- readFile cabalfile
|
||||||
|
writeFile tmpcabalfile $ unlines $
|
||||||
|
map (setfield "Version" version) $
|
||||||
|
map (setfield "Extra-Source-Files" $ join ", " $ sort filelist) $
|
||||||
|
lines cabal
|
||||||
|
renameFile tmpcabalfile cabalfile
|
||||||
|
where
|
||||||
cabalfile = "git-annex.cabal"
|
cabalfile = "git-annex.cabal"
|
||||||
tmpcabalfile = cabalfile++".tmp"
|
tmpcabalfile = cabalfile++".tmp"
|
||||||
setversion version s
|
setfield field value s
|
||||||
| "Version:" `isPrefixOf` s = "Version: " ++ version
|
| fullfield `isPrefixOf` s = fullfield ++ value
|
||||||
| otherwise = s
|
| otherwise = s
|
||||||
|
where
|
||||||
|
fullfield = field ++ ": "
|
||||||
|
|
||||||
setup :: IO ()
|
setup :: IO ()
|
||||||
setup = do
|
setup = do
|
||||||
|
@ -90,3 +104,4 @@ main = do
|
||||||
config <- runTests tests
|
config <- runTests tests
|
||||||
writeSysConfig config
|
writeSysConfig config
|
||||||
cleanup
|
cleanup
|
||||||
|
cabalSetup
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue