summaryrefslogtreecommitdiff
path: root/configure.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-06-30 15:37:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-06-30 15:37:35 -0400
commitb3ab44f8bbc6a1e253bb81dfe9d6939adcdcba56 (patch)
tree708f59ad289f524562c032556901d4f3412e2a26 /configure.hs
parent20565027cc2f78679a9c54c8350fb7b34e8ff94f (diff)
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.
Diffstat (limited to 'configure.hs')
-rw-r--r--configure.hs33
1 files changed, 24 insertions, 9 deletions
diff --git a/configure.hs b/configure.hs
index 2e39feb16..5f0ff5a1e 100644
--- a/configure.hs
+++ b/configure.hs
@@ -2,6 +2,8 @@
import System.Directory
import Data.List
+import Data.String.Utils
+import System.Cmd.Utils
import TestConfig
@@ -56,24 +58,36 @@ unicodeFilePath = do
{- Pulls package version out of the changelog. -}
getVersion :: Test
getVersion = do
+ version <- getVersionString
+ return $ Config "packageversion" (StringConfig version)
+
+getVersionString :: IO String
+getVersionString = do
changelog <- readFile "CHANGELOG"
let verline = head $ lines changelog
- let version = middle (words verline !! 1)
+ return $ middle (words verline !! 1)
+ where
+ middle s = drop 1 $ take (length s - 1) s
- -- Replace Version field in cabal file, so I don't have to maintain
- -- the version there too.
+{- 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 (setversion version) $ lines cabal
+ writeFile tmpcabalfile $ unlines $
+ map (setfield "Version" version) $
+ map (setfield "Extra-Source-Files" $ join ", " $ sort filelist) $
+ lines cabal
renameFile tmpcabalfile cabalfile
-
- return $ Config "packageversion" (StringConfig version)
where
- middle s = drop 1 $ take (length s - 1) s
cabalfile = "git-annex.cabal"
tmpcabalfile = cabalfile++".tmp"
- setversion version s
- | "Version:" `isPrefixOf` s = "Version: " ++ version
+ setfield field value s
+ | fullfield `isPrefixOf` s = fullfield ++ value
| otherwise = s
+ where
+ fullfield = field ++ ": "
setup :: IO ()
setup = do
@@ -90,3 +104,4 @@ main = do
config <- runTests tests
writeSysConfig config
cleanup
+ cabalSetup