Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add configure flags to generated PKGBUILD #26

Open
wants to merge 3 commits into from

1 participant

Magnus Therning
Magnus Therning
Owner

These changes makes sure cabal2arch uses the modified API of archlinux (see the related pull request archhaskell/archlinux#6). They also add a new command line flag so configure flags can be passed in at the call (only when converting one Cabal file though).

I thought this would warrant a pull request since it modifies the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 13 deletions.
  1. +15 −11 Main.hs
  2. +2 −2 cabal2arch.cabal
26 Main.hs
View
@@ -17,7 +17,7 @@
-- rather than makedepends
import Distribution.PackageDescription.Parse
-import Distribution.PackageDescription (GenericPackageDescription)
+import Distribution.PackageDescription (GenericPackageDescription, FlagName(..))
import Distribution.Simple.Utils hiding (die)
import Distribution.Verbosity
import Distribution.Text
@@ -50,7 +50,7 @@ import System.Console.CmdArgs
import Cabal2Arch.Util
data CmdLnArgs
- = CmdLnConvertOne { argCabalFile :: String, argCreateTar :: Bool, argDataFiles :: String }
+ = CmdLnConvertOne { argCabalFile :: String, argCreateTar :: Bool, argDataFiles :: String, argFlags :: [String] }
| CmdLnConvertMany { argPkgList :: FilePath, argTarBall :: FilePath, argRepo :: FilePath, argDataFiles :: String }
deriving (Data, Typeable)
@@ -59,6 +59,7 @@ cmdLnConvertOne = CmdLnConvertOne
{ argCabalFile = "" &= argPos 0 &= typ "FILE|DIR|URL"
, argCreateTar = False &= name "tar" &= explicit &= help "Create a tar-ball for the source package."
, argDataFiles = "" &= name "sysinfo" &= typDir &= explicit &= help "Use custom system information files."
+ , argFlags = [] &= name "flag" &= explicit &= typ "FLAG" &= help "Build flag to pass through to the PKGBUILD. Can be specified many times."
} &= auto &= name "conv" &= help "Convert a single CABAL file."
cmdLnConvertMany :: CmdLnArgs
@@ -84,7 +85,7 @@ main :: IO ()
main = cmdArgs cmdLnArgs >>= subCmd
subCmd :: CmdLnArgs -> IO ()
-subCmd (CmdLnConvertOne cabalLoc createTar dataFiles) =
+subCmd (CmdLnConvertOne cabalLoc createTar dataFiles flags) =
CE.bracket
-- We do all our work in a temp directory
(do _cwd <- getCurrentDirectory
@@ -123,11 +124,14 @@ subCmd (CmdLnConvertOne cabalLoc createTar dataFiles) =
sysProvides <- case maybeSysProvides of
Left s -> die s
Right sp -> return sp
- let finalcabal = preprocessCabal cabalsrc sysProvides
- finalcabal' <- case finalcabal of
- Nothing -> die "Aborting..."
- Just f -> return f
- let (pkgbuild', hooks) = cabal2pkg finalcabal' sysProvides
+ let parseFlag f = let
+ v = not $ "-" `isPrefixOf` f
+ n = if v then f else (tail f)
+ in (FlagName n, v)
+ let flags' = map parseFlag flags
+ let finalcabal = preprocessCabal cabalsrc flags' sysProvides
+ (finalcabal', cblflags) <- maybe (die "Aborting...") (\ f -> return (f)) finalcabal
+ let (pkgbuild', hooks) = cabal2pkg finalcabal' cblflags sysProvides
apkgbuild' <- getMD5 pkgbuild'
let apkgbuild = apkgbuild' { pkgBuiltWith = Just version }
@@ -193,11 +197,11 @@ subCmd (CmdLnConvertMany pkgListLoc tarballLoc repoLoc dataFiles) = do
exportPackage :: FilePath -> String -> SystemProvides -> GenericPackageDescription -> IO ()
exportPackage dot email sysProvides p = do
- let q = preprocessCabal p sysProvides
+ let q = preprocessCabal p [] sysProvides
case q of
Nothing -> return ()
- Just p' -> do
- let (pkg, script) = cabal2pkg p' sysProvides
+ Just (p', f) -> do
+ let (pkg, script) = cabal2pkg p' f sysProvides
pkgname = arch_pkgname (pkgBody pkg)
pkgbuild <- getMD5 pkg
let apkgbuild = pkgbuild { pkgBuiltWith = Just version }
4 cabal2arch.cabal
View
@@ -1,5 +1,5 @@
name: cabal2arch
-version: 0.7.7
+version: 0.8
homepage: http://github.com/archhaskell/
synopsis: Create Arch Linux packages from Cabal packages.
description: Create Arch Linux packages from Cabal packages.
@@ -30,7 +30,7 @@ executable cabal2arch
Cabal > 1.8,
filepath,
mtl,
- archlinux >= 0.3.6,
+ archlinux ==0.4.*,
cmdargs
other-modules:
Something went wrong with that request. Please try again.