cabal-rpm 0.9.3 → 0.9.4
raw patch · 9 files changed
+67/−43 lines, 9 filesdep ~Cabal
Dependency ranges changed: Cabal
Files
- ChangeLog +5/−0
- README.md +2/−2
- cabal-rpm.cabal +3/−3
- src/Commands/Depends.hs +3/−3
- src/Commands/Install.hs +4/−4
- src/Commands/RpmBuild.hs +2/−2
- src/Commands/Update.hs +6/−6
- src/Dependencies.hs +11/−14
- src/SysCmd.hs +31/−9
ChangeLog view
@@ -1,3 +1,8 @@+* 0.9.4 (2015-02-17)+- use dnf if installed instead of yum for install and repoquery+- update now only commits changes and new source if git origin is ssh+- allow Cabal-1.22+ * 0.9.3 (2015-02-05) - make sure tarball destdir exists before copying - improve output for listing missing packages
README.md view
@@ -4,7 +4,7 @@ # cabal-rpm cabal-rpm is a tool for RPM packaging of Haskell Cabal-based packages.-It interacts with yum to install build dependencies and can also act as+It interacts with yum/dnf to install build dependencies and can also act as a cabal-install wrapper installing dependencies packaged in Fedora before running "cabal install". @@ -58,7 +58,7 @@ $ cblrpm install [pkg][-ver] -will yum install available missing dependencies and+will yum/dnf install available missing dependencies and run "cabal install" to build the package. ## Development
cabal-rpm.cabal view
@@ -1,11 +1,11 @@ Name: cabal-rpm-Version: 0.9.3+Version: 0.9.4 Synopsis: RPM packaging tool for Haskell Cabal-based packages Description: This package provides a RPM packaging tool for Haskell Cabal-based packages. . cblrpm has commands to generate a RPM spec file and srpm for a package.- It can rpmbuild packages, yum install their dependencies, prep packages,+ 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 and the update command updates the spec file@@ -30,7 +30,7 @@ Executable cblrpm Main-is: Main.hs Build-depends: base < 5,- Cabal > 1.10 && < 1.21,+ Cabal > 1.10 && < 1.23, directory, filepath, old-locale,
src/Commands/Depends.hs view
@@ -5,7 +5,7 @@ -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha ----- Explanation: cabal wrapper which yum installs dependencies+-- Explanation: determines dependencies -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by@@ -20,7 +20,7 @@ import Dependencies (dependencies, missingPackages, packageDependencies) import PackageUtils (PackageData (..), prepare, stripPkgDevel) import Setup (quiet)-import SysCmd (cmd, (+-+))+import SysCmd (repoquery, (+-+)) import Control.Applicative ((<$>)) import Control.Monad (filterM, unless, void)@@ -61,7 +61,7 @@ return $ nub $ accum2 ++ more notAvail :: String -> IO Bool-notAvail pkg = null <$> cmd "repoquery" [pkg]+notAvail pkg = null <$> repoquery [] pkg missingDepsPkg :: String -> IO [String] missingDepsPkg pkg = do
src/Commands/Install.hs view
@@ -6,7 +6,7 @@ -- Stability : alpha -- Portability : portable ----- Explanation: cabal wrapper which yum installs dependencies+-- Explanation: cabal wrapper which installs rpm dependencies -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by@@ -21,7 +21,7 @@ import Dependencies (missingPackages, notInstalled) import PackageUtils (PackageData (..), RpmStage (..), stripPkgDevel) import Setup (RpmFlags (..))-import SysCmd (cmd, cmd_, sudo, yumInstall, (+-+))+import SysCmd (cmd, cmd_, pkgInstall, rpmInstall, (+-+)) import Control.Applicative ((<$>)) import Control.Monad (unless, when)@@ -32,7 +32,7 @@ let pkgDesc = packageDesc pkgdata missing <- missingPackages pkgDesc unless (null missing) $ do- yumInstall missing False+ pkgInstall missing False stillMissing <- missingPackages pkgDesc unless (null stillMissing) $ do putStrLn $ "Missing:" +-+ unwords stillMissing@@ -42,7 +42,7 @@ rpmdir <- cmd "rpm" ["--eval", "%{_rpmdir}"] rpms <- (map (\ p -> rpmdir </> arch </> p ++ ".rpm") . lines) <$> cmd "rpmspec" ["-q", spec]- sudo "yum" $ ["-y", "localinstall"] ++ rpms+ rpmInstall rpms installMissing :: String -> IO () installMissing pkg = do
src/Commands/RpmBuild.hs view
@@ -24,7 +24,7 @@ import PackageUtils (copyTarball, isScmDir, PackageData (..), packageName, packageVersion, rpmbuild, RpmStage (..)) import Setup (RpmFlags (..))-import SysCmd (cmd, yumInstall, (+-+))+import SysCmd (cmd, pkgInstall, (+-+)) --import Control.Exception (bracket) import Control.Monad (unless, void, when)@@ -62,7 +62,7 @@ name = packageName pkg when (stage `elem` [Binary,BuildDep]) $ do missing <- missingPackages pkgDesc- yumInstall missing (stage == Binary)+ pkgInstall missing (stage == Binary) unless (stage == BuildDep) $ do srcdir <- cmd "rpm" ["--eval", "%{_sourcedir}"]
src/Commands/Update.hs view
@@ -18,10 +18,10 @@ import Commands.Spec (createSpecFile) import FileUtils (withTempDirectory)-import PackageUtils (PackageData (..), bringTarball, isGitDir, latestPkg,+import PackageUtils (PackageData (..), bringTarball, latestPkg, packageName, packageVersion, prepare, removePrefix) import Setup (RpmFlags (..))-import SysCmd (cmd_, shell, (+-+))+import SysCmd (cmd_, cmdBool, shell, (+-+)) import Control.Monad (when) import Distribution.PackageDescription (PackageDescription (..))@@ -43,9 +43,9 @@ then error $ current +-+ "is latest version." else do bringTarball latest- pkgGit <- isGitDir "."- when pkgGit $- cmd_ "fedpkg" ["new-sources", latest ++ ".tar.gz"]+ rwGit <- cmdBool "grep -q 'url = ssh://' .git/config"+ when rwGit $+ cmd_ "fedpkg" ["new-sources", latest ++ ".tar.gz"] withTempDirectory $ \cwd -> do curspec <- createSpecVersion current spec newspec <- createSpecVersion latest spec@@ -54,7 +54,7 @@ cmd_ "sed" ["-i", "-e s/^\\(Release: \\).*/\\10%{?dist}/", spec] let newver = removePrefix (name ++ "-") latest cmd_ "rpmdev-bumpspec" ["-c", "update to" +-+ newver, spec]- when pkgGit $+ when rwGit $ cmd_ "git" ["commit", "-a", "-m", "update to" +-+ newver] where createSpecVersion :: String -> String -> IO FilePath
src/Dependencies.hs view
@@ -23,7 +23,7 @@ ) where import PackageUtils (packageName)-import SysCmd (cmd, cmdBool, optionalProgram, (+-+))+import SysCmd (cmd, cmdBool, repoquery, (+-+)) import Control.Applicative ((<$>)) import Control.Monad (filterM, liftM)@@ -67,6 +67,8 @@ clibs = concatMap extraLibs buildinfo return (deps, tools, nub clibs, pkgcfgs, selfdep) +data RepoQueryType = Rpm | Repoquery deriving Eq+ resolveLib :: String -> IO (Maybe String) resolveLib lib = do lib64 <- doesDirectoryExist "/usr/lib64"@@ -74,21 +76,16 @@ let lib_path = "/usr/lib" ++ libsuffix ++ "/lib" ++ lib ++ ".so" libInst <- doesFileExist lib_path if libInst- then rpmqueryFile "rpm" lib_path+ then rpmqueryFile Rpm lib_path else do- haveRpqry <- optionalProgram "repoquery"- if haveRpqry- then do- putStrLn $ "Running repoquery on" +-+ "lib" ++ lib- rpmqueryFile "repoquery" lib_path- else do- warning $ "Install yum-utils to resolve package that provides uninstalled" +-+ lib_path- return Nothing+ putStrLn $ "Running repoquery on" +-+ "lib" ++ lib+ rpmqueryFile Repoquery lib_path -- use repoquery or rpm -q to query which package provides file-rpmqueryFile :: String -> FilePath -> IO (Maybe String)-rpmqueryFile qc file = do- out <- cmd qc ["-q", "--qf=%{name}", "-f", file]+rpmqueryFile :: RepoQueryType -> FilePath -> IO (Maybe String)+rpmqueryFile qt file = do+ let args = ["-q", "--qf=%{name}", "-f"]+ out <- if qt == Rpm then cmd "rpm" (args ++ [file]) else repoquery args file let pkgs = nub $ words out -- EL5 repoquery can return "No package provides <file>" case pkgs of@@ -141,7 +138,7 @@ derefPkg :: String -> IO String derefPkg req = do- res <- singleLine <$> cmd "repoquery" ["--qf", "%{name}", "--whatprovides", req]+ res <- singleLine <$> repoquery ["--qf", "%{name}", "--whatprovides"] req if null res then error $ req +-+ "provider not found by repoquery" else return res
src/SysCmd.hs view
@@ -22,16 +22,18 @@ cmdBool, cmdQuiet, cmdSilent,+ pkgInstall,+ repoquery,+ rpmInstall, trySystem, shell, sudo,- yumInstall, (+-+)) where import Control.Monad (unless, void, when) import Data.Functor ((<$>)) import Data.List ((\\))-import Data.Maybe (fromMaybe, isJust, isNothing)+import Data.Maybe (fromMaybe, isJust, isNothing, maybeToList) import Distribution.Simple.Utils (die, warn, findProgramLocation) import Distribution.Verbosity (normal)@@ -114,16 +116,31 @@ then init str else str +infixr 4 +-+ (+-+) :: String -> String -> String "" +-+ s = s s +-+ "" = s s +-+ t = s ++ " " ++ t -yumInstall :: [String] -> Bool -> IO ()-yumInstall [] _ = return ()-yumInstall pkgs hard = do+packageManager :: IO String+packageManager = do+ havednf <- optionalProgram "dnf"+ if havednf+ then return "dnf"+ else requireProgram "yum" >> return "yum"++repoquery :: [String] -> String -> IO String+repoquery args key = do+ havednf <- optionalProgram "dnf"+ let (prog, subcmd) = if havednf then ("dnf", Just "repoquery") else ("repoquery", Nothing)+ cmd prog (maybeToList subcmd ++ args ++ [key])++pkgInstall :: [String] -> Bool -> IO ()+pkgInstall [] _ = return ()+pkgInstall pkgs hard = do+ pkginstaller <- packageManager putStrLn $ "Running repoquery" +-+ unwords pkgs- repopkgs <- lines <$> readProcess "repoquery" (["--qf", "%{name}"] ++ pkgs) []+ repopkgs <- mapM (repoquery ["--qf", "%{name}"]) pkgs let missing = pkgs \\ repopkgs if not (null missing) && hard then error $ unwords missing +-+ "not available."@@ -141,13 +158,18 @@ else do havesudo <- optionalProgram "sudo" return $ if havesudo then Just "sudo" else Nothing- requireProgram "yum" let args = map showPkg repopkgs- putStrLn $ "Running:" +-+ fromMaybe "" maybeSudo +-+ "yum install" +-+ unwords args+ putStrLn $ "Running:" +-+ fromMaybe "" maybeSudo +-+ pkginstaller +-+ "install" +-+ unwords args let exec = if hard then cmd_ else trySystem fedora <- cmd "rpm" ["--eval", "%fedora"] let nogpgcheck = ["--nogpgcheck" | fedora `elem` ["21", "22"]]- exec (fromMaybe "yum" maybeSudo) $ maybe [] (const "yum") maybeSudo : "install" : args ++ nogpgcheck+ exec (fromMaybe pkginstaller maybeSudo) $ maybe [] (const pkginstaller) maybeSudo : "install" : args ++ nogpgcheck showPkg :: String -> String showPkg p = if '(' `elem` p then show p else p++rpmInstall :: [String] -> IO ()+rpmInstall rpms = do+ pkginstaller <- packageManager+ let (inst, arg) = if pkginstaller == "dnf" then ("dnf", "install") else ("yum", "localinstall")+ sudo inst $ ["-y", arg] ++ rpms