Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement packageIdToFilepath

  • Loading branch information...
commit 2ba26223bbf42ee297c3d97bae5cbcc76e91ec4a 1 parent 570f302
@kolmodin kolmodin authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 Portage/PackageId.hs
View
15 Portage/PackageId.hs
@@ -10,7 +10,8 @@ module Portage.PackageId (
toCabalPackageId,
parseFriendlyPackage,
normalizeCabalPackageName,
- normalizeCabalPackageId
+ normalizeCabalPackageId,
+ packageIdToFilePath
) where
import qualified Distribution.Package as Cabal
@@ -23,8 +24,9 @@ import qualified Portage.Version as Portage
import qualified Text.PrettyPrint as Disp
import Text.PrettyPrint ((<>))
import qualified Data.Char as Char (isAlphaNum, isSpace, toLower)
--- import qualified Data.Char as Char (isDigit)
--- import Data.List (intersperse)
+
+import Distribution.Text(display)
+import System.FilePath ( (</>) )
newtype Category = Category { unCategory :: String }
deriving (Eq, Ord, Show, Read)
@@ -49,6 +51,13 @@ instance Text PN where
-- ambiguity in identifiers like foo-1 (the 1 is the version number).
-}
+packageIdToFilePath :: PackageId -> FilePath
+packageIdToFilePath (PackageId (PackageName cat pn) version) =
+ display cat </> display pn </> display pn <-> display version <.> "ebuild"
+ where
+ a <-> b = a ++ '-':b
+ a <.> b = a ++ '.':b
+
mkPackageName :: String -> String -> PackageName
mkPackageName cat package = PackageName (Category cat) (Cabal.PackageName package)
Please sign in to comment.
Something went wrong with that request. Please try again.