packages feed

cabal-rpm 2.0.6 → 2.0.7

raw patch · 13 files changed

+142/−108 lines, 13 filesdep ~simple-cabal

Dependency ranges changed: simple-cabal

Files

ChangeLog view
@@ -1,3 +1,10 @@+# 2.0.7 (2020-10-07)+- spec: setup bash completions for optparse-applicative+- spec: --ignore-missing to ignore deps not yet in hackage+- update: only commit revised if actual changes+- show rpmbuild mode+- spec --standalone updated for cabal-install 3 (f33+)+ # 2.0.6 (2020-06-28) Fedora 33 - spec: use packager's name in %changelog - spec: default package versions to Stackage LTS 16@@ -31,7 +38,7 @@ - support Cabal-3.2 ShortText (hekkaidekapus) - use simple-cmd-args 0.1.6 for working subcommand help - improve handling of update --stream for subpackaging-- default to Stackage LTS 15+- bump latest Stackage to LTS 15 - spec: exclude deps dropped with cabal-tweak-drop-dep  # 2.0.4 (2020-02-27) Fedora 32
− Makefile
@@ -1,21 +0,0 @@-man: man/cabal-rpm.1--man/cabal-rpm.1: man/cabal-rpm.1.md-	pandoc -s -t man $< > $@--stack-all:-	stack --resolver nightly build-	@echo-	stack --resolver lts build-	@echo-	stack --resolver lts-15 build-	@echo-	stack --resolver lts-14 build-	@echo-	stack --resolver lts-13 --stack-yaml stack-lts13.yaml build-	@echo-	stack --resolver lts-12 --stack-yaml stack-lts12.yaml build-	@echo-	stack --resolver lts-11 --stack-yaml stack-lts11.yaml build-	@echo-	stack --resolver lts-10 --stack-yaml stack-lts11.yaml build
TODO view
@@ -1,9 +1,16 @@+- update prints package name twice (due to spec generation?)+- in container/clean install: cblrpm local HsOpenSSL fails:+cabal-rpm: HsOpenSSL-0.11.4.17: getDirectoryContents:openDirStream: does not exist (No such file or directory)++- choose use latest minor PVP release compatible with older lts stream?+- missingdeps should warn about subpackaged deps - installmissing' only installs libs - cblrpm local gi-ibus fails looking for ghc-haskell-gi-overloading-prof   - need unified handling of deps - depsort subpkgs - check for cabal-install - read cabal-tweak-flag for correct deps+- LTS per branch  - spec --force does not work (file busy) - use tmp workspace for duration of executation to reference prep(are) etc
cabal-rpm.cabal view
@@ -1,5 +1,5 @@ Name:                cabal-rpm-Version:             2.0.6+Version:             2.0.7 Synopsis:            RPM packaging tool for Haskell Cabal-based packages Description:     This package provides a RPM packaging tool for Haskell Cabal-based packages.@@ -22,11 +22,12 @@                      2012-2020 Jens Petersen <juhpetersen@gmail.com> Category:            Distribution Build-type:          Simple-Extra-source-files:  ChangeLog Makefile README.md TODO man/cabal-rpm.1.md-Cabal-version:       >=1.10+Extra-doc-files:     ChangeLog README.md TODO+Extra-source-files:  man/cabal-rpm.1.md+Cabal-version:       1.18 Tested-with:         GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3,                      GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4,-                     GHC == 8.6.5, GHC == 8.8.3, GHC == 8.10.1+                     GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.2  source-repository head   type:     git@@ -49,7 +50,7 @@                    filepath,                    optparse-applicative,                    process,-                   simple-cabal >= 0.1.0,+                   simple-cabal >= 0.1.3,                    simple-cmd >= 0.2.0,                    simple-cmd-args >= 0.1.6,                    unix
src/Commands/Diff.hs view
@@ -23,7 +23,6 @@ import FileUtils (mktempdir) import PackageUtils (dropChangelog, editSpecField, getSpecField,                      PackageData (..), prepare)-import SysCmd (die) import Types  #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,0))@@ -32,7 +31,7 @@ #endif import Control.Monad import Distribution.Verbosity (silent)-import SimpleCmd (grep_, pipe)+import SimpleCmd (grep_, error', pipe) import System.Directory (removeDirectoryRecursive) import System.FilePath ((<.>)) import System.Posix.Env (getEnvDefault)@@ -41,11 +40,11 @@ diff flags pkgtype mpvs = do   pkgdata <- prepare flags mpvs True False   case specFilename pkgdata of-    Nothing -> die "No (unique) .spec file in directory."+    Nothing -> error' "No (unique) .spec file in directory."     Just spec -> do       subpkg <- grep_ "%{subpkgs}" spec       tmpdir <- mktempdir-      speccblrpm <- createSpecFile False True silent flags False False pkgtype (if subpkg then Just Nothing else Nothing) (Just tmpdir) mpvs+      speccblrpm <- createSpecFile False True False silent flags False False pkgtype (if subpkg then Just Nothing else Nothing) (Just tmpdir) mpvs       currel <- getSpecField "Release" spec       let suffix = "%{?dist}"       editSpecField "Release" (currel ++ suffix) speccblrpm
src/Commands/Refresh.hs view
@@ -21,11 +21,11 @@ import FileUtils (withTempDirectory) import Header (headerVersion, withSpecHead) import PackageUtils (PackageData (..), cabal_, patchSpec, prepare)-import SysCmd (die, optionalProgram)+import SysCmd (optionalProgram) import Types import Paths_cabal_rpm (version) -import SimpleCmd (cmd, cmd_, grep_)+import SimpleCmd (cmd, cmd_, error', grep_) import SimpleCmd.Git (rwGitDir)  #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,0))@@ -47,7 +47,7 @@ refresh dryrun pkgtype mpvs = do   pkgdata <- prepare [] mpvs True True   case specFilename pkgdata of-    Nothing -> die "No (unique) .spec file in directory."+    Nothing -> error' "No (unique) .spec file in directory."     Just spec -> do       rwGit <- rwGitDir       when rwGit $ do@@ -67,7 +67,7 @@           subpkg <- grep_ "%{subpkgs}" spec           let wasrevised = isJust $ lookup "x-revision" $ customFieldsPD (packageDesc pkgdata)           oldspec <- createOldSpec subpkg cblrpmver spec-          newspec <- createSpecFile True wasrevised silent [] False False spectype (if subpkg then Just Nothing else Nothing) Nothing mpvs+          newspec <- createSpecFile True wasrevised False silent [] False False spectype (if subpkg then Just Nothing else Nothing) Nothing mpvs           patchSpec dryrun Nothing oldspec newspec --          setCurrentDirectory cwd --          when rwGit $
src/Commands/RpmBuild.hs view
@@ -45,7 +45,7 @@     void $ pkgInstallMissing' pkgdata   let pkgDesc = packageDesc pkgdata       mspec = specFilename pkgdata-  specFile <- maybe (createSpecFile False True normal flags False False pkgtype (if subpackage then Just Nothing else Nothing) Nothing mpvs)+  specFile <- maybe (createSpecFile False True False normal flags False False pkgtype (if subpackage then Just Nothing else Nothing) Nothing mpvs)               (\ s -> putStrLn ("Using existing" +-+ s) >> return s)               mspec   let pkgid = package pkgDesc
src/Commands/Spec.hs view
@@ -95,11 +95,12 @@ unUnqualComponentName = id #endif -createSpecFile :: Bool -> Bool -> Verbosity -> Flags -> Bool -> Bool+-- FIXME use datatype for options+createSpecFile :: Bool -> Bool -> Bool -> Verbosity -> Flags -> Bool -> Bool                -> PackageType -> Maybe (Maybe Stream) -> Maybe FilePath                -> Maybe PackageVersionSpecifier                -> IO FilePath-createSpecFile keep revise verbose flags testsuite force pkgtype subpkgStream mdest mpvs = do+createSpecFile keep revise ignoreMissing verbose flags testsuite force pkgtype subpkgStream mdest mpvs = do   pkgdata <- prepare flags mpvs revise keep   let mspec = case pkgtype of                 SpecFile f -> Just f@@ -165,7 +166,8 @@   if targetSpecAlreadyExists     then warn verbose $ (if force then "overwriting" else "creating") +-+ outputFile     else do-    let realdir dir = "cblrpm." `isPrefixOf` takeBaseName dir+    -- changed to not+    let realdir = not . ("cblrpm." `isPrefixOf`) . takeBaseName     when (maybe True realdir mdest) $       putStrLn pkgname @@ -204,10 +206,10 @@     warn verbose "this package has no synopsis."   let initialCapital (c:cs) = toUpper c:cs       initialCapital [] = []-  let syn' = if null syn+      syn' = if null syn              then "Haskell" +-+ name +-+ "package"              else (unwords . lines . initialCapital) syn-  let summary = dropWhileEnd (== '.') syn'+      summary = dropWhileEnd (== '.') syn'   when (length ("Summary     : " ++ syn') > 79) $     warn verbose "this package has a long synopsis." @@ -219,7 +221,10 @@   when (null descr) $     warn verbose "this package has no description."   let descLines = (formatParagraphs . initialCapital . filterSymbols . finalPeriod) $ if null descr then syn' else descr-      finalPeriod cs = if last cs == '.' then cs else cs ++ "."+      finalPeriod cs = case last cs of+                         '.' -> cs+                         '\n' -> finalPeriod $ init cs+                         _ -> cs ++ "."       filterSymbols (c:cs) =         if c `notElem` "@\\" then c: filterSymbols cs         else case c of@@ -336,7 +341,7 @@   when (standalone || subpackage) $ do     when standalone $       putHdr "BuildRequires" "cabal-install > 1.18"-    unless (null missingLibs) $ do+    unless (null missingLibs || ignoreMissing) $ do       putStrLn "checking for deps of missing dependencies:"       let deptype = if standalone then Devel else Prof       forM_ missingLibs $ \ pkg -> do@@ -456,49 +461,65 @@   put "# End cabal-rpm setup"   sectionNewline +  let pkgType = if hasLibPkg then "lib" else "bin"+   put "%build"   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"-  let pkgType = if hasLibPkg then "lib" else "bin"-  put $ "%ghc_" ++ pkgType ++ "_build" ++-        if hasLibPkg && not hasModules then "_without_haddock" else []+  if standalone then do+    put "cabal update"+    put "%if 0%{fedora} < 33"+    put "cabal sandbox init"+    put "cabal install"+    put "%endif"+  else do+    when hasSubpkgs $+      put "%ghc_libs_build %{subpkgs}"+    put $ "%ghc_" ++ pkgType ++ "_build" +++          if hasLibPkg && not hasModules then "_without_haddock" else []   put "# End cabal-rpm build"   sectionNewline    put "%install"   put "# Begin cabal-rpm install"-  when hasSubpkgs $-    put "%ghc_libs_install %{subpkgs}"-  put $ "%ghc_" ++ pkgType ++ "_install"+  if standalone then do+    put "mkdir -p %{buildroot}%{_bindir}"+    put "%if 0%{fedora} >= 33"+    put "cabal install --install-method=copy --installdir=%{buildroot}%{_bindir}"+    put "%else"+    put "for i in .cabal-sandbox/bin/*; do"+    put "strip -s -o %{buildroot}%{_bindir}/$(basename $i) $i"+    put "done"+    put "%endif"+  else do+    when hasSubpkgs $+      put "%ghc_libs_install %{subpkgs}"+    put $ "%ghc_" ++ pkgType ++ "_install" -  when hasSubpkgs $-    put $ "%ghc_fix_rpath" +-+ pkgver+    when hasSubpkgs $+      put $ "%ghc_fix_rpath" +-+ pkgver -  unless (null dupdocs) $ do-    putNewline-    warn verbose $ "doc files found in datadir:" +-+ unwords dupdocs-    put $ "rm %{buildroot}%{_datadir}" </> pkgver </>-      case length dupdocs of-         1 -> head dupdocs-         _ -> "{" ++ intercalate "," dupdocs ++ "}"+    unless (null dupdocs) $ do+      putNewline+      warn verbose $ "doc files found in datadir:" +-+ unwords dupdocs+      put $ "rm %{buildroot}%{_datadir}" </> pkgver </>+        case length dupdocs of+           1 -> head dupdocs+           _ -> "{" ++ intercalate "," dupdocs ++ "}" -  when (hasLibPkg && not hasModules) $-    put "mv %{buildroot}%{_ghcdocdir}{,-devel}"+    when (hasLibPkg && not hasModules) $+      put "mv %{buildroot}%{_ghcdocdir}{,-devel}" -  when common $-    put "mv %{buildroot}%{_ghcdocdir}{,-common}"+    when common $+      put "mv %{buildroot}%{_ghcdocdir}{,-common}" -  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}"+  let execs = sort $ map exeName $ filter isBuildable $ executables pkgDesc+      execNaming p = let pn = unUnqualComponentName p in+                     if pn == name then "%{name}" else pn +  when (hasExecPkg && mkPackageName "optparse-applicative" `elem` buildDeps pkgdeps) $ do+    put "mkdir -p %{buildroot}%{_datadir}/bash-completion/completions/"+    mapM_ (\ ex -> let exn = execNaming ex in put ("%{buildroot}%{_bindir}" </> exn ++ " --bash-completion-script " ++ exn ++ " > %{buildroot}%{_datadir}/bash-completion/completions" </> exn)) execs+   put "# End cabal-rpm install"   sectionNewline @@ -508,7 +529,6 @@     sectionNewline    let license_macro = "%license"-  let execs = sort $ map exeName $ filter isBuildable $ executables pkgDesc    when hasExecPkg $ do     put "%files"@@ -519,9 +539,10 @@       mapM_ (\ l -> put $ license_macro +-+ l) licensefiles       unless (null docs) $         put $ "%doc" +-+ unwords docs-    mapM_ ((\ p -> put $ "%{_bindir}" </> (if p == name then "%{name}" else p)) . unUnqualComponentName) execs+    mapM_ (put . ("%{_bindir}" </>) . execNaming) execs     unless (common || null datafiles) $       put $ "%{_datadir}" </> pkgver+    when (hasExecPkg && mkPackageName "optparse-applicative" `elem` buildDeps pkgdeps) $ mapM_ (put . ("%{_datadir}/bash-completion/completions" </>) . execNaming) execs     put "# End cabal-rpm files"     sectionNewline @@ -578,10 +599,10 @@   hClose h   return outputFile -createSpecFile_ :: Verbosity -> Flags -> Bool -> Bool -> PackageType+createSpecFile_ :: Bool -> Verbosity -> Flags -> Bool -> Bool -> PackageType                 -> Maybe (Maybe Stream) -> Maybe PackageVersionSpecifier -> IO ()-createSpecFile_ verbose flags testsuite force pkgtype subpkgStream mpvs =-  void (createSpecFile True True verbose flags testsuite force pkgtype subpkgStream Nothing mpvs)+createSpecFile_ ignoreMissing verbose flags testsuite force pkgtype subpkgStream mpvs =+  void (createSpecFile True True ignoreMissing verbose flags testsuite force pkgtype subpkgStream Nothing mpvs)  isBuildable :: Executable -> Bool isBuildable exe = buildable $ buildInfo exe
src/Commands/Update.hs view
@@ -24,18 +24,24 @@                      editSpecField, getRevisedCabal, getSpecField, latestPackage,                      patchSpec, pkgSpecPkgData, rpmbuild) import Stackage (defaultLTS)-import SysCmd (die) import Types  import SimpleCabal (customFieldsPD, package,                     PackageIdentifier (..), showVersion)-import SimpleCmd (cmd_, error', grep_, shell_, (+-+))-import SimpleCmd.Git (grepGitConfig, rwGitDir)+import SimpleCmd+#if MIN_VERSION_simple_cmd(0,2,1)+  hiding (ifM,whenM)+#endif+import SimpleCmd.Git (grepGitConfig, rwGitDir,+#if MIN_VERSION_simple_cmd(0,2,2)+                      gitBool+#endif+                     ) #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,0)) #else import Control.Applicative ((<$>)) #endif-import Control.Monad (unless, when)+import Control.Monad.Extra import Data.Maybe (isJust) import Distribution.Text (display) import Distribution.Verbosity (silent)@@ -43,11 +49,13 @@                          removeDirectoryRecursive, renameFile) import System.FilePath ((<.>)) +-- FIXME --dryrun+-- FIXME check kerberos before new-sources update :: Maybe PackageVersionSpecifier -> IO () update mpvs = do   pkgdata <- pkgSpecPkgData [] (pvsPackage =<< mpvs) True True   case specFilename pkgdata of-    Nothing -> die "No (unique) .spec file in directory."+    Nothing -> error' "No (unique) .spec file in directory."     Just spec -> do       let pkgDesc = packageDesc pkgdata           oldPkgId = package pkgDesc@@ -131,6 +139,7 @@               cmd_ "git" ["commit", "-a", "-m", "update to" +-+ showVersion newver]               else               when newrev $+              whenM (gitBool "diff-index" ["--quiet", "HEAD"]) $               cmd_ "git" ["commit", "-a", "-m", "revised .cabal file"]           rpmbuild True Prep spec   where@@ -141,4 +150,13 @@       direxists <- doesDirectoryExist dir       when direxists $ removeDirectoryRecursive dir       createDirectoryIfMissing True dir-      createSpecFile True revise silent [] False False (SpecFile spec) subpkgStream (Just dir) (streamPkgToPVS Nothing (Just pkgid))+      createSpecFile True revise False silent [] False False (SpecFile spec) subpkgStream (Just dir) (streamPkgToPVS Nothing (Just pkgid))++#if !MIN_VERSION_simple_cmd(0,2,2)+-- | @gitBool c args@ runs git command and return result+gitBool :: String -- ^ git command+        -> [String] -- ^ arguments+        -> IO Bool -- ^ result+gitBool c args =+  cmdBool "git" (c:args)+#endif
src/Dependencies.hs view
@@ -39,8 +39,8 @@ import PackageUtils (PackageData(..), prepare, repoquery, rpmInstall) import Types -import SimpleCabal (buildDependencies, mkPackageName,-                    exeDepName,+import SimpleCabal (allLibraries, buildDependencies, mkPackageName,+                    exeDepName, Library(..),                     PackageDescription (package),                     PackageName, pkgcfgDepName, pkgName,                     setupDependencies, testsuiteDependencies,@@ -49,8 +49,7 @@ import SimpleCmd (cmd, cmdBool, removePrefix, removeSuffix, warning, (+-+)) import SimpleCmd.Rpm (rpmspec) -#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,0))-#else+#if !MIN_VERSION_base(4,8,0) import Control.Applicative ((<$>)) #endif import Control.Monad (filterM, when, unless)@@ -59,10 +58,12 @@ import Data.Maybe (catMaybes, fromJust, isNothing, mapMaybe)  import Distribution.Text (display)-import Distribution.PackageDescription (allLibraries, buildInfo, BuildInfo (..),-                                        executables, hasLibs, Library(..),+import Distribution.PackageDescription (buildInfo, BuildInfo (..),+                                        executables, hasLibs,                                         testBuildInfo, testSuites)+#if MIN_VERSION_Cabal(2,0,0) import Distribution.Types.ExeDependency (ExeDependency(..))+#endif import System.Directory (doesDirectoryExist, doesFileExist) import System.FilePath ((<.>), (</>)) @@ -164,9 +165,14 @@   where     tests = map testBuildInfo $ testSuites pkgDesc     testTools = map exeDepName $ concatMap buildTools tests-    testToolDeps = map prettyShow $ concatMap buildToolDepends tests+    testToolDeps =+#if MIN_VERSION_Cabal(2,0,0)+      map prettyShow $ concatMap buildToolDepends tests      prettyShow (ExeDependency pn _ _) = unPackageName pn+#else+      []+#endif  missingPackages :: PackageDescription -> IO [RpmPackage] missingPackages pkgDesc = do
src/Main.hs view
@@ -55,7 +55,7 @@     "RPM package tool for Haskell Stackage/Hackage packages" $     subcommands     [ Subcommand "spec" "Generate a spec file" $-      createSpecFile_ <$> quietOpt <*> flags <*> testsuite <*> force <*> pkgtype <*> fmap toSubpkgStream subpackage <*> pkgVerSpecifier+      createSpecFile_ <$> ignoreMissing <*> quietOpt <*> flags <*> testsuite <*> force <*> pkgtype <*> fmap toSubpkgStream subpackage <*> pkgVerSpecifier     , Subcommand "srpm" "Generate an srpm" $       rpmBuild_ Source <$> verboseRpmbuild <*> flags <*> pkgtype <*> subpackage <*> pkgVerSpecifier     , Subcommand "prep" "Unpack source" $@@ -103,6 +103,8 @@     force = switchWith 'F' "force" "Force overwriting existing of any .spec file"      dryrun = switchWith 'n' "dry-run" "Just show patch"++    ignoreMissing = switchWith 'm' "ignore-missing" "Don't check for deps of missing deps"      -- quietOpt :: Parser Verbosity     quietOpt = flagWith normal silent 'q' "quiet" "Silence Cabal"
src/PackageUtils.hs view
@@ -195,8 +195,14 @@         renameFile file $ dir </> display pkgid <.> "cabal"       return revised -data RpmStage = Binary | Source | Prep deriving Eq+data RpmStage = Binary | Source | Prep+  deriving Eq +instance Show RpmStage where+  show Binary = "binary"+  show Source = "source"+  show Prep = "prep"+ rpmbuild :: Bool -> RpmStage -> FilePath -> IO () rpmbuild quiet mode spec = do   let rpmCmd = case mode of@@ -213,7 +219,7 @@   if not quiet then     cmd_ "rpmbuild" args     else do-    putStr "Running rpmbuild: "+    putStr $ "rpmbuild" +-+ show mode ++ ": " #if MIN_VERSION_simple_cmd(0,2,2)     -- may hang for build     (ret, out) <- cmdStderrToStdout "rpmbuild" args
src/SysCmd.hs view
@@ -17,7 +17,6 @@ -- (at your option) any later version.  module SysCmd (-  die,   optionalProgram,   requireProgram,   rpmEval@@ -30,25 +29,14 @@ import Control.Monad import Data.Maybe       (isJust, isNothing) -#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,0,0)-import Distribution.Simple.Utils (dieNoVerbosity)-#else-import Distribution.Simple.Utils (die)-#endif- import System.Directory (findExecutable) -import SimpleCmd (cmd)--#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,0,0)-die :: String -> IO a-die = dieNoVerbosity-#endif+import SimpleCmd (cmd, error')  requireProgram :: String -> IO () requireProgram c = do   mavail <- findExecutable c-  when (isNothing mavail) $ die (c ++ ": command not found")+  when (isNothing mavail) $ error' (c ++ ": command not found")  optionalProgram :: String -> IO Bool optionalProgram c =