cabal-rpm 0.6.0 → 0.6.1
raw patch · 5 files changed
+46/−36 lines, 5 files
Files
- NEWS +6/−0
- README.md +1/−1
- cabal-rpm.cabal +10/−3
- src/Distribution/Package/Rpm.hs +17/−24
- src/Distribution/Package/Rpm/Main.hs +12/−8
NEWS view
@@ -1,3 +1,9 @@+* 0.6.1 (2012-07-25)+bugfixes:+- fix "cabal-rpm pkg" when other *pkg* packages exist in hackage+- always generate the extra docs list from the pkg src dir!+- now no backslash at end of common_description+ * 0.6.0 (2012-07-24) - updated to work with Cabal >= 1.10 and current cabal2spec style packaging using currently actively used ghc-rpm-macros
README.md view
@@ -38,7 +38,7 @@ $ cabal-rpm somepkg-0.1 -will unpack the (latest) 'something' package from hackage+will unpack the (latest) 'somepkg' package from hackage (if the dir does not exist, otherwise it uses the existing dir) and create a spec file for it.
cabal-rpm.cabal view
@@ -1,14 +1,21 @@ Name: cabal-rpm-Version: 0.6.0+Version: 0.6.1 Synopsis: RPM package creator for Haskell Cabal-based packages-Description: This package generates RPM spec files from Haskell Cabal packages.+Description:+ This package generates RPM spec files from Haskell Cabal packages.+ .+ Recent changes:+ .+ * 0.6.1: fix bugs for "cabal-rpm pkg" unpacking and extra docs+ .+ * 0.6.0: new update and release for Cabal >= 1.10 Homepage: https://github.com/juhp/cabal-rpm Bug-reports: https://github.com/juhp/cabal-rpm/issues License: GPL-3 License-file: COPYING Author: Bryan O'Sullivan <bos@serpentine.com> Maintainer: Jens Petersen <juhp@community.haskell.org>-Copyright: 2007-2008 Bryan O'Sullivan <bos@serpentine.com>+Copyright: 2007-2008 Bryan O'Sullivan <bos@serpentine.com>, 2012 Jens Petersen <petersen@fedoraproject.org> Category: Distribution Build-type: Simple
src/Distribution/Package/Rpm.hs view
@@ -14,14 +14,14 @@ module Distribution.Package.Rpm ( createSpecFile- , rpm+-- , rpm -- , rpmBuild ) where --import Control.Exception (bracket) import Control.Monad (when, unless) import Data.Char (toLower)-import Data.List (intercalate, isPrefixOf, isSuffixOf, nub, sort)+import Data.List (intercalate, isPrefixOf, isSuffixOf, nub) import Data.Maybe (fromMaybe) import Data.Time.Clock (UTCTime, getCurrentTime) import Data.Time.Format (formatTime)@@ -34,7 +34,7 @@ import System.Locale (defaultTimeLocale) --import System.Process (runInteractiveCommand, waitForProcess) ---import System.FilePath ((</>))+import System.FilePath (dropFileName) --(</>) import Distribution.Compiler (CompilerFlavor(..)) import Distribution.Simple.Compiler (Compiler(..)) import Distribution.System (Platform(..), buildOS, buildArch)@@ -56,6 +56,7 @@ -- withLib ) import Distribution.PackageDescription.Configuration (finalizePackageDescription)+import Distribution.PackageDescription.Parse (readPackageDescription) --import Distribution.Verbosity (Verbosity) import Distribution.Version (VersionRange, foldVersionRange') --import Distribution.Simple.Setup (configConfigurationsFlags, emptyConfigFlags)@@ -81,17 +82,6 @@ Left e -> die $ "finalize failed:" +-+ show e Right (pd, _) -> return pd -rpm :: GenericPackageDescription -- ^info from the .cabal file- -> RpmFlags -- ^rpm flags- -> IO ()-rpm genPkgDesc flags = do- pkgDesc <- simplePackageDescription genPkgDesc flags- (_, extraDocs) <- createSpecFile pkgDesc flags- unless (null extraDocs) $ do- putStrLn "Docs not in .cabal packaged:"- mapM_ putStrLn $ sort extraDocs- return ()- -- | Copy a file or directory (recursively, in the latter case) to the -- same name in the target directory. Arguments flipped from the -- conventional order.@@ -162,14 +152,17 @@ rstrip :: (Char -> Bool) -> String -> String rstrip p = reverse . dropWhile p . reverse -createSpecFile :: PackageDescription -- ^info from the .cabal file++createSpecFile :: FilePath -- ^pkg src dir -> RpmFlags -- ^rpm flags- -> IO (FilePath, [FilePath])-createSpecFile pkgDesc flags = do+ -> IO FilePath+createSpecFile cabalPath flags = do+ let verbose = rpmVerbosity flags+ genPkgDesc <- readPackageDescription verbose cabalPath+ pkgDesc <- simplePackageDescription genPkgDesc flags now <- getCurrentTime defRelease <- defaultRelease now let pkg = package pkgDesc- verbose = rpmVerbosity flags PackageName packageName = pkgName pkg name = fromMaybe (if isExec then packageName else "ghc-" ++ packageName) (rpmName flags) pkg_name = if isExec then "%{name}" else "%{pkg_name}"@@ -204,7 +197,7 @@ when synTooLong $ warn verbose "The synopsis for this package spans multiple lines." - let common_description = unlines . map (++ "\\") . lines $+ let common_description = intercalate "\\\n" $ lines $ if (null . description) pkgDesc then if synTooLong then syn@@ -278,7 +271,7 @@ putNewline putNewline - docs <- findDocs pkgDesc+ docs <- findDocs cabalPath pkgDesc when isExec $ do put "%files"@@ -309,11 +302,11 @@ put $ "*" +-+ date +-+ "Fedora Haskell SIG <haskell@lists.fedoraproject.org>" put $ "- spec file generated by cabal-rpm-" ++ showVersion Paths_cabal_rpm.version hClose h- return (specPath, filter (`notElem` extraSrcFiles pkgDesc) docs)+ return specPath -findDocs :: PackageDescription -> IO [FilePath]-findDocs pkgDesc = do- contents <- getDirectoryContents "."+findDocs :: FilePath -> PackageDescription -> IO [FilePath]+findDocs cabalPath pkgDesc = do+ contents <- getDirectoryContents $ dropFileName cabalPath let docs = filter likely contents return $ if null lf then docs
src/Distribution/Package/Rpm/Main.hs view
@@ -13,11 +13,10 @@ module Distribution.Package.Rpm.Main where -import Distribution.PackageDescription.Parse (readPackageDescription)-import Distribution.Package.Rpm (rpm)+import Distribution.Package.Rpm (createSpecFile) import Distribution.Package.Rpm.Setup (RpmFlags (..), parseArgs) import Distribution.Simple.Utils (defaultPackageDesc, findPackageDesc)-import Control.Monad (unless)+import Control.Monad (unless, void) import Data.Char (isDigit) import System.Directory (doesDirectoryExist, doesFileExist) import System.Environment (getArgs)@@ -27,9 +26,8 @@ main :: IO () main = do (opts, args) <- getArgs >>= parseArgs let verbosity = rpmVerbosity opts- descPath <- if null args then defaultPackageDesc verbosity else findCabalFile $ head args- pkgDesc <- readPackageDescription verbosity descPath- rpm pkgDesc opts+ cabalPath <- if null args then defaultPackageDesc verbosity else findCabalFile $ head args+ void $ createSpecFile cabalPath opts findCabalFile :: FilePath -> IO FilePath findCabalFile path = do@@ -50,10 +48,16 @@ tryUnpack pkg = do pkgver <- if isDigit $ last pkg then return pkg else do- pkgs <- readProcess "cabal" ["list", "--simple-output", pkg] []- return $ last $ lines pkgs+ contains_pkg <- readProcess "cabal" ["list", "--simple-output", pkg] []+ let pkgs = filter (startsWith pkg) $ lines contains_pkg+ return $ map (\c -> if c == ' ' then '-' else c) $ last pkgs isdir <- doesDirectoryExist pkgver unless isdir $ do _ <- system $ "cabal unpack " ++ pkgver return () findPackageDesc pkgver++startsWith :: String -> String -> Bool+startsWith pkg mth = take (length pkg') mth == pkg'+ where+ pkg' = pkg ++ " "