cabal-rpm 2.0.1 → 2.0.2
raw patch · 9 files changed
+107/−99 lines, 9 files
Files
- ChangeLog +8/−0
- Makefile +1/−1
- cabal-rpm.cabal +1/−1
- src/Commands/Refresh.hs +3/−3
- src/Commands/RpmBuild.hs +1/−1
- src/Commands/Spec.hs +46/−52
- src/Commands/Update.hs +27/−28
- src/PackageUtils.hs +19/−12
- src/Stackage.hs +1/−1
ChangeLog view
@@ -1,3 +1,11 @@+# 2.0.2 (2020-02-20)+- drop %_devel compat macro+- default stream is now lts-14+- sort deps of subpackages+- metapkgs don't have prof or doc+- fix generation of subpackages for a new package+- update: logic reworked to reduce redundant downloads+ # 2.0.1 (2020-02-06) - quote macros in commented fields - read --subpackage from spec header
Makefile view
@@ -10,7 +10,7 @@ @echo stack --resolver lts-13 --stack-yaml stack-lts13.yaml build @echo-# stack --resolver lts-12 --stack-yaml stack-lts12.yaml build+ stack --resolver lts-12 --stack-yaml stack-lts12.yaml build @echo stack --resolver lts-11 --stack-yaml stack-lts11.yaml build @echo
cabal-rpm.cabal view
@@ -1,5 +1,5 @@ Name: cabal-rpm-Version: 2.0.1+Version: 2.0.2 Synopsis: RPM packaging tool for Haskell Cabal-based packages Description: This package provides a RPM packaging tool for Haskell Cabal-based packages.
src/Commands/Refresh.hs view
@@ -72,10 +72,10 @@ -- cmd_ "git" ["commit", "-a", "-m", "refreshed to cabal-rpm-" ++ showVersion version] where createOldSpec :: Bool -> String -> FilePath -> IO FilePath- createOldSpec subpkg crVer spec = do- cblrpmVersion subpkg crVer+ createOldSpec subpkg cblrpmver spec = do+ cblrpmVersion subpkg cblrpmver let backup = spec <.> "cblrpm"- backup' = backup ++ "-" ++ crVer+ backup' = backup ++ "-" ++ cblrpmver renameFile backup backup' return backup'
src/Commands/RpmBuild.hs view
@@ -49,7 +49,7 @@ (\ s -> putStrLn ("Using existing" +-+ s) >> return s) mspec let pkgid = package pkgDesc- bringTarball pkgid True specFile+ bringTarball pkgid True (Just specFile) rpmbuild stage specFile return specFile
src/Commands/Spec.hs view
@@ -219,14 +219,6 @@ global "pkg_name" name global "pkgver" "%{pkg_name}-%{version}" putNewline- unless standalone $ do- global "_devel" $- if hasLib- -- rpm-4.15 supports %{expr:b?t:f} (not in rhel8)- then "%{?ghc_devel_prof}%{!?ghc_devel_prof:devel}"- -- FIXME: use static%{_isa}- else "%{?ghc_devel_prof:static}%{!?ghc_devel_prof:devel}"- putNewline let pkgver = if hasLib then "%{pkgver}" else pkg_name ++ "-%{version}" @@ -237,11 +229,8 @@ miss <- if subpackage || standalone then missingLibraries hasLibPkg pkgDesc else return [] return $ nub (subs ++ miss) subpkgs <- if subpackage then- case mspec of- Just spec ->- mapM (getsubpkgMacro mstream spec >=>- \(m,pv) -> global m (display pv) >> return ("%{" ++ m ++ "}")) missingLibs- Nothing -> return []+ mapM (getsubpkgMacro mstream mspec >=>+ \(m,pv) -> global m (display pv) >> return ("%{" ++ m ++ "}")) missingLibs else return [] let hasSubpkgs = subpkgs /= [] when hasSubpkgs $ do@@ -286,9 +275,12 @@ mapM_ (\ d -> (if d `elem` missingLibs then putHdrComment else putHdr) "BuildRequires" (showRpm (RpmHsLib Devel d))) setupDeps putHdr "BuildRequires" $ "ghc-rpm-macros" ++ (if hasSubpkgs then "-extra" else "") - unless (null deps) $+ unless (null deps) $ do -- put "# Build"- mapM_ (\ d -> (if d `elem` missingLibs then putHdrComment else putHdr) "BuildRequires" (showRpm (RpmHsLib Base d) ++ if standalone then "-devel" else "-%{_devel}")) $ sort deps+ let metaPackages = map mkPackageName ["haskell-gi-overloading"]+ ghcLibDep d | d `elem` metaPackages = RpmHsLib Devel d+ | otherwise = (RpmHsLib $ if standalone then Devel else if hasLibPkg then Prof else Static) d+ mapM_ (\ d -> (if d `elem` missingLibs then putHdrComment else putHdr) "BuildRequires" (showRpm (ghcLibDep d))) $ sort deps let otherdeps = sort $ tools ++ clibs ++ pkgcfgs unless (null otherdeps) $ do -- put "# Other"@@ -316,7 +308,7 @@ let deptype = if standalone then Devel else Prof putPkgDeps pkg = do more <- packageDeps flags Nothing pkg- let moredeps = more \\ (deps ++ missingLibs)+ let moredeps = sort $ more \\ (deps ++ missingLibs) unless (null moredeps) $ do put $ "# for missing dep '" ++ display pkg ++ "':" mapM_ (\ d -> (if d `elem` missingLibs then putHdrComment else putHdr) "BuildRequires" (showRpm (RpmHsLib deptype d))) moredeps@@ -359,8 +351,9 @@ let isa = "%{?_isa}" put $ "%package" +-+ subpkgParam Devel putHdr "Summary" $ "Haskell" +-+ pkg_name +-+ "library development files"- putHdr "Provides" $ baselibpkg ++ "-static" ++ versionRelease- putHdr "Provides" $ baselibpkg ++ "-static" ++ isa ++ versionRelease+ when hasModules $ do+ putHdr "Provides" $ baselibpkg ++ "-static" ++ versionRelease+ putHdr "Provides" $ baselibpkg ++ "-static" ++ isa ++ versionRelease put "%if %{defined ghc_version}" putHdr "Requires" "ghc-compiler = %{ghc_version}" put "%endif"@@ -374,27 +367,27 @@ put $ "%description" +-+ subpkgParam Devel put $ wrapGenDesc $ "This package provides the Haskell" +-+ pkg_name +-+ "library development files." sectionNewline--- ? when hasModules $- put "%if %{with haddock}"- put $ "%package" +-+ subpkgParam Doc- putHdr "Summary" $ "Haskell" +-+ pkg_name +-+ "library documentation"- putHdr "BuildArch" "noarch"- putNewline- put $ "%description" +-+ subpkgParam Doc- put $ wrapGenDesc $ "This package provides the Haskell" +-+ pkg_name +-+ "library documentation."- put "%endif"- {- HLINT ignore "Reduce duplication"-}- sectionNewline- put "%if %{with ghc_prof}"- put $ "%package" +-+ subpkgParam Prof- putHdr "Summary" $ "Haskell" +-+ pkg_name +-+ "profiling library"- putHdr "Requires" $ baselibpkg ++ "-devel" ++ isa ++ versionRelease- putHdr "Supplements" $ "(" ++ baselibpkg ++ "-devel and ghc-prof)"- putNewline- put $ "%description" +-+ subpkgParam Prof- put $ wrapGenDesc $ "This package provides the Haskell" +-+ pkg_name +-+ "profiling library."- put "%endif"- sectionNewline+ when hasModules $ do+ put "%if %{with haddock}"+ put $ "%package" +-+ subpkgParam Doc+ putHdr "Summary" $ "Haskell" +-+ pkg_name +-+ "library documentation"+ putHdr "BuildArch" "noarch"+ putNewline+ put $ "%description" +-+ subpkgParam Doc+ put $ wrapGenDesc $ "This package provides the Haskell" +-+ pkg_name +-+ "library documentation."+ put "%endif"+ {- HLINT ignore "Reduce duplication"-}+ sectionNewline+ put "%if %{with ghc_prof}"+ put $ "%package" +-+ subpkgParam Prof+ putHdr "Summary" $ "Haskell" +-+ pkg_name +-+ "profiling library"+ putHdr "Requires" $ baselibpkg ++ "-devel" ++ isa ++ versionRelease+ putHdr "Supplements" $ "(" ++ baselibpkg ++ "-devel and ghc-prof)"+ putNewline+ put $ "%description" +-+ subpkgParam Prof+ put $ wrapGenDesc $ "This package provides the Haskell" +-+ pkg_name +-+ "profiling library."+ put "%endif"+ sectionNewline when hasSubpkgs $ do global "main_version" "%{version}"@@ -528,15 +521,16 @@ -- put "# End cabal-rpm files" sectionNewline - put "%if %{with haddock}"- put $ "%files" +-+ filesParams Doc- mapM_ (\ l -> put $ license_macro +-+ l) licensefiles- put "%endif"- sectionNewline- put "%if %{with ghc_prof}"- put $ "%files" +-+ filesParams Prof- put "%endif"- sectionNewline+ when hasModules $ do+ put "%if %{with haddock}"+ put $ "%files" +-+ filesParams Doc+ mapM_ (\ l -> put $ license_macro +-+ l) licensefiles+ put "%endif"+ sectionNewline+ put "%if %{with ghc_prof}"+ put $ "%files" +-+ filesParams Prof+ put "%endif"+ sectionNewline put "%changelog" now <- getCurrentTime@@ -565,7 +559,7 @@ showLicense PublicDomain = "Public Domain" showLicense AllRightsReserved = "Proprietary" showLicense OtherLicense = "Unknown"- -- FIXME+-- FIXME showLicense (UnknownLicense l) = removePrefix "LicenseRef" l #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,16,0) showLicense (Apache Nothing) = "ASL ?"@@ -610,12 +604,12 @@ paragraphs :: [String] -> [String] paragraphs = map (unlines . filter notNull) . groupBy (const notNull) -getsubpkgMacro :: Maybe Stream -> FilePath -> PackageName+getsubpkgMacro :: Maybe Stream -> Maybe FilePath -> PackageName -> IO (String, PackageIdentifier)-getsubpkgMacro mstream spec pkg = do+getsubpkgMacro mstream mspec pkg = do let macro = filter (/= '-') $ display pkg pkgid <- latestPackage mstream pkg- bringTarball pkgid False spec+ bringTarball pkgid False mspec return (macro, pkgid) number :: [a] -> [(String,a)]
src/Commands/Update.hs view
@@ -19,7 +19,6 @@ ) where import Commands.Spec (createSpecFile)-import FileUtils (withTempDirectory) import Header (headerOption, withSpecHead) import PackageUtils (PackageData (..), bringTarball, editSpecField, getRevisedCabal, getSpecField, latestPackage,@@ -40,8 +39,9 @@ import Data.Maybe (isJust) import Distribution.Text (display) import Distribution.Verbosity (silent)-import System.Directory (createDirectory, renameFile, setCurrentDirectory)-import System.FilePath ((</>), (<.>))+import System.Directory (createDirectoryIfMissing, doesDirectoryExist,+ removeDirectoryRecursive, renameFile)+import System.FilePath ((<.>)) update :: Maybe PackageVersionSpecifier -> IO () update mpvs = do@@ -52,7 +52,8 @@ let pkgDesc = packageDesc pkgdata oldPkgId = package pkgDesc name = pkgName oldPkgId- revised = isJust $ lookup "x-revision" (customFieldsPD pkgDesc)+ wasrevised = isJust $ lookup "x-revision" (customFieldsPD pkgDesc)+ putStrLn $ display oldPkgId +-+ "->" newPkgId <- case mpvs of Nothing -> do stream <-@@ -81,37 +82,34 @@ if newver < oldver then putStrLn $ "current" +-+ display oldver +-+ "is newer!" else do- getRevisedCabal newPkgId+ newrev <- getRevisedCabal newPkgId unless updated $ putStrLn "Package is already latest version."- when (not revised || updated) $- withTempDirectory $ \cwd -> do- let specfile = cwd </> spec- subpkg <- grep_ "%{subpkgs}" specfile- (curspec, _) <- createSpecVersion oldPkgId specfile revised subpkg- (newspec, newrevised) <- createSpecVersion newPkgId specfile True subpkg- currel <- getSpecField "Release" specfile+ when (newrev || updated) $ do+ subpkg <- grep_ "%{subpkgs}" spec+ (curspec, _) <- createSpecVersion oldPkgId spec wasrevised subpkg+ (newspec, newrevised) <- createSpecVersion newPkgId spec True subpkg+ currel <- getSpecField "Release" spec let suffix = "%{?dist}" defrelease = "1"- editSpecField "Release" (defrelease ++ suffix) specfile- patchSpec False (Just cwd) curspec newspec- ver' <- readVersion <$> getSpecField "Version" specfile+ editSpecField "Release" (defrelease ++ suffix) spec+ patchSpec False Nothing curspec newspec+ ver' <- readVersion <$> getSpecField "Version" spec when (ver' /= newver) $- editSpecField "Version" (showVersion newver) specfile+ editSpecField "Version" (showVersion newver) spec if updated && not subpkg- then editSpecField "Release" (defrelease ++ suffix) specfile- else editSpecField "Release" (currel ++ suffix) specfile+ then editSpecField "Release" (defrelease ++ suffix) spec+ else editSpecField "Release" (currel ++ suffix) spec when updated $ do -- FIXME reset when all subpkgs updated unless subpkg $- editSpecField "Release" ("0" ++ suffix) specfile- cmd_ "rpmdev-bumpspec" ["-c", "update to" +-+ showVersion newver, specfile]- setCurrentDirectory cwd+ editSpecField "Release" ("0" ++ suffix) spec+ cmd_ "rpmdev-bumpspec" ["-c", "update to" +-+ showVersion newver, spec] rwGit <- rwGitDir when (rwGit && subpkg) $ do cmd_ "cp" ["-p", "sources", "sources.cblrpm"] cmd_ "sed" ["-i", "/" ++ display oldPkgId <.> "tar.gz" ++ "/d", "sources.cblrpm"]- bringTarball newPkgId False spec+ bringTarball newPkgId False (Just spec) distgit <- grepGitConfig "\\(pkgs\\|src\\)." when (rwGit && distgit) $ do cmd_ "fedpkg" ["new-sources", display newPkgId <.> "tar.gz"]@@ -120,18 +118,19 @@ renameFile "sources.cblrpm" "sources" when newrevised $ cmd_ "git" ["add", display newPkgId <.> "cabal"]- when revised $+ when wasrevised $ cmd_ "git" ["rm", display oldPkgId <.> "cabal"] cmd_ "git" ["commit", "-a", "-m", "update to" +-+ showVersion newver] where createSpecVersion :: PackageIdentifier -> String -> Bool -> Bool -> IO (FilePath, Bool) createSpecVersion pkgid spec revise subpkg = do pd <- prepare [] (streamPkgToPVS Nothing (Just pkgid)) revise- let pkgdata' = pd { specFilename = Just spec }- dir = display pkgid ++ if revise then ".revised" else ".orig"- createDirectory dir+ let pkgdata = pd { specFilename = Just spec }+ dir = ".Cblrpm/" ++ display pkgid ++ if revise then ".revised" else ".orig"+ direxists <- doesDirectoryExist dir+ when direxists $ removeDirectoryRecursive dir+ createDirectoryIfMissing True dir newspec <- createSpecFile silent [] False (SpecFile spec) subpkg (Just dir) (streamPkgToPVS Nothing (Just pkgid)) let newrevised =- let pkgDesc = packageDesc pkgdata' in- isJust $ lookup "x-revision" (customFieldsPD pkgDesc)+ isJust $ lookup "x-revision" (customFieldsPD (packageDesc pkgdata)) return (newspec, newrevised)
src/PackageUtils.hs view
@@ -52,7 +52,7 @@ #else import Control.Applicative ((<$>)) #endif-import Control.Monad (filterM, unless, when)+import Control.Monad (filterM, unless, void, when) import Data.Char (toLower) import Data.List (isPrefixOf, isSuffixOf, nub, sort)@@ -95,11 +95,13 @@ in any (`isPrefixOf` lowerName) names unlikely name = not $ any (`isSuffixOf` name) ["~", ".cabal"] -bringTarball :: PackageIdentifier -> Bool -> FilePath -> IO ()-bringTarball pkgid revise spec = do- havespec <- doesFileExist spec+bringTarball :: PackageIdentifier -> Bool -> Maybe FilePath -> IO ()+bringTarball pkgid revise mspec = do+ havespec <- case mspec of+ Nothing -> return False+ Just spec -> doesFileExist spec sources <- if havespec- then map sourceFieldFile <$> cmdLines "spectool" ["-S", spec]+ then map sourceFieldFile <$> cmdLines "spectool" ["-S", fromJust mspec] else return [tarfile] srcdir <- getSourceDir allExist <- and <$> mapM (doesFileExist . (srcdir </>)) sources@@ -114,10 +116,10 @@ mapM_ (copyTarball False srcdir) sources haveLocalCabal <- doesFileExist $ srcdir </> display pkgid <.> "cabal" when (not haveLocalCabal && revise) $- getRevisedCabal pkgid+ void $ getRevisedCabal pkgid allExist' <- and <$> mapM (doesFileExist . (srcdir </>)) sources- unless allExist' $- cmd_ "spectool" ["-g", "-S", "-C", srcdir, spec]+ when (not allExist' && havespec) $+ cmd_ "spectool" ["-g", "-S", "-C", srcdir, fromJust mspec] where tarfile = display pkgid <.> "tar.gz" @@ -165,7 +167,7 @@ then getCurrentDirectory else fromJust <$> rpmEval "%{_sourcedir}" -getRevisedCabal :: PackageIdentifier -> IO ()+getRevisedCabal :: PackageIdentifier -> IO Bool getRevisedCabal pkgid = do let file = display (pkgName pkgid) <.> "cabal" dir <- getSourceDir@@ -175,6 +177,7 @@ when revised $ do cmd_ "dos2unix" ["--keepdate", file] renameFile file $ dir </> display pkgid <.> "cabal"+ return revised data RpmStage = Binary | Source | Prep deriving Eq @@ -342,7 +345,7 @@ namever <- removePrefix "ghc-" . head <$> rpmspec ["--srpm"] (Just "%{name}-%{version}") specFile case simpleParse namever of Nothing -> error "pkgid could not be parsed"- Just pkgid -> bringTarball pkgid revise specFile+ Just pkgid -> bringTarball pkgid revise (Just specFile) dExists <- doesDirectoryExist namever if dExists then do@@ -419,15 +422,19 @@ mspec <- checkForSpecFile (Just pkg) prepStreamPkg flags mspec stream pkg revise +-- redundant mdir was earlier for update patchSpec :: Bool -> Maybe FilePath -> FilePath -> FilePath -> IO () patchSpec dryrun mdir oldspec newspec = do- diff <- cmdIgnoreErr "diff" ["-u2", "-I", "- spec file generated by cabal-rpm", "-I", "Fedora Haskell SIG <haskell@lists.fedoraproject.org>", oldspec, newspec] "" >>= cmdIgnoreErr "sed" ["-e", "s/.cblrpm//"]+ diff <- cmdIgnoreErr "diff" ["-u2", "-I", "- spec file generated by cabal-rpm", "-I", "Fedora Haskell SIG <haskell@lists.fedoraproject.org>", oldspec, newspec] "" >>= cmdIgnoreErr "sed" ["-e", "s%.Cblrpm/%%"] putStrLn diff unless dryrun $ do out <- cmdIgnoreErr "patch" opts diff putStrLn out where- opts = ["--fuzz=1"] ++ ["-p1" | '/' `elem` newspec] ++ maybe [] (\ d -> ["-d", d]) mdir+ opts = ["--fuzz=1"] ++ ["-p" ++ show n | let n = count '/' newspec] ++ maybe [] (\ d -> ["-d", d]) mdir++ count :: Eq a => a -> [a] -> Int+ count x = length . filter (==x) packageManager :: IO String packageManager = do
src/Stackage.hs view
@@ -41,7 +41,7 @@ import Types defaultLTS :: Stream-defaultLTS = LTS "13"+defaultLTS = LTS "14" latestLTS :: Stream latestLTS = LTS "14"