Skip to content

Commit

Permalink
add versioncheck.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
wavewave committed Mar 8, 2011
1 parent cf2b5ac commit aa209ab
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion haddock
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cabal install --enable-documentation
cabal haddock --hyperlink-source --hoogle
cabal haddock --hyperlink-source
cabal install
runhaskell versioncheck.hs
53 changes: 53 additions & 0 deletions versioncheck.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import Text.Parsec.Prim
import Text.Parsec.Char
import Text.Parsec.String
import Text.Parsec.Combinator

import System.FilePath ((</>))
import System.Posix.Files

--import System.Directory
--import System.Process

cabalName :: Parser String
cabalName = do
manyTill anyChar (try (string "Name:"))
spaces
many1 (noneOf " \n")

cabalVersion :: Parser String
cabalVersion = do
manyTill anyChar (try (string "Version:"))
spaces
many1 (oneOf "0123456789.")

nameVersion :: Parser (String,String)
nameVersion = do
n <- cabalName
v <- cabalVersion
return (n,v)

main = do
putStrLn "version check"
str <- readFile "MSSMType.cabal"
let Right (name,version) = parse nameVersion "" str
filename = name ++ "-" ++ version
linkbase = "/home/wavewave/nfs/doc/prog"
docbase = "/home/wavewave/nfs/haddock"
linkpath = linkbase </> name
origpath = docbase </> filename

putStrLn $ "ln -s " ++ origpath ++ " " ++ linkpath


b <- fileExist linkpath
if b
then do
putStrLn $ "removing link"
removeLink linkpath
else return ()
{- readProcess "ln" ["-s", origpath, linkpath] "" -}
createSymbolicLink origpath linkpath

return ()

0 comments on commit aa209ab

Please sign in to comment.