Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Some fixes for -Wall (name colisions, redundant imports)

  • Loading branch information...
commit deff8895bd412a68c3b2a83f3aab4dde0a3a6eea 1 parent 3e32a08
Sergei Trofimovich authored

Showing 1 changed file with 19 additions and 18 deletions. Show diff stats Hide diff stats

  1. 37  Merge.hs
37  Merge.hs
... ...
@@ -1,3 +1,4 @@
  1
+{-# OPTIONS -XPatternGuards #-}
1 2
 module Merge where
2 3
 
3 4
 import Control.Monad.Error
@@ -9,7 +10,7 @@ import Data.Version
9 10
 import Distribution.Package
10 11
 import Distribution.Compiler (CompilerId(..), CompilerFlavor(GHC))
11 12
 import Distribution.PackageDescription ( PackageDescription(..)
12  
-                                       , FlagName(..)
  13
+                                       -- , FlagName(..)
13 14
                                        , libBuildInfo
14 15
                                        , buildInfo
15 16
                                        , extraLibs
@@ -26,7 +27,7 @@ import System.Directory ( getCurrentDirectory
26 27
                         )
27 28
 import System.IO
28 29
 import System.Cmd (system)
29  
-import System.FilePath ((</>), splitPath, joinPath, takeFileName)
  30
+import System.FilePath ((</>))
30 31
 import qualified Data.Map as Map
31 32
 
32 33
 import qualified Cabal2Ebuild as E
@@ -62,7 +63,10 @@ import Debug.Trace
62 63
 -- Replace this module once it's included in a cabal release.
63 64
 import CabalDistributionVersion (simplifyVersionRange)
64 65
 
  66
+(<->) :: String -> String -> String
65 67
 a <-> b = a ++ '-':b
  68
+
  69
+(<.>) :: String -> String -> String
66 70
 a <.> b = a ++ '.':b
67 71
 
68 72
 {-
@@ -134,7 +138,6 @@ resolveFullPortageName overlay pn =
134 138
   where
135 139
   ret c = return (Portage.PackageName c pn)
136 140
   mkC = Portage.Category
137  
-  devhaskell = mkC "dev-haskell"
138 141
   -- if any of these categories show up in the result list, the match isn't
139 142
   -- ambiguous, pick the first match in the list
140 143
   priority = [ mkC "dev-haskell"
@@ -204,11 +207,9 @@ merge verbosity repo serverURI args = do
204 207
     info verbosity $ match_text ++ (display . packageInfoId $ avail)
205 208
 
206 209
   let cabal_pkgId = packageInfoId selectedPkg
207  
-      cabal_pkgName = packageName cabal_pkgId
208  
-      pkgVer = packageVersion cabal_pkgId
209 210
       norm_pkgId = Portage.normalizeCabalPackageId cabal_pkgId
210 211
       norm_pkgName = packageName norm_pkgId
211  
-  category <- resolveCategory verbosity overlay norm_pkgName
  212
+  cat <- resolveCategory verbosity overlay norm_pkgName
212 213
 
213 214
   let pkgGenericDesc = packageDescription selectedPkg
214 215
       Right (pkgDesc0, flags) =
@@ -231,9 +232,9 @@ merge verbosity repo serverURI args = do
231 232
            ]
232 233
 
233 234
       packageNameResolver s = do
234  
-        (Portage.PackageName (Portage.Category cat) (Cabal.PackageName pn))
  235
+        (Portage.PackageName (Portage.Category p_cat) (Cabal.PackageName pn))
235 236
           <- resolveFullPortageName portage (Cabal.PackageName s)
236  
-        return $ E.AnyVersionOf (cat </> pn)
  237
+        return $ E.AnyVersionOf (p_cat </> pn)
237 238
 
238 239
   extra <- findCLibs verbosity packageNameResolver pkgDesc
239 240
                     
@@ -252,12 +253,12 @@ merge verbosity repo serverURI args = do
252 253
                . addDeps extra
253 254
                . addDeps (convertDependencies bt)
254 255
                $ E.cabal2ebuild pkgDesc
255  
-      ebuildName = display category </> display norm_pkgId
  256
+      -- ebuildName = display category </> display norm_pkgId
256 257
 
257  
-  mergeEbuild verbosity overlayPath (Portage.unCategory category) ebuild
  258
+  mergeEbuild verbosity overlayPath (Portage.unCategory cat) ebuild
258 259
   fetchAndDigest
259 260
     verbosity
260  
-    (overlayPath </> display category </> display norm_pkgName)
  261
+    (overlayPath </> display cat </> display norm_pkgName)
261 262
     (display cabal_pkgId <.> "tar.gz")
262 263
     (mkUri cabal_pkgId)
263 264
 
@@ -318,10 +319,10 @@ mkUri pid =
318 319
    -- http://hackage.haskell.org/packages/archive/Cabal/1.4.0.2/Cabal-1.4.0.2.tar.gz
319 320
    fromJust $ parseURI $
320 321
     "http://hackage.haskell.org/packages/archive/"
321  
-             </> name </> ver </> name <-> ver <.> "tar.gz"
  322
+             </> p_name </> p_ver </> p_name <-> p_ver <.> "tar.gz"
322 323
   where
323  
-    ver = display (packageVersion pid)
324  
-    name = display (packageName pid)
  324
+    p_ver = display (packageVersion pid)
  325
+    p_name = display (packageName pid)
325 326
 
326 327
 fetchAndDigest :: Verbosity
327 328
                -> FilePath -- ^ directory of ebuild
@@ -331,8 +332,8 @@ fetchAndDigest :: Verbosity
331 332
 fetchAndDigest verbosity ebuildDir tarballName tarballURI =
332 333
   withWorkingDirectory ebuildDir $ do
333 334
     notice verbosity $ "Fetching " ++ show tarballURI
334  
-    response <- simpleHTTP (Request tarballURI GET [] "")
335  
-    case response of
  335
+    e_response <- simpleHTTP (Request tarballURI GET [] "")
  336
+    case e_response of
336 337
       Left err -> throwEx (E.DownloadFailed (show tarballURI) (show err))
337 338
       Right response -> do
338 339
         let tarDestination = "/usr/portage/distfiles" </> tarballName
@@ -351,8 +352,8 @@ withWorkingDirectory newDir action = do
351 352
     (\_ -> action)
352 353
 
353 354
 mergeEbuild :: Verbosity -> FilePath -> String -> EBuild -> IO () 
354  
-mergeEbuild verbosity target category ebuild = do 
355  
-  let edir = target </> category </> name ebuild
  355
+mergeEbuild verbosity target cat ebuild = do 
  356
+  let edir = target </> cat </> name ebuild
356 357
       elocal = name ebuild ++"-"++ version ebuild <.> "ebuild"
357 358
       epath = edir </> elocal
358 359
   createDirectoryIfMissing True edir

0 notes on commit deff889

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