cabal-rpm 0.9.2 → 0.9.3
raw patch · 7 files changed
+69/−57 lines, 7 files
Files
- ChangeLog +8/−0
- cabal-rpm.cabal +1/−1
- src/Commands/RpmBuild.hs +5/−1
- src/Commands/Spec.hs +16/−20
- src/Commands/Update.hs +17/−17
- src/PackageUtils.hs +1/−1
- src/SysCmd.hs +21/−17
ChangeLog view
@@ -1,3 +1,11 @@+* 0.9.3 (2015-02-05)+- make sure tarball destdir exists before copying+- improve output for listing missing packages+- update improvements: new-sources first, continue if patch fails, git commit changes+- spec: sort executables and use %pkg_name in %ghc_fix_dynamic_rpath+- drop the debuginfo handling for C files+- ignore emacs temp ".#pkgname.spec" files+ * 0.9.2 (2014-12-18) - lots of bug fixes - improved missingdeps output
cabal-rpm.cabal view
@@ -1,5 +1,5 @@ Name: cabal-rpm-Version: 0.9.2+Version: 0.9.3 Synopsis: RPM packaging tool for Haskell Cabal-based packages Description: This package provides a RPM packaging tool for Haskell Cabal-based packages.
src/Commands/RpmBuild.hs view
@@ -33,7 +33,8 @@ --import Distribution.Version (VersionRange, foldVersionRange') -import System.Directory (doesFileExist)+import System.Directory (createDirectoryIfMissing, doesDirectoryExist,+ doesFileExist) import System.FilePath (takeDirectory, (</>)) -- autoreconf :: Verbosity -> PackageDescription -> IO ()@@ -74,6 +75,9 @@ when scmRepo $ error "No tarball for source repo" + destExists <- doesDirectoryExist srcdir+ unless destExists $+ createDirectoryIfMissing True srcdir copyTarball name version False srcdir rpmbuild stage False Nothing specFile return specFile
src/Commands/Spec.hs view
@@ -31,7 +31,7 @@ import Data.Char (toLower, toUpper) import Data.List (groupBy, intercalate, isPrefixOf, isSuffixOf, sort, (\\))-import Data.Maybe (fromMaybe, maybeToList)+import Data.Maybe (fromMaybe) import Data.Time.Clock (UTCTime, getCurrentTime) import Data.Time.Format (formatTime) import Data.Version (showVersion)@@ -40,9 +40,8 @@ import Distribution.Simple.Utils (notice, warn) -import Distribution.PackageDescription (PackageDescription (..), BuildInfo (..),- Executable (..), Library (..),- exeName, hasExes, hasLibs, withExe)+import Distribution.PackageDescription (PackageDescription (..), Executable (..),+ exeName, hasExes, hasLibs) --import Distribution.Version (VersionRange, foldVersionRange') @@ -119,7 +118,7 @@ put "#" put $ "# spec file for package " ++ pkgname put "#"- put $ "# Copyright (c) " ++ year ++ " SUSE LINUX Products GmbH, Nuernberg, Germany."+ put $ "# Copyright (c) " ++ year ++ " SUSE LINUX GmbH, Nuernberg, Germany." put "#" put "# All modifications and additions to the file contributed by third parties" put "# remain the property of their copyright owners, unless otherwise agreed"@@ -167,12 +166,12 @@ put $ "%bcond_" ++ (if null missTestDeps then "without" else "with") +-+ "tests" putNewline - let eCsources = concatMap (cSources . buildInfo) $ executables pkgDesc- let lCsources = concatMap (cSources . libBuildInfo) $ maybeToList $ library pkgDesc- when (null $ eCsources ++ lCsources) $ do- put "# no useful debuginfo for Haskell packages without C sources"- putDef "debug_package" "%{nil}"- putNewline+ -- let eCsources = concatMap (cSources . buildInfo) $ executables pkgDesc+ -- let lCsources = concatMap (cSources . libBuildInfo) $ maybeToList $ library pkgDesc+ -- when (null $ eCsources ++ lCsources) $ do+ -- put "# no useful debuginfo for Haskell packages without C sources"+ -- putDef "debug_package" "%{nil}"+ -- putNewline putHdr "Name" (if binlib then "%{pkg_name}" else basename) putHdr "Version" version@@ -263,10 +262,11 @@ put "%install" put $ "%ghc_" ++ pkgType ++ "_install"++ let execs = sort $ map exeName $ executables pkgDesc when selfdep $ do- let execs = map exeName $ executables pkgDesc putNewline- put $ "%ghc_fix_dynamic_rpath" +-+ intercalate " " execs+ put $ "%ghc_fix_dynamic_rpath" +-+ intercalate " " (map (\ p -> if p == name then "%{pkg_name}" else p) execs) putNewline putNewline @@ -305,9 +305,7 @@ unless (null docs) $ put $ "%doc" +-+ unwords docs - withExe pkgDesc $ \exe ->- let program = exeName exe in- put $ "%{_bindir}/" ++ (if program == name then "%{name}" else program)+ mapM_ (\ p -> put $ "%{_bindir}/" ++ (if p == name then "%{name}" else p)) execs unless (null (dataFiles pkgDesc)) $ put "%{_datadir}/%{name}-%{version}" @@ -329,10 +327,8 @@ when (distro /= Fedora) $ put "%defattr(-,root,root,-)" unless (null docs) $ put $ "%doc" +-+ unwords docs- when (not binlib && hasExec) $- withExe pkgDesc $ \exe ->- let program = exeName exe in- put $ "%{_bindir}/" ++ (if program == name then "%{pkg_name}" else program)+ when (not binlib) $+ mapM_ (\ p -> put $ "%{_bindir}/" ++ (if p == name then "%{pkg_name}" else p)) execs putNewline putNewline
src/Commands/Update.hs view
@@ -27,35 +27,35 @@ import Distribution.PackageDescription (PackageDescription (..)) import Distribution.Simple.Utils (die) -import System.Directory (createDirectory, getCurrentDirectory,- setCurrentDirectory)+import System.Directory (createDirectory, setCurrentDirectory) update :: PackageData -> RpmFlags -> IO () update pkgdata flags = case specFilename pkgdata of Nothing -> die "No (unique) .spec file in directory." Just spec -> do- withTempDirectory $ \cwd -> do- let pkg = package $ packageDesc pkgdata- name = packageName pkg- ver = packageVersion pkg- current = name ++ "-" ++ ver- curspec <- createSpecVersion current spec- latest <- latestPkg name- if current == latest- then error $ current +-+ "is latest version."- else do+ let pkg = package $ packageDesc pkgdata+ name = packageName pkg+ ver = packageVersion pkg+ current = name ++ "-" ++ ver+ latest <- latestPkg name+ if current == latest+ then error $ current +-+ "is latest version."+ else do+ bringTarball latest+ pkgGit <- isGitDir "."+ when pkgGit $+ cmd_ "fedpkg" ["new-sources", latest ++ ".tar.gz"]+ withTempDirectory $ \cwd -> do+ curspec <- createSpecVersion current spec newspec <- createSpecVersion latest spec- getCurrentDirectory >>= putStrLn- shell $ "diff -u1 -I \"- spec file generated by cabal-rpm\" -I \"Fedora Haskell SIG <haskell@lists.fedoraproject.org>\"" +-+ curspec +-+ newspec +-+ "| patch -d" +-+ cwd +-+ "-p1"+ shell $ "diff -u1 -I \"- spec file generated by cabal-rpm\" -I \"Fedora Haskell SIG <haskell@lists.fedoraproject.org>\"" +-+ curspec +-+ newspec +-+ "| patch -d" +-+ cwd +-+ "-p1" +-+ "|| :" setCurrentDirectory cwd cmd_ "sed" ["-i", "-e s/^\\(Release: \\).*/\\10%{?dist}/", spec] let newver = removePrefix (name ++ "-") latest cmd_ "rpmdev-bumpspec" ["-c", "update to" +-+ newver, spec]- bringTarball latest- pkgGit <- isGitDir cwd when pkgGit $- cmd_ "fedpkg" ["new-sources", latest ++ ".tar.gz"]+ cmd_ "git" ["commit", "-a", "-m", "update to" +-+ newver] where createSpecVersion :: String -> String -> IO FilePath createSpecVersion ver spec = do
src/PackageUtils.hs view
@@ -245,7 +245,7 @@ checkForSpecFile :: Maybe String -> IO (Maybe FilePath) checkForSpecFile Nothing = do- specs <- filesWithExtension "." ".spec"+ specs <- filter (\ f -> head f /= '.') <$> filesWithExtension "." ".spec" case specs of [one] -> return $ Just one _ -> return Nothing
src/SysCmd.hs view
@@ -28,7 +28,7 @@ yumInstall, (+-+)) where -import Control.Monad (void, when)+import Control.Monad (unless, void, when) import Data.Functor ((<$>)) import Data.List ((\\)) import Data.Maybe (fromMaybe, isJust, isNothing)@@ -128,22 +128,26 @@ if not (null missing) && hard then error $ unwords missing +-+ "not available." else do- putStrLn "Uninstalled dependencies:"- mapM_ putStrLn pkgs- uid <- getEffectiveUserID- maybeSudo <-- if uid == 0- then return Nothing- 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- 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+ unless (null missing) $ do+ putStrLn "Unavailable dependencies:"+ mapM_ putStrLn missing+ unless (null repopkgs) $ do+ putStrLn "Uninstalled dependencies:"+ mapM_ putStrLn repopkgs+ uid <- getEffectiveUserID+ maybeSudo <-+ if uid == 0+ then return Nothing+ 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+ 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 showPkg :: String -> String showPkg p = if '(' `elem` p then show p else p