cabal-rpm 2.1.1 → 2.1.2
raw patch · 13 files changed
+144/−76 lines, 13 files
Files
- COPYING +4/−4
- ChangeLog +14/−0
- README.md +53/−19
- TODO +2/−0
- cabal-rpm.cabal +6/−6
- src/Commands/Diff.hs +1/−1
- src/Commands/Refresh.hs +1/−1
- src/Commands/RpmBuild.hs +1/−1
- src/Commands/Spec.hs +42/−25
- src/Commands/Update.hs +6/−5
- src/Main.hs +5/−5
- src/PackageUtils.hs +7/−7
- src/Stackage.hs +2/−2
COPYING view
@@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -645,7 +645,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.+ along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. @@ -664,11 +664,11 @@ You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see-<http://www.gnu.org/licenses/>.+<https://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read-<http://www.gnu.org/philosophy/why-not-lgpl.html>.+<https://www.gnu.org/licenses/why-not-lgpl.html>.
ChangeLog view
@@ -1,3 +1,17 @@+# 2.1.2 (2023-07-27)+- PackageUtils checkForPkgCabalFile: check within BUILD dir+- PackageUtils patchSpec: drop problem code for showing patch -.rej+- Stackage: bump default to lts-21+- allow Cabal-3.10+- https for COPYING urls+- spec: add %autopatch if Patch's and no %patch+- spec: exclude missing deps from missing testsuite deps+- spec: revert from %autosetup to %setup+- spec: standalone should not use prof+- update: --old-stream option for subpackages+- update: invert gitBool check for local changes+- update: use wasrevised to control revision of old reference spec+ # 2.1.1 (2023-03-27) - spec: use %autosetup - PackageUtils patchSpec: adding newline to stdin hangs patch
README.md view
@@ -9,30 +9,20 @@ cabal-rpm is a tool for RPM packaging of Haskell Cabal-based packages. Firstly it creates RPM spec files from the .cabal files of Haskell packages. It can also install build dependencies using dnf/yum, it prefers package-versions from Stackage, and can build and install packages and their dependencies-recursively as rpm packages. It can also update packages and refresh spec files.+versions from Stackage, and can build and install packages and+their dependencies recursively as rpm packages. It can also update packages+and refresh spec files. Cabal-rpm was originally created by Bryan O'Sullivan (see README.orig)-to create spec files, and was later updated by Jens Petersen to work with current-Cabal and Fedora Packaging Guidelines replacing cabal2spec, and extended with-many new features. It is used by Fedora and earlier by OpenSuSE. It is licensed-under the terms of the GPL version 3 (see the COPYING file).+to create spec files, and was later updated by Jens Petersen to work with+current Cabal and Fedora Packaging Guidelines replacing cabal2spec,+and extended with many new features.+It is used by Fedora and earlier by OpenSuSE.+It is licensed under the terms of the GPL version 3 (see the COPYING file). ## Requirements cabal-rpm assumes you are using ghc-rpm-macros for Haskell RPM packaging.-It currently needs Cabal 1.10 or later to build (ie ghc 7 or later). -## Installation-The package is on Hackage. If you have cabal-install (part of Haskell Platform)-you can install simply with-- $ cabal install cabal-rpm--You can also install it with `stack install cabal-rpm`.--You can also build and install it from source as normal by running-`cabal install`.- ## Usage To create a `.spec` file for a package: @@ -78,9 +68,53 @@ There are more commands: prep, builddep, depends, requires, missingdeps. See the manpage or help output for more details. +## Help output+```shellsession+$ cabal-rpm --version+2.1.2+$ cabal-rpm --help+Cabal-rpm tool++Usage: cabal-rpm [--version] COMMAND++ RPM package tool for Haskell Stackage/Hackage packages++Available options:+ -h,--help Show this help text+ --version Show version++Available commands:+ spec Generate a spec file+ srpm Generate an srpm+ prep Unpack source+ local Build rpm package locally+ build Alias for 'local' - builds rpm locally+ builddep Install build dependencies with dnf+ install Build and install recursively+ diff Diff with pristine generated spec file+ depends List Haskell dependencies+ requires List buildrequires for package+ missingdeps List dependencies not available+ refresh Refresh spec file to latest packaging+ update Update package to latest version+```++## Installation+cabal-rpm is packaged in Fedora and EPEL.++It currently needs at least ghc 8 or newer and Cabal 1.10 or later to build.++The package is on Hackage. If you have cabal-install you can install simply with++ $ cabal install cabal-rpm++You can also install it with `stack install cabal-rpm`.++You can also build and install it from source as normal by running+`cabal install`.+ ## Development The latest source code is available from: https://github.com/juhp/cabal-rpm -## Plans More features are planned and patches welcome. See the [TODO](TODO) file for more details.
TODO view
@@ -2,6 +2,8 @@ - 'install' in a source dir: "package not found for directory" - maybe just run "cabal install" for executable? +- subpackage data files(?): eg criterion+ - cblrpm local: Running repoquery for haskell-gi-overloading Unavailable dependencies: haskell-gi-overloading
cabal-rpm.cabal view
@@ -1,5 +1,6 @@+Cabal-version: 1.18 Name: cabal-rpm-Version: 2.1.1+Version: 2.1.2 Synopsis: RPM packaging tool for Haskell Cabal-based packages Description: This package provides a RPM packaging tool for Haskell Cabal-based packages.@@ -10,8 +11,8 @@ 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 made, built with cabal-install.+ file to the current cabal-rpm packaging. It also handles Hackage revisions+ of packages. Standalone packages can also be made, built with cabal-install. Homepage: https://github.com/juhp/cabal-rpm Bug-reports: https://github.com/juhp/cabal-rpm/issues License: GPL-3@@ -25,10 +26,9 @@ Build-type: Simple Extra-doc-files: ChangeLog README.md TODO Extra-source-files: man/cabal-rpm.1.md-Cabal-version: 1.18 Tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7,- GHC == 9.0.2, GHC == 9.2.5+ GHC == 9.0.2, GHC == 9.2.8, GHC == 9.4.5 source-repository head type: git@@ -45,7 +45,7 @@ Executable cabal-rpm Main-is: Main.hs Build-depends: base < 5,- Cabal > 1.10 && < 3.9,+ Cabal > 1.10 && < 3.11, directory, extra, filepath >= 1.4,
src/Commands/Diff.hs view
@@ -42,7 +42,7 @@ Just spec -> do subpkg <- grep_ "%{subpkgs}" spec withTempDir $ \tmpdir -> do- speccblrpm <- createSpecFile False silent flags False False pkgtype (if subpkg then Just Nothing else Nothing) Nothing (Just tmpdir) mpvs+ speccblrpm <- createSpecFile False silent flags False False False pkgtype (if subpkg then Just Nothing else Nothing) Nothing (Just tmpdir) mpvs currel <- getSpecField "Release" spec let suffix = "%{?dist}" editSpecField "Release" (currel ++ suffix) speccblrpm
src/Commands/Refresh.hs view
@@ -60,7 +60,7 @@ _ -> pkgtype subpkg <- grep_ "%{subpkgs}" spec oldspec <- createOldSpec subpkg cblrpmver spec- newspec <- createSpecFile False silent [] False False spectype (if subpkg then Just Nothing else Nothing) Nothing Nothing mpvs+ newspec <- createSpecFile False silent [] False False False spectype (if subpkg then Just Nothing else Nothing) Nothing Nothing mpvs patchSpec dryrun Nothing oldspec newspec -- setCurrentDirectory cwd -- when rwGit $
src/Commands/RpmBuild.hs view
@@ -41,7 +41,7 @@ void $ pkgInstallMissing' pkgdata let pkgDesc = packageDesc pkgdata mspec = specFilename pkgdata- specFile <- maybe (createSpecFile False normal flags False False pkgtype (if subpackage then Just Nothing else Nothing) Nothing Nothing mpvs)+ specFile <- maybe (createSpecFile False normal flags False False False pkgtype (if subpackage then Just Nothing else Nothing) Nothing Nothing mpvs) (\ s -> putStrLn ("Using existing" +-+ s) >> return s) mspec let pkgid = package pkgDesc
src/Commands/Spec.hs view
@@ -32,7 +32,7 @@ , showVersion #endif )-import SimpleCmd ((+-+), cmd, cmdMaybe, grep, grep_, removePrefix)+import SimpleCmd ((+-+), cmd, cmdLines, cmdMaybe, grep, grep_, removePrefix) import Stackage (defaultLTS) import Types @@ -93,11 +93,11 @@ #endif -- FIXME use datatype for options-createSpecFile :: Bool -> Verbosity -> Flags -> Bool -> Bool+createSpecFile :: Bool -> Verbosity -> Flags -> Bool -> Bool -> Bool -> PackageType -> Maybe (Maybe Stream) -> Maybe V.Version -> Maybe FilePath -> Maybe PackageVersionSpecifier -> IO FilePath-createSpecFile ignoreMissing verbose flags testsuite force pkgtype subpkgStream mwithghc mdest mpvs = do+createSpecFile ignoreMissing verbose flags norevision testsuite force pkgtype subpkgStream mwithghc mdest mpvs = do pkgdata <- prepare flags mpvs let mspec = case pkgtype of SpecFile f -> Just f@@ -142,6 +142,14 @@ autochangelog <- ifJust mspecExists $ grep_ "^%autochangelog"+ autopatch <-+ ifJust mspecExists $ \sf -> do+ patches <- not . null <$> cmdLines "spectool" ["-P", sf]+ if patches+ then do+ ppatch <- grep_ "^%patch" sf+ return $ not ppatch+ else return False let hasExec = hasExes pkgDesc hasLib = hasLibs pkgDesc@@ -214,8 +222,7 @@ ST.fromShortText $ #endif synopsis pkgDesc- when (null syn) $- warn verbose "this package has no synopsis."+ when (null syn) $ warn verbose "this package has no synopsis." let initialCapital (c:cs) = toUpper c:cs initialCapital [] = [] syn' = if null syn@@ -230,22 +237,24 @@ ST.fromShortText $ #endif description pkgDesc- when (null descr) $- warn verbose "this package has no description."+ when (null descr) $ warn verbose "this package has no description." let descLines = (formatParagraphs . initialCapital . filterSymbols . finalPeriod . paragraphPeriods) $ if null descr then syn' else descr paragraphPeriods = unlines . map (\l -> if l == "." then "" else l) . lines- 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- '@' -> '\'': filterSymbols cs- '\\' -> head cs: filterSymbols (tail cs)- _ -> c: filterSymbols cs+ finalPeriod cs =+ case last cs of+ '.' -> cs+ '\n' -> finalPeriod $ init cs+ _ -> cs ++ "." filterSymbols [] = []+ filterSymbols (c:cs) =+ if c `notElem` "@\\"+ then c: filterSymbols cs+ else+ case c of+ '@' -> '\'': filterSymbols cs+ '\\' -> head cs: filterSymbols (tail cs)+ _ -> c: filterSymbols cs when standalone $ do global "ghc_without_dynamic" "1"@@ -280,7 +289,8 @@ putNewline let (testsuiteDeps,testsuiteTools) = testsuiteDependencies' pkgDesc- missTestDeps <- filterM (notSrcOrInst . RpmHsLib Devel) testsuiteDeps+ unpkgedTestDeps <- filterM (notSrcOrInst . RpmHsLib Devel) testsuiteDeps+ let missTestDeps = unpkgedTestDeps \\ missingLibs let testable = notNull testsuiteDeps && not standalone && (null missTestDeps || testsuite) && isNothing mwithghc if testable then do put "%bcond_without tests"@@ -291,6 +301,9 @@ let version = display $ pkgVersion pkgid release = "1" revised <-+ if norevision+ then return False+ else if isJust $ lookup "x-revision" (customFieldsPD pkgDesc) then return True else do@@ -325,7 +338,7 @@ when revisedDOS $ putHdr "BuildRequires" "dos2unix" when (mkPackageName "Cabal" `notElem` buildDeps pkgdeps || not hasLib || notNull (setupDeps pkgdeps)) $ do -- put "# Setup"- when (mkPackageName "Cabal" `notElem` buildDeps pkgdeps) $+ unless (mkPackageName "Cabal" `elem` buildDeps pkgdeps) $ putHdr "BuildRequires" $ ghc_name ++ "-Cabal-devel" mapM_ (\ d -> (if d `elem` missingLibs then putHdrComment else putHdr) "BuildRequires" (showRpm (RpmHsLib Devel d))) $ setupDeps pkgdeps putHdr "BuildRequires" $ "ghc-rpm-macros" ++ (if hasSubpkgs then "-extra" else "")@@ -338,7 +351,7 @@ putHdr "BuildRequires" $ "%{ghc_name}" ++ "-prof" put "%else" - let metaPackages = map mkPackageName ["haskell-gi-overloading"]+ let metaPackages = [mkPackageName "haskell-gi-overloading"] mapM_ (\ d -> (if d `elem` missingLibs then putHdrComment else putHdr) "BuildRequires" (showRpm (RpmHsLib Devel d))) $ sort $ buildDeps pkgdeps when hasLibPkg $ do put "%if %{with ghc_prof}"@@ -377,9 +390,10 @@ put $ "# for missing dep '" ++ display pkg ++ "':" missingMore <- filterM (notSrcOrInst . RpmHsLib Devel) moredeps mapM_ (\ d -> (if d `elem` missingMore then putHdrComment else putHdr) "BuildRequires" (showRpm (RpmHsLib Devel d))) moredeps- put "%if %{with ghc_prof}"- mapM_ (\ d -> (if d `elem` missingMore then putHdrComment else putHdr) "BuildRequires" (showRpm (RpmHsLib Prof d))) moredeps- put "%endif"+ unless standalone $ do+ put "%if %{with ghc_prof}"+ mapM_ (\ d -> (if d `elem` missingMore then putHdrComment else putHdr) "BuildRequires" (showRpm (RpmHsLib Prof d))) moredeps+ put "%endif" when (isJust mwithghc) $ put "%endif" put "# End cabal-rpm deps"@@ -471,12 +485,14 @@ put "%prep" put "# Begin cabal-rpm setup:"- put $ "%autosetup -p1" ++ (if pkgname /= name then " -n" +-+ pkgver else "") +-++ put $ "%setup -q" ++ (if pkgname /= name then " -n" +-+ pkgver else "") +-+ (if hasSubpkgs then unwords (map (("-a" ++) . fst) $ number subpkgs) else "") when revised $ put $ (if revisedDOS then "dos2unix -k -n" else "cp -bp") +-+ "%{SOURCE" ++ show (1 + length subpkgs) ++ "}" +-+ pkg_name <.> "cabal"+ when autopatch $+ put "%autopatch -p1" put "# End cabal-rpm setup" sectionNewline @@ -631,11 +647,12 @@ -> Maybe (Maybe Stream) -> Maybe V.Version -> Maybe PackageVersionSpecifier -> IO () createSpecFile_ ignoreMissing verbose flags testsuite force pkgtype subpkgStream mwithghc mpvs =- void (createSpecFile ignoreMissing verbose flags testsuite force pkgtype subpkgStream mwithghc Nothing mpvs)+ void (createSpecFile ignoreMissing verbose flags False testsuite force pkgtype subpkgStream mwithghc Nothing mpvs) isBuildable :: Executable -> Bool isBuildable exe = buildable $ buildInfo exe +-- FIXME convert strings to SPDX or drop? #if !MIN_VERSION_Cabal(2,2,0) prettyShow :: License -> String prettyShow (GPL Nothing) = "GPL+"
src/Commands/Update.hs view
@@ -44,8 +44,8 @@ -- FIXME --dryrun -- FIXME check kerberos before new-sources-update :: Maybe PackageVersionSpecifier -> IO ()-update mpvs = do+update :: Maybe Stream -> Maybe PackageVersionSpecifier -> IO ()+update moldstream mpvs = do pkgdata <- pkgSpecPkgData [] (pvsPackage =<< mpvs) case specFilename pkgdata of Nothing -> error' "No (unique) .spec file in directory."@@ -94,7 +94,8 @@ when (newrev || updated) $ do putStrLn $ display oldPkgId +-+ "current" subpkg <- grep_ "%{subpkgs}" spec- curspec <- createSpecVersion oldPkgId spec wasrevised (if subpkg then Just Nothing else Nothing)+ -- FIXME should not update subpackage versions+ curspec <- createSpecVersion oldPkgId spec wasrevised (if subpkg then Just moldstream else Nothing) newspec <- createSpecVersion newPkgId spec True (if subpkg then Just mstream else Nothing) currel <- getSpecField "Release" spec let suffix = "%{?dist}"@@ -142,7 +143,7 @@ else "update to" +-+ showVersion newver] else when newrev $- whenM (gitBool "diff-index" ["--quiet", "HEAD"]) $+ unlessM (gitBool "diff-index" ["--quiet", "HEAD"]) $ cmd_ "git" ["commit", "-a", "-m", "revised .cabal file"] rpmbuild True Prep spec where@@ -153,7 +154,7 @@ direxists <- doesDirectoryExist dir when direxists $ removeDirectoryRecursive dir createDirectoryIfMissing True dir- createSpecFile False silent [] False False (SpecFile spec) subpkgStream Nothing (Just dir) (streamPkgToPVS Nothing (Just pkgid))+ createSpecFile False silent [] (not revise) False False (SpecFile spec) subpkgStream Nothing (Just dir) (streamPkgToPVS Nothing (Just pkgid)) krbTicket :: IO () krbTicket = do
src/Main.hs view
@@ -130,15 +130,13 @@ <*> pkgVerSpecifier , Subcommand "update" "Update package to latest version" $ update- <$> pkgVerSpecifier+ <$> optional (optionWith auto 'o' "old-stream" "OLDSTREAM" "Current subpackage stream")+ <*> pkgVerSpecifier ] where pkgId :: Parser (Maybe PackageIdentifier) pkgId = optional (argumentWith (maybeReader simpleParse) "PKG[VER]") - stream :: Parser (Maybe Stream)- stream = optional (optionWith auto 's' "stream" "STREAM" "Stackage stream or Hackage")- flags :: Parser Flags flags = optionalWith auto 'f' "flag" "[(String,Bool)]" "Set or disable Cabal flags" [] @@ -167,7 +165,9 @@ subpackage = switchWith 'S' "subpackage" "Subpackage missing Haskell dependencies" pkgVerSpecifier :: Parser (Maybe PackageVersionSpecifier)- pkgVerSpecifier = streamPkgToPVS <$> stream <*> pkgId+ pkgVerSpecifier = streamPkgToPVS+ <$> optional (optionWith auto 's' "stream" "STREAM" "Stackage stream or Hackage")+ <*> pkgId toSubpkgStream :: Bool -> Maybe (Maybe Stream) toSubpkgStream False = Nothing
src/PackageUtils.hs view
@@ -42,7 +42,7 @@ tryFindPackageDesc) import SimpleCmd (cmd, cmd_, cmdBool, cmdIgnoreErr, cmdLines, cmdStderrToStdoutIn,- error', grep_, removePrefix, shell_, sudo, sudo_, (+-+))+ error', grep_, removePrefix, sudo, sudo_, (+-+)) import SimpleCmd.Git (isGitDir, grepGitConfig) import SimpleCmd.Rpm (rpmspec) import SysCmd (optionalProgram, requireProgram, rpmEval)@@ -185,7 +185,7 @@ if not dl then return False else do- revised <- grep_ "x-revision" file+ revised <- grep_ "^x-revision:" file when revised $ -- renameFile can fail across fs devices copyFile file $ dir </> display pkgid <.> "cabal"@@ -338,9 +338,11 @@ if pkgcabal then return $ Just cabalfile else do- exists <- doesDirectoryExist $ display pkgid+ builddir <- getBuildDir+ let dir = builddir </> display pkgid+ exists <- doesDirectoryExist dir if exists- then fileWithExtension (display pkgid) ".cabal"+ then fileWithExtension dir ".cabal" else return Nothing pkgSpecPkgData :: Flags -> Maybe PackageName -> IO PackageData@@ -468,10 +470,8 @@ putStrLn diff unless dryrun $ do putStrLn ""- (ok,out) <- cmdStderrToStdoutIn "patch" opts diff+ out <- cmdIgnoreErr "patch" opts diff putStrLn out- unless ok $- shell_ "echo *.rej; cat *.rej" where opts = ["--fuzz=1"] ++ ["-p" ++ show n | let n = count '/' (removePrefix ".Cblrpm/" newspec)] ++ maybe [] (\ d -> ["-d", d]) mdir
src/Stackage.hs view
@@ -40,10 +40,10 @@ import Types defaultLTS :: Stream-defaultLTS = LTS 20+defaultLTS = LTS 21 latestLTS :: Stream-latestLTS = LTS 20+latestLTS = LTS 21 stackageList :: Stream -> PackageName -> IO (Maybe PackageIdentifier) stackageList stream pkg = do