Permalink
Browse files

archlinux.cabal: re-enable export of getVersionConflicts and getLates…

…tVersions from HackageTranslation

These functions are used in client-code, and I don't know a better place
for them.
  • Loading branch information...
1 parent 7360d14 commit a1136d94b653566359fc9d9c73103e89374a4515 @peti peti committed Apr 19, 2011
Showing with 20 additions and 65 deletions.
  1. +6 −54 Distribution/ArchLinux/HackageTranslation.hs
  2. +14 −11 archlinux.cabal
View
60 Distribution/ArchLinux/HackageTranslation.hs
@@ -6,69 +6,21 @@
-- Maintainer: Arch Haskell Team <arch-haskell@haskell.org>
--
-module Distribution.ArchLinux.HackageTranslation where
+module Distribution.ArchLinux.HackageTranslation
+ ( getVersionConflicts
+ , getLatestVersions
+ )
+ where
+
import Distribution.ArchLinux.CabalTranslation
import Distribution.ArchLinux.SystemProvides
-- Cabal modules
import Distribution.Package
import Distribution.Version
import Distribution.PackageDescription
-import Distribution.PackageDescription.Parse
-- Standard types
-import Distribution.Text
import qualified Data.Map as M
-import qualified Data.Set as Set
import Data.Maybe
--- Read tarballs
-import qualified Codec.Archive.Tar as Tar
-import qualified Data.ByteString.Lazy.Char8 as Bytes
-
---
--- | Reads a tarball and converts it to a list of PackageDescription's
---
-getCabalsFromTarball :: Bytes.ByteString -> [GenericPackageDescription]
-getCabalsFromTarball tarball = Tar.foldEntries insertThis [] (const []) files
- where files = Tar.read tarball
- insertThis file list = case getCabalFromEntry file of
- Nothing -> list
- Just pkg -> pkg:list
-
-getCabalFromEntry :: Tar.Entry -> Maybe GenericPackageDescription
-getCabalFromEntry file = case Tar.entryContent file of
- Tar.NormalFile contents _ -> parse2maybe $ parsePackageDescription $ Bytes.unpack contents
- _ -> Nothing
-
-parse2maybe :: ParseResult a -> Maybe a
-parse2maybe a = case a of
- ParseOk _ pkg -> Just pkg
- _ -> Nothing
-
---
--- | Reads a tarball and get cabal files according to a list
---
-getSpecifiedCabalsFromTarball :: Bytes.ByteString -> [String] -> [GenericPackageDescription]
-getSpecifiedCabalsFromTarball tarball list =
- getSpecifiedCabals (mapMaybe parsePackageIdentifier list) (getCabalsFromTarball tarball)
-
---
--- | Parses a list of lines of the form "package-name 1.2.3.4"
---
-parsePackageIdentifier :: String -> Maybe PackageIdentifier
-parsePackageIdentifier s = case words s of
- [] -> void
- "#":_ -> void
- name:version:_ -> case simpleParse version of
- Nothing -> err
- Just v -> Just $ PackageIdentifier { pkgName = PackageName name, pkgVersion = v }
- _ -> err
- where
- void = Nothing
- err = error ("Malformed package identifier " ++ show s)
-
-getSpecifiedCabals :: [PackageIdentifier] -> [GenericPackageDescription] -> [GenericPackageDescription]
-getSpecifiedCabals list packages = filter wasSpecified packages
- where set = Set.fromList list
- wasSpecified p = Set.member (packageId p) set
--
-- | Check for inconsistencies in version requirements
View
25 archlinux.cabal
@@ -23,15 +23,18 @@ source-repository head
location: git://github.com/archhaskell/archlinux.git
library
- build-depends: base >= 4 && < 6,
- Cabal >= 1.6,
- pretty,
- containers,
- directory,
- filepath
+ ghc-Options: -Wall
+ build-depends:
+ base >= 4 && < 6,
+ Cabal >= 1.6,
+ pretty,
+ containers,
+ directory,
+ filepath
- exposed-modules:
- Distribution.ArchLinux.PkgBuild
- Distribution.ArchLinux.SrcRepo
- Distribution.ArchLinux.CabalTranslation
- Distribution.ArchLinux.SystemProvides
+ exposed-modules:
+ Distribution.ArchLinux.PkgBuild
+ Distribution.ArchLinux.SrcRepo
+ Distribution.ArchLinux.CabalTranslation
+ Distribution.ArchLinux.SystemProvides
+ Distribution.ArchLinux.HackageTranslation

0 comments on commit a1136d9

Please sign in to comment.