packages feed

cabal-rpm 0.13 → 0.13.1

raw patch · 6 files changed

+51/−49 lines, 6 filesdep ~simple-cmd

Dependency ranges changed: simple-cmd

Files

ChangeLog view
@@ -1,3 +1,11 @@+* 0.13.1 (2019-02-27)+- update: fix rw git dir detection+- fix tarball downloading and copying of revised .cabal file+- show output (errors) when prepping source and prep in working dir+- include BUGS and CONTRIBUTING as docs+- need chrpath for subpackages+- move license dir to any common subpackage+ * 0.13 (2019-02-18) - improve license and doc filtering - backup revised .cabal files
cabal-rpm.cabal view
@@ -1,5 +1,5 @@ Name:                cabal-rpm-Version:             0.13+Version:             0.13.1 Synopsis:            RPM packaging tool for Haskell Cabal-based packages Description:     This package provides a RPM packaging tool for Haskell Cabal-based packages.@@ -47,7 +47,7 @@                    directory,                    filepath,                    process,-                   simple-cmd >= 0.1.1,+                   simple-cmd >= 0.1.3,                    unix     if flag(old-locale)        Build-Depends: old-locale >= 1 && < 1.1,
src/Commands/RpmBuild.hs view
@@ -60,7 +60,7 @@   unless (stage == BuildDep) $ do     let version = packageVersion pkg     bringTarball (name ++ "-" ++ version) True specFile-    rpmbuild stage False Nothing specFile+    rpmbuild stage specFile    return specFile 
src/Commands/Spec.hs view
@@ -254,7 +254,7 @@   putHdr "BuildRequires" "ghc-Cabal-devel"   putHdr "BuildRequires" $ "ghc-rpm-macros" ++ (if hasSubpkgs then "-extra" else "") -  let alldeps = sort $ deps ++ tools ++ clibs ++ pkgcfgs+  let alldeps = sort $ deps ++ tools ++ clibs ++ pkgcfgs ++ ["chrpath" | hasSubpkgs]   let testDeps = sort $ testsuiteDeps \\ deps   unless (null $ alldeps ++ testDeps) $ do     mapM_ (\ d -> (if d `elem` missing then putHdrComment else putHdr) "BuildRequires" d) alldeps@@ -270,7 +270,7 @@   let common = binlib && datafiles /= []    when common $-    putHdr "Requires" $ "%{name}-common = %{version}-%{release}"+    putHdr "Requires" "%{name}-common = %{version}-%{release}"   put "# End cabal-rpm deps"    putNewline@@ -286,7 +286,7 @@     putHdr "Summary" $ pkg_name +-+ "common files"     putHdr "BuildArch" "noarch"     putNewline-    put $ "%description common"+    put "%description common"     put $ wrapGenDesc $ "This package provides the" +-+ pkg_name +-+ "common data files."     putNewline @@ -303,7 +303,7 @@         RHEL5 -> putHdr "Group" "System Environment/Libraries"         _ -> return ()       when common $-        putHdr "Requires" $ "%{name}-common = %{version}-%{release}"+        putHdr "Requires" "%{name}-common = %{version}-%{release}"       putNewline       put $ "%description" +-+ ghcPkg       put $ wrapGenDesc $ "This package provides the Haskell" +-+ pkg_name +-+ "shared library."@@ -375,6 +375,9 @@     put "%ghc_libs_install %{subpkgs}"   put $ "%ghc_" ++ pkgType ++ "_install" +  when hasSubpkgs $+    put $ "%ghc_fix_rpath" +-+ pkgver+   unless (null dupdocs) $ do     putNewline     putStrLn $ "Warning: doc files found in datadir:" +-+ unwords dupdocs@@ -387,6 +390,9 @@   when (hasLib && not hasModules) $     put "mv %{buildroot}%{_ghcdocdir}{,-devel}" +  when common $+    put "mv %{buildroot}%{_ghcdocdir}{,-common}"+   put "# End cabal-rpm install"    sectionNewline@@ -422,11 +428,10 @@     unless (common || null datafiles) $       put $ "%{_datadir}" </> pkgver     put "# End cabal-rpm files"-     sectionNewline    when common $ do-    put $ "%files common"+    put "%files common"     put "# Begin cabal-rpm files:"     when (distro /= Fedora) $ put "%defattr(-,root,root,-)"     mapM_ (\ l -> put $ license_macro +-+ l) licensefiles
src/Commands/Update.hs view
@@ -61,9 +61,7 @@         getRevisedCabal latest         unless updated $           putStrLn "Package is already latest version."-        when (not revised || updated) $ do-          when updated $-            bringTarball latest False spec+        when (not revised || updated) $           withTempDirectory $ \cwd -> do             let specfile = cwd </> spec             subpkg <- grep_ "%{subpkgs}" specfile@@ -87,12 +85,13 @@                 unless subpkg $                   editSpecField "Release" ("0" ++ suffix) specfile                 cmd_ "rpmdev-bumpspec" ["-c", "update to" +-+ newver, specfile]+              setCurrentDirectory cwd               rwGit <- rwGitDir+              when (rwGit && subpkg) $ do+                cmd_ "cp" ["-p", "sources", "sources.cblrpm"]+                cmd_ "sed" ["-i", "/" ++ current <.> "tar.gz" ++ "/d", "sources.cblrpm"]+              bringTarball latest False spec               when rwGit $ do-                setCurrentDirectory cwd-                when subpkg $ do-                  cmd_ "cp" ["-p", "sources", "sources.cblrpm"]-                  cmd_ "sed" ["-i", "/" ++ current <.> "tar.gz" ++ "/d", "sources.cblrpm"]                 cmd_ "fedpkg" ["new-sources", latest <.> "tar.gz"]                 when subpkg $ do                   shell_ $ "cat sources >>" +-+ "sources.cblrpm"
src/PackageUtils.hs view
@@ -42,7 +42,7 @@ import FileUtils (filesWithExtension, fileWithExtension,                   getDirectoryContents_, mktempdir, withTempDirectory) import Options (RpmFlags (..))-import SimpleCmd (cmd, cmd_, cmdIgnoreErr, cmdLines, cmdSilent, grep_, sudo,+import SimpleCmd (cmd, cmd_, cmdIgnoreErr, cmdLines, grep_, sudo,                   (+-+)) import SimpleCmd.Git (isGitDir, grepGitConfig) import SysCmd (die, optionalProgram, requireProgram, rpmEval)@@ -56,7 +56,7 @@  import Data.Char (isDigit, toLower) import Data.List (groupBy, isPrefixOf, isSuffixOf, nub, sort, stripPrefix)-import Data.Maybe (fromJust, fromMaybe, isJust)+import Data.Maybe (fromJust, fromMaybe) import Data.Time.Clock (diffUTCTime, getCurrentTime) import Data.Version ( #if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,0))@@ -139,7 +139,8 @@                          removeDirectoryRecursive, renameFile,                          setCurrentDirectory) import System.Environment (getEnv)-import System.FilePath ((</>), (<.>), dropFileName, takeBaseName, takeFileName)+import System.FilePath ((</>), (<.>), dropFileName, takeBaseName, takeExtensions,+                        takeFileName) import System.Posix.Files (accessTime, fileMode, getFileStatus,                            modificationTime, setFileMode) @@ -152,10 +153,6 @@ #endif #endif --- returns path to .cabal file and possibly tmpdir to be removed---findCabalFile :: Verbosity -> FilePath -> IO (FilePath, Maybe FilePath)---findCabalFile vb path = do- stripVersion :: String -> String stripVersion n | '-' `notElem` n = n stripVersion nv = if hasVer then reverse emaN else nv@@ -223,7 +220,7 @@         ++ filter (likely licenseNames) contents       docfiles = if null licenses then docs else filter (`notElem` licenses) docs   return (docfiles, licenses)-  where docNames = ["author", "changelog", "changes", "contributors",+  where docNames = ["author", "bugs", "changelog", "changes", "contribut",                     "example", "news", "readme", "todo"]         licenseNames = ["copying", "licence", "license"]         likely names name = let lowerName = map toLower name@@ -237,26 +234,21 @@ tryFindPackageDesc = findPackageDesc #endif -cabalFromSpec :: FilePath -> Bool -> IO (FilePath, Maybe FilePath)+cabalFromSpec :: FilePath -> Bool -> IO FilePath cabalFromSpec specFile revise = do   -- no rpmspec command in RHEL 5 and 6   namever <- removePrefix "ghc-" . head <$> cmdLines "rpm" ["-q", "--qf", "%{name}-%{version}\n", "--specfile", specFile]+  bringTarball namever revise specFile   dExists <- doesDirectoryExist namever   if dExists     then do     specTime <- modificationTime <$> getFileStatus specFile     dirTime <- accessTime <$> getFileStatus namever-    when (specTime > dirTime) $ do-      bringTarball namever revise specFile-      rpmbuild Prep True Nothing specFile-    cabalfile <- tryFindPackageDesc namever-    return (cabalfile, Nothing)-    else do-    tmpdir <- mktempdir-    bringTarball namever revise specFile-    rpmbuild Prep True (Just tmpdir) specFile-    cabalfile <- tryFindPackageDesc $ tmpdir </> namever-    return (cabalfile, Just tmpdir)+    when (specTime > dirTime) $+      rpmbuild Prep specFile+    else+    rpmbuild Prep specFile+  tryFindPackageDesc namever  bringTarball :: FilePath -> Bool -> FilePath -> IO () bringTarball nv revise spec = do@@ -274,8 +266,8 @@         cmd_ "fedpkg" ["sources"]     when havespec $       createDirectoryIfMissing True srcdir-    haveLocalCabal <- doesFileExist $ srcdir </> nv <.> "cabal"     mapM_ (copyTarball False srcdir) sources+    haveLocalCabal <- doesFileExist $ srcdir </> nv <.> "cabal"     when (not haveLocalCabal && revise) $       getRevisedCabal nv     allExist' <- and <$> mapM (doesFileExist . (srcdir </>)) sources@@ -292,7 +284,8 @@     else (takeFileName . last . words) field    copyTarball :: Bool -> FilePath -> FilePath -> IO ()-  copyTarball ranFetch dir file = do+  copyTarball ranFetch dir file =+   when (takeExtensions file == ".tar.gz") $ do     let dest = dir </> file     already <- doesFileExist dest     unless already $ do@@ -324,8 +317,9 @@ getSourceDir :: IO FilePath getSourceDir = do     git <- isGitDir "."-    cwd <- getCurrentDirectory-    if git then return cwd else fromJust <$> rpmEval "%{_sourcedir}"+    if git+      then getCurrentDirectory+      else fromJust <$> rpmEval "%{_sourcedir}"  getRevisedCabal :: String -> IO () getRevisedCabal nv = do@@ -349,8 +343,8 @@  data RpmStage = Binary | Source | Prep | BuildDep deriving Eq -rpmbuild :: RpmStage -> Bool -> Maybe FilePath -> FilePath -> IO ()-rpmbuild mode quiet moutdir spec = do+rpmbuild :: RpmStage -> FilePath -> IO ()+rpmbuild mode spec = do   let rpmCmd = case mode of         Binary -> "a"         Source -> "s"@@ -360,14 +354,11 @@   gitDir <- isGitDir "."   let rpmdirs_override =         [ "--define="++ mcr +-+ cwd |-          mcr <- ["_rpmdir", "_srcrpmdir", "_sourcedir"], gitDir]-  command "rpmbuild" $ ["-b" ++ rpmCmd] +++          mcr <- ["_builddir", "_rpmdir", "_srcrpmdir", "_sourcedir"], gitDir]+  cmd_ "rpmbuild" $ ["-b" ++ rpmCmd] ++     ["--nodeps" | mode == Prep] ++-    ["--define=_builddir" +-+ maybe cwd (cwd </>) moutdir | isJust moutdir] ++     rpmdirs_override ++     [spec]-  where-    command = if quiet then cmdSilent else cmd_  removePrefix :: String -> String-> String removePrefix pref str = fromMaybe str (stripPrefix pref str)@@ -529,9 +520,8 @@   mspec <- checkForSpecFile mpkg   case mspec of     Just spec -> do-      (cabalfile, mtmp) <- cabalFromSpec spec revise+      cabalfile <- cabalFromSpec spec revise       (pkgDesc, docs, licenses) <- simplePackageDescription cabalfile flags-      maybe (return ()) removeDirectoryRecursive mtmp       return $ PackageData mspec docs licenses pkgDesc     Nothing ->       case mpkgver of