cabal-rpm 0.13.1 → 0.13.2
raw patch · 9 files changed
+150/−99 lines, 9 files
Files
- ChangeLog +7/−0
- TODO +2/−8
- cabal-rpm.cabal +6/−6
- man/cabal-rpm.1 +53/−53
- man/cabal-rpm.1.md +12/−0
- src/Commands/Spec.hs +42/−20
- src/Dependencies.hs +17/−7
- src/Options.hs +6/−2
- src/PackageUtils.hs +5/−3
ChangeLog view
@@ -1,3 +1,10 @@+* 0.13.2 (2019-04-09)+- include ANNOUNCE in docs+- if dependency parallel directory exists, don't check if installed+- fix buildDepends on Cabal-2.4+- new --standalone option for private packages built with cabal-install+- print --{missing,standalone,subpackage} options on spec file header line+ * 0.13.1 (2019-02-27) - update: fix rw git dir detection - fix tarball downloading and copying of revised .cabal file
TODO view
@@ -1,5 +1,3 @@-* add Begin/End comments on Source's, %setup and %files lists to improve update- ## Misc * run "cabal update" if package-version not found @@ -13,18 +11,13 @@ - allow cmd abbreviations? ## Options-- command-based flags and help (optparse-applicative?)+- command-based flags and help (optparse-applicative) ## spec/packaging - filter or blockformat literate code in description ("> ...") - sort devel packages ignoring -devel suffix?-* common subpackage for binlib packages-- include README.*-- handle datafiles more automatically- - clean away READMEs etc ? include version ranges in BRs ? use repoquery for missing testdeps-* --static binary package - support tarballs again * filter dummy pkgs like fail, bytestring-builder and mtl-compat - handle ghc-lzma -> lzma!@@ -48,6 +41,7 @@ - use rpmspec + dnf/yum-builddep if needed to install deps not in .cabal ## install+- check ghc version compatible ## update - warm about new missing deps
cabal-rpm.cabal view
@@ -1,5 +1,5 @@ Name: cabal-rpm-Version: 0.13.1+Version: 0.13.2 Synopsis: RPM packaging tool for Haskell Cabal-based packages Description: This package provides a RPM packaging tool for Haskell Cabal-based packages.@@ -7,11 +7,11 @@ cabal-rpm has commands to generate a RPM spec file and srpm for a package. It can rpmbuild packages, yum/dnf install their dependencies, prep packages, and install them. There are commands to list package dependencies and- missing dependencies. The diff command compares the current spec file- with a freshly generated one, the update command updates the spec file- to latest version from Stackage or Hackage, and the refresh command updates- the spec file to the current cabal-rpm packaging. It also handles Hackage- revisions of packages.+ missing dependencies. The diff command compares the current spec file with+ a freshly generated one, the update command updates the spec file to latest+ version from Stackage or Hackage, and the refresh command updates the spec+ file to the current cabal-rpm packaging. It also handles Hackage revisions of+ packages. Standalone packages can also be packaged built with cabal-install. Homepage: https://github.com/juhp/cabal-rpm Bug-reports: https://github.com/juhp/cabal-rpm/issues License: GPL-3
man/cabal-rpm.1 view
@@ -1,74 +1,74 @@-.\" Automatically generated by Pandoc 2.1.1+.\" Automatically generated by Pandoc 2.7.1 .\"-.TH "CABAL\-RPM" "1" "2013\-01\-21" "" ""+.TH "CABAL-RPM" "1" "2013-01-21" "" "" .hy .SH NAME .PP-cabal\-rpm \- a RPM packaging tool for Haskell Cabal packages+cabal-rpm - a RPM packaging tool for Haskell Cabal packages .SH SYNOPSIS .PP-cabal\-rpm [\f[I]options\f[]] spec [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] local [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] srpm [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] prep [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] builddep [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] install [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] depends [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] requires [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] missingdeps [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] diff [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] update [\f[I]path\-or\-pkg\f[]] cabal\-rpm-[\f[I]options\f[]] refresh [\f[I]path\-or\-pkg\f[]]+cabal-rpm [\f[I]options\f[R]] spec [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] local [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] srpm [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] prep [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] builddep [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] install [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] depends [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] requires [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] missingdeps [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] diff [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] update [\f[I]path-or-pkg\f[R]] cabal-rpm+[\f[I]options\f[R]] refresh [\f[I]path-or-pkg\f[R]] .SH DESCRIPTION .PP-cabal\-rpm generates RPM packages and .spec files from Haskell Cabal+cabal-rpm generates RPM packages and .spec files from Haskell Cabal package. .PP-If no \f[I]path\-or\-pkg\f[] is specified, cabal\-rpm looks for a .spec-or .cabal file in the current directory.-Otherwise, it will look for \f[I]path\-or\-pkg\f[].+If no \f[I]path-or-pkg\f[R] is specified, cabal-rpm looks for a .spec or+\&.cabal file in the current directory.+Otherwise, it will look for \f[I]path-or-pkg\f[R]. If the argument is a directory then it will look there for a .spec or \&.cabal file. If the argument is a path to a .cabal file then it will use it. Otherwise if there is no `/' in the argument and it does not exist then-cabal\-rpm will try to unpack the package and use its .cabal file.-cabal\-rpm uses a temporary directory for unpackaging tarballs or+cabal-rpm will try to unpack the package and use its .cabal file.+cabal-rpm uses a temporary directory for unpackaging tarballs or packages.-cabal\-rpm then parses the .cabal file and uses it to generate a .spec+cabal-rpm then parses the .cabal file and uses it to generate a .spec file that can be built. .PP-If a .spec already exists, cabal\-rpm outputs to .spec.cblrpm instead.+If a .spec already exists, cabal-rpm outputs to .spec.cblrpm instead. .SH OPTIONS .TP-.B \-h, \[en]help+.B -h, \[en]help Show the help text.-.RS-.RE .TP-.B \-b, \[en]binary+.B -b, \[en]binary Force the base package name to be the Hackage package name.-.RS-.RE .TP-.B \-f \f[I]FLAGS\f[], \[en]flags=\f[I]FLAGS\f[]+.B -f \f[I]FLAGS\f[R], \[en]flags=\f[I]FLAGS\f[R] Override one or more Cabal build configuration flags.-.RS-.RE .TP-.B \[en]release=\f[I]RELEASE\f[]+.B \[en]force+overwrite existing spec file+.TP+.B \[en]missing+comment out unavailable BuildRequires deps+.TP+.B \[en]release=\f[I]RELEASE\f[R] Override the release number in the .spec file.-.RS-.RE .TP-.B \-v \f[I]N\f[], \[en]verbose=\f[I]N\f[]-Set verbosity to \f[I]N\f[].-.RS-.RE+.B \[en]standalone+create a standalone package, built using cabal-install .TP-.B \[en]version=\f[I]VERSION\f[]+.B -s \f[I]STREAM\f[R] , \[en]stream=\f[I]STREAM\f[R]+Stackage stream (eg lts-13) or `hackage' used to get package version.+.TP+.B -v \f[I]N\f[R], \[en]verbose=\f[I]N\f[R]+Set verbosity to \f[I]N\f[R].+.TP+.B \[en]version=\f[I]VERSION\f[R] Override the version number in the .spec file.-.RS-.RE .SH EXAMPLES .PP Below CMD can be one of: spec, srpm, prep, local, install, diff,@@ -78,37 +78,37 @@ .IP .nf \f[C]-cabal\-rpm\ CMD-\f[]+cabal-rpm CMD+\f[R] .fi .PP Do CMD for package (directory or package name): .IP .nf \f[C]-cabal\-rpm\ CMD\ [package]-\f[]+cabal-rpm CMD [package]+\f[R] .fi .PP-Do CMD for package\-version (directory or package name):+Do CMD for package-version (directory or package name): .IP .nf \f[C]-cabal\-rpm\ CMD\ [package\-version]-\f[]+cabal-rpm CMD [package-version]+\f[R] .fi .PP Do CMD on a .cabal file: .IP .nf \f[C]-cabal\-rpm\ CMD\ path/to/some.cabal-\f[]+cabal-rpm CMD path/to/some.cabal+\f[R] .fi .SH HISTORY .PP-Cabal\-rpm was originally written by Bryan O'Sullivan in 2007\-2008 and-resurrected by Jens Petersen in 2012 to replace cabal2spec.+Cabal-rpm was originally written by Bryan O\[cq]Sullivan in 2007-2008+and resurrected by Jens Petersen in 2012 to replace cabal2spec. .SH SEE ALSO .PP <http://github.com/juhp/cabal-rpm/>
man/cabal-rpm.1.md view
@@ -44,8 +44,20 @@ -f *FLAGS*, --flags=*FLAGS* : Override one or more Cabal build configuration flags. +--force+: overwrite existing spec file++--missing+: comment out unavailable BuildRequires deps+ --release=*RELEASE* : Override the release number in the .spec file.++--standalone+: create a standalone package, built using cabal-install++-s *STREAM* , --stream=*STREAM*+: Stackage stream (eg lts-13) or 'hackage' used to get package version. -v *N*, --verbose=*N* : Set verbosity to *N*.
src/Commands/Spec.hs view
@@ -33,7 +33,7 @@ #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,0)) #else-import Control.Applicative ((<$>))+--import Control.Applicative ((<$>)) #endif import Data.Char (toUpper)@@ -106,16 +106,17 @@ verbose = rpmVerbosity flags hasExec = hasExes pkgDesc hasLib = hasLibs pkgDesc+ hasLibPkg = hasLib && not standalone dupdocs = docs `intersect` dataFiles pkgDesc datafiles = dataFiles pkgDesc \\ dupdocs-- (pkgname, binlib) <- getPkgName mspec pkgDesc (rpmBinary flags)+ standalone = rpmStandalone flags+ (pkgname, binlib) <- getPkgName mspec pkgDesc (rpmBinary flags || standalone) let pkg_name = if pkgname == name then "%{name}" else "%{pkg_name}" basename | binlib = "%{pkg_name}" | hasExecPkg = name | otherwise = "ghc-%{pkg_name}" specFile = fromMaybe "" mdest </> pkgname <.> "spec"- hasExecPkg = binlib || (hasExec && not hasLib)+ hasExecPkg = binlib || (hasExec && not hasLibPkg) -- run commands before opening file to prevent empty file on error -- maybe shell commands should be in a monad or something (deps, tools, clibs, pkgcfgs) <- packageDependencies (rpmStrict flags) pkgDesc@@ -137,10 +138,12 @@ putNewline = hPutStrLn h "" sectionNewline = putNewline >> putNewline put = hPutStrLn h+ global m v = put $ "%global" +-+ m +-+ v ghcPkg = if binlib then "-n ghc-%{name}" else "" ghcPkgDevel = if binlib then "-n ghc-%{name}-devel" else "devel" put $ "# generated by cabal-rpm-" ++ showVersion Paths_cabal_rpm.version+ +-+ (unwords $ ["--missing" | rpmMissing flags] ++ ["--standalone" | standalone] ++ ["--subpackage" | rpmSubpackage flags]) distro <- maybe detectDistro return (rpmDistribution flags) if distro /= SUSE then put "# https://fedoraproject.org/wiki/Packaging:Haskell"@@ -190,9 +193,18 @@ '\\' -> head cs: filterSymbols (tail cs) _ -> c: filterSymbols cs filterSymbols [] = []++ when standalone $ do+ global "ghc_without_dynamic" "1"+ global "ghc_without_shared" "1"+ global "without_prof" "1"+ global "without_haddock" "1"+ global "debug_package" "%{nil}"+ putNewline+ when hasLib $ do- put $ "%global pkg_name" +-+ name- put "%global pkgver %{pkg_name}-%{version}"+ global "pkg_name" name+ global "pkgver" "%{pkg_name}-%{version}" putNewline let pkgver = if hasLib then "%{pkgver}" else pkg_name ++ "-%{version}"@@ -201,16 +213,16 @@ -- FIXME recursive missingdeps missing <- do subs <- if rpmSubpackage flags then subPackages mspec pkgDesc else return []- miss <- if rpmSubpackage flags || rpmMissing flags then missingPackages pkgDesc else return []+ miss <- if rpmSubpackage flags || rpmMissing flags || standalone then missingPackages pkgDesc else return [] return $ nub (subs ++ miss) subpkgs <- if rpmSubpackage flags then mapM ((getsubpkgMacro flags specFile >=>- \(m,pv) -> put ("%global" +-+ m +-+ pv) >> return ("%{" ++ m ++ "}"))+ \(m,pv) -> global m pv >> return ("%{" ++ m ++ "}")) . stripPkgDevel) missing else return [] let hasSubpkgs = subpkgs /= [] when hasSubpkgs $ do- put $ "%global subpkgs" +-+ unwords subpkgs+ global "subpkgs" $ unwords subpkgs putNewline unless (null testsuiteDeps) $ do@@ -267,12 +279,12 @@ mapM_ (putHdr "BuildRequires") testDeps put "%endif" - let common = binlib && datafiles /= []-+ let common = binlib && datafiles /= [] && not standalone when common $ putHdr "Requires" "%{name}-common = %{version}-%{release}" put "# End cabal-rpm deps"-+ when standalone $+ putHdr "BuildRequires" "cabal-install > 1.18" putNewline put "%description"@@ -294,7 +306,7 @@ let hasModules = hasLib && ((notNull . exposedModules . fromJust . library) pkgDesc || "ghc-haskell-gi-devel" `elem` deps) - when hasLib $ do+ when hasLibPkg $ do when (binlib && hasModules) $ do put $ "%package" +-+ ghcPkg putHdr "Summary" $ "Haskell" +-+ pkg_name +-+ "library"@@ -337,13 +349,13 @@ putNewline when hasSubpkgs $ do- put "%global main_version %{version}"+ global "main_version" "%{version}" putNewline put "%if %{defined ghclibdir}" mapM_ (\p -> put $ "%ghc_lib_subpackage" +-+ p) subpkgs put "%endif" putNewline- put "%global version %{main_version}"+ global "version" "%{main_version}" sectionNewline put "%prep"@@ -359,11 +371,16 @@ put "# Begin cabal-rpm build:" when hasSubpkgs $ put "%ghc_libs_build %{subpkgs}"+ when standalone $ do+ global "cabal" "cabal"+ put "%cabal update"+ put "%cabal sandbox init"+ put "%cabal install --only-dependencies" when (distro == SUSE && rpmConfigurationsFlags flags /= []) $ do let cabalFlags = [ "-f" ++ (if b then "" else "-") ++ unFlagName n | (n, b) <- rpmConfigurationsFlags flags ] put $ "%define cabal_configure_options " ++ unwords cabalFlags- let pkgType = if hasLib then "lib" else "bin"- if hasLib && not hasModules+ let pkgType = if hasLibPkg then "lib" else "bin"+ if hasLibPkg && not hasModules then put $ "%ghc_" ++ pkgType ++ "_build_without_haddock" else put $ "%ghc_" ++ pkgType ++ "_build" put "# End cabal-rpm build"@@ -387,7 +404,7 @@ 1 -> head dupdocs _ -> "{" ++ intercalate "," dupdocs ++ "}" - when (hasLib && not hasModules) $+ when (hasLibPkg && not hasModules) $ put "mv %{buildroot}%{_ghcdocdir}{,-devel}" when common $@@ -395,6 +412,11 @@ put "# End cabal-rpm install" + when (standalone && hasLib) $ do+ -- can be dropped with ghc-rpm-macros-1.9.8+ put "find %{buildroot}%{_libdir} -name 'libHS%{pkgver}-*.so' -delete"+ put "rm -r %{buildroot}%{ghclibdir}"+ sectionNewline unless (null testsuiteDeps) $ do@@ -402,7 +424,7 @@ put "%cabal_test" sectionNewline - when hasLib $ do+ when hasLibPkg $ do put $ "%post" +-+ ghcPkgDevel put "%ghc_pkg_recache" sectionNewline@@ -441,7 +463,7 @@ put "# End cabal-rpm files" sectionNewline - when hasLib $ do+ when hasLibPkg $ do let baseFiles = if binlib then "-f ghc-%{name}.files" else "-f %{name}.files" develFiles = if binlib then "-f ghc-%{name}-devel.files" else "-f %{name}-devel.files" when hasModules $ do
src/Dependencies.hs view
@@ -26,7 +26,8 @@ testsuiteDependencies ) where -import PackageUtils (PackageData(..), packageName, packageManager, repoquery)+import PackageUtils (PackageData(..), packageName, packageManager, removeSuffix,+ repoquery) import SimpleCmd (cmd, cmd_, cmdBool, (+-+)) import SimpleCmd.Rpm (rpmspec) import SysCmd (optionalProgram, rpmEval, trySystem)@@ -52,13 +53,16 @@ ) #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,0,0)+#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,4,0)+import Distribution.Types.ComponentRequestedSpec (defaultComponentRequestedSpec)+#endif import Distribution.Types.LegacyExeDependency (LegacyExeDependency (..)) import Distribution.Types.PkgconfigDependency (PkgconfigDependency (..)) #endif import Distribution.PackageDescription (PackageDescription (..), #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,4,0)- allBuildDepends,+ enabledBuildDepends, #endif allBuildInfo, BuildInfo (..),@@ -68,7 +72,7 @@ #endif ) import System.Directory (doesDirectoryExist, doesFileExist)-import System.FilePath ((<.>))+import System.FilePath ((<.>), (</>)) import System.IO (hPutStrLn, stderr) import System.Posix.User (getEffectiveUserID) @@ -76,15 +80,15 @@ excludedPkgs = flip notElem ["Cabal", "base", "ghc-prim", "integer-gmp"] #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,4,0)+buildDepends :: PackageDescription -> [Dependency]+buildDepends = flip enabledBuildDepends defaultComponentRequestedSpec #else-allBuildDepends :: PackageDescription -> [Dependency]-allBuildDepends = buildDepends #endif -- returns list of deps buildDependencies :: PackageDescription -> String -> [String] buildDependencies pkgDesc self =- let deps = nub $ map depName (allBuildDepends pkgDesc)+ let deps = nub $ map depName (buildDepends pkgDesc) ++ setupDependencies pkgDesc in filter excludedPkgs (delete self deps) @@ -201,7 +205,13 @@ missingPackages pkgDesc = do (deps, tools, clibs, pkgcfgs) <- packageDependencies False pkgDesc pcpkgs <- mapM derefPkg pkgcfgs- filterM notInstalled $ deps ++ ["ghc-Cabal-devel", "ghc-rpm-macros"] ++ tools ++ clibs ++ pcpkgs+ filterM notSrcOrInst $ deps ++ ["ghc-Cabal-devel", "ghc-rpm-macros"] ++ tools ++ clibs ++ pcpkgs+ where+ notSrcOrInst :: String -> IO Bool+ notSrcOrInst pkg = do+ src <- doesDirectoryExist (".." </> removeSuffix "-devel" pkg)+ if src then return False+ else notInstalled pkg notInstalled :: String -> IO Bool notInstalled dep =
src/Options.hs view
@@ -54,10 +54,11 @@ , rpmForce :: Bool , rpmHelp :: Bool , rpmBinary :: Bool+ , rpmStandalone :: Bool , rpmStrict :: Bool , rpmSubpackage :: Bool- , rpmStream :: String , rpmMissing :: Bool+ , rpmStream :: String , rpmRelease :: Maybe String , rpmCompilerId :: Maybe CompilerId , rpmDistribution :: Maybe Distro@@ -72,10 +73,11 @@ , rpmForce = False , rpmHelp = False , rpmBinary = False+ , rpmStandalone = False , rpmStrict = False , rpmSubpackage = False- , rpmStream = defaultStream , rpmMissing = False+ , rpmStream = defaultStream , rpmRelease = Nothing , rpmCompilerId = Nothing , rpmDistribution = Nothing@@ -101,6 +103,8 @@ "Stackage stream (default '" ++ defaultStream ++ "') or 'hackage' used to get package version." , Option "" ["missing"] (NoArg (\x -> x { rpmMissing = True })) "Comment out missing BuildRequires packages."+ , Option "" ["standalone"] (NoArg (\x -> x { rpmStandalone = True }))+ "Create a standalone package that uses cabal-install to build and install." , Option "" ["strict"] (NoArg (\x -> x { rpmStrict = True })) "Fail rather than produce an incomplete spec file." , Option "" ["subpackage"] (NoArg (\x -> x { rpmSubpackage = True }))
src/PackageUtils.hs view
@@ -71,7 +71,7 @@ #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,2,0) import Distribution.Pretty (prettyShow) #else-import qualified Distribution.Version (showVersion)+import qualified Distribution.Version (showVersion, Version) #endif #else import qualified Data.Version (showVersion)@@ -147,8 +147,10 @@ #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,2,0) #else #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,0,0)+prettyShow :: Distribution.Version.Version -> String prettyShow = Distribution.Version.showVersion #else+prettyShow :: Version -> String prettyShow = Data.Version.showVersion #endif #endif@@ -220,8 +222,8 @@ ++ filter (likely licenseNames) contents docfiles = if null licenses then docs else filter (`notElem` licenses) docs return (docfiles, licenses)- where docNames = ["author", "bugs", "changelog", "changes", "contribut",- "example", "news", "readme", "todo"]+ where docNames = ["announce", "author", "bugs", "changelog", "changes",+ "contribut", "example", "news", "readme", "todo"] licenseNames = ["copying", "licence", "license"] likely names name = let lowerName = map toLower name in any (`isPrefixOf` lowerName) names