Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implement packageIdToFilepath

  • Loading branch information...
commit 2ba26223bbf42ee297c3d97bae5cbcc76e91ec4a 1 parent 570f302
Lennart Kolmodin kolmodin authored

Showing 1 changed file with 12 additions and 3 deletions. Show diff stats Hide diff stats

  1. +12 3 Portage/PackageId.hs
15 Portage/PackageId.hs
@@ -10,7 +10,8 @@ module Portage.PackageId (
10 10 toCabalPackageId,
11 11 parseFriendlyPackage,
12 12 normalizeCabalPackageName,
13   - normalizeCabalPackageId
  13 + normalizeCabalPackageId,
  14 + packageIdToFilePath
14 15 ) where
15 16
16 17 import qualified Distribution.Package as Cabal
@@ -23,8 +24,9 @@ import qualified Portage.Version as Portage
23 24 import qualified Text.PrettyPrint as Disp
24 25 import Text.PrettyPrint ((<>))
25 26 import qualified Data.Char as Char (isAlphaNum, isSpace, toLower)
26   --- import qualified Data.Char as Char (isDigit)
27   --- import Data.List (intersperse)
  27 +
  28 +import Distribution.Text(display)
  29 +import System.FilePath ( (</>) )
28 30
29 31 newtype Category = Category { unCategory :: String }
30 32 deriving (Eq, Ord, Show, Read)
@@ -49,6 +51,13 @@ instance Text PN where
49 51 -- ambiguity in identifiers like foo-1 (the 1 is the version number).
50 52 -}
51 53
  54 +packageIdToFilePath :: PackageId -> FilePath
  55 +packageIdToFilePath (PackageId (PackageName cat pn) version) =
  56 + display cat </> display pn </> display pn <-> display version <.> "ebuild"
  57 + where
  58 + a <-> b = a ++ '-':b
  59 + a <.> b = a ++ '.':b
  60 +
52 61 mkPackageName :: String -> String -> PackageName
53 62 mkPackageName cat package = PackageName (Category cat) (Cabal.PackageName package)
54 63

0 comments on commit 2ba2622

Please sign in to comment.
Something went wrong with that request. Please try again.