[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:55:17 UTC 2010
The following commit has been merged in the master branch:
commit fc8acf5eba8f6de1ba39a20fc9370c045f1d6b7c
Author: John Goerzen <jgoerzen at complete.org>
Date: Tue Mar 15 02:40:09 2005 +0100
Checkpointing new Debian tools
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.7--patch-204)
diff --git a/ChangeLog b/ChangeLog
index d24207d..f9a6e97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,25 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
#
+2005-03-14 19:40:09 GMT John Goerzen <jgoerzen at complete.org> patch-204
+
+ Summary:
+ Checkpointing new Debian tools
+ Revision:
+ missingh--head--0.7--patch-204
+
+
+ new files:
+ MissingH/Debian.hs MissingH/Debian/.arch-ids/=id
+ MissingH/Debian/ControlParser.hs
+
+ modified files:
+ ChangeLog MissingH.cabal
+
+ new directories:
+ MissingH/Debian MissingH/Debian/.arch-ids
+
+
2005-02-14 22:37:01 GMT John Goerzen <jgoerzen at complete.org> patch-203
Summary:
diff --git a/MissingH.cabal b/MissingH.cabal
index 3b649f8..646d2d6 100644
--- a/MissingH.cabal
+++ b/MissingH.cabal
@@ -43,6 +43,7 @@ Exposed-Modules: MissingH.IO, MissingH.IO.Binary, MissingH.List,
MissingH.IO.HVFS.Utils,
MissingH.IO.HVIO,
MissingH.Email.Parser,
+ MissingH.Debian, MissingH.Debian.ControlParser,
MissingH.Wash.Mail.Email,
MissingH.Wash.Mail.EmailConfig,
MissingH.Wash.Mail.HeaderField,
@@ -72,5 +73,5 @@ Exposed-Modules: MissingH.IO, MissingH.IO.Binary, MissingH.List,
Extensions: ExistentialQuantification, AllowOverlappingInstances,
AllowUndecidableInstances
Build-Depends: haskell-src, network, unix, parsec
-Options-GHC: -O2
+GHC-Options: -O2
diff --git a/MissingH/Debian.hs b/MissingH/Debian.hs
new file mode 100644
index 0000000..9ed8f81
--- /dev/null
+++ b/MissingH/Debian.hs
@@ -0,0 +1,81 @@
+{- arch-tag: Debian Package utilities main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : MissingH.Debian
+ Copyright : Copyright (C) 2004 John Goerzen
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John Goerzen,
+ Maintainer : jgoerzen at complete.org
+ Stability : provisional
+ Portability: portable
+
+This module provides various helpful utilities for dealing with Debian
+files and programs.
+
+Written by John Goerzen, jgoerzen\@complete.org
+-}
+
+module MissingH.Debian (-- * Control or Similar File Utilities
+ ControlFile,
+ -- * Version Number Utilities
+ DebVersion, compareDebVersion
+ )
+where
+import System.Cmd
+import MissingH.Debian.ControlParser
+import MissingH.Cmd
+import MissingH.Str
+import System.IO.Unsafe
+import System.Exit
+
+{- | The type representing the contents of a Debian control file,
+or any control-like file (such as the output from apt-cache show, etc.) -}
+type ControlFile = [(String, String)]
+
+splitComma :: String -> [String]
+splitComma = map strip . split ","
+
+----------------------------------------------------------------------
+-- VERSION NUMBERS
+----------------------------------------------------------------------
+
+{- | The type representing a Debian version number. This type is an instance
+of 'Prelude.Ord', but you can also use 'compareDebVersion' if you prefer. -}
+data DebVersion = DebVersion String
+ deriving (Eq)
+instance Ord DebVersion where
+ compare v1 v2 =
+ {- | This is OK since compareDebVersion should always be the same. -}
+ unsafePerformIO $ compareDebVersion v1 v2
+
+compareDebVersion :: DebVersion -> DebVersion -> IO Ordering
+compareDebVersion (DebVersion v1) (DebVersion v2) =
+ let runit op = do ec <- rawSystem "dpkg" ["--compare-versions", v1, op, v2]
+ case ec of
+ ExitSuccess -> return True
+ ExitFailure _ -> return False
+ in do islt <- runit "lt"
+ if islt
+ then return LT
+ else do isgt <- runit "gt"
+ if isgt
+ then return GT
+ else return EQ
+
diff --git a/MissingH/Threads.hs b/MissingH/Debian/ControlParser.hs
similarity index 65%
copy from MissingH/Threads.hs
copy to MissingH/Debian/ControlParser.hs
index a863960..c5477d8 100644
--- a/MissingH/Threads.hs
+++ b/MissingH/Debian/ControlParser.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Thread utilities main file
+{- arch-tag: Parser for Debian control file
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
- Module : MissingH.Threads
+ Module : MissingH.Debian.ControlParser
Copyright : Copyright (C) 2004 John Goerzen
License : GNU GPL, version 2 or above
@@ -26,21 +26,28 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Stability : provisional
Portability: portable
-This module provides various helpful utilities for dealing with threads.
+This module provides various helpful utilities for dealing with Debian
+files and programs.
Written by John Goerzen, jgoerzen\@complete.org
-}
-module MissingH.Threads(-- * I\/O utilities
- runInThread
- )
-where
+module MissingH.Debian.ControlParser(control)
+ where
+import Text.ParserCombinators.Parsec
-import Control.Concurrent
+eol = (try (string "\r\n"))
+ <|> string "\n" <?> "EOL"
-{- | Takes a IO action and a function. The IO action will be called in a
-separate thread. When it is completed, the specified function is called with
-its result. This is a simple way of doing callbacks. -}
+extline = do char ' '
+ content <- many (noneOf "\r\n")
+ eol
-runInThread :: IO a -> (a -> IO b) -> IO ThreadId
-runInThread action callback = forkIO $ action >>= callback >> return ()
+entry = do key <- many1 (noneOf ":\r\n")
+ char ':'
+ val <- many (noneOf "\r\n")
+ eol
+ exts <- many extline
+ return (key, unlines ([val] ++ exts))
+
+control = many entry
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list