cabal-rpm 0.10.1 → 0.11
raw patch · 19 files changed
+420/−290 lines, 19 files
Files
- ChangeLog +11/−0
- README.md +24/−10
- cabal-rpm.cabal +7/−6
- man/cabal-rpm.1 +6/−5
- man/cabal-rpm.1.md +2/−1
- src/Commands/Depends.hs +6/−3
- src/Commands/Diff.hs +10/−7
- src/Commands/Install.hs +5/−2
- src/Commands/Refresh.hs +47/−9
- src/Commands/RpmBuild.hs +3/−10
- src/Commands/Spec.hs +30/−35
- src/Commands/Update.hs +13/−8
- src/Dependencies.hs +16/−3
- src/FileUtils.hs +12/−1
- src/Main.hs +5/−5
- src/Options.hs +158/−0
- src/PackageUtils.hs +55/−20
- src/Setup.hs +0/−159
- src/SysCmd.hs +10/−6
ChangeLog view
@@ -1,3 +1,14 @@+* 0.11 (2017-01-27)+- refresh command now reads the cabal-rpm version header in the spec file and+ installs that version of cabal-rpm under ~/.cblrpm/ and uses it to make patch+- diff and update now follow package-version args+- update tries to use stackage-query to check latest Stackage version+ before falling back to latest Hackage+- update from Hackage now follows "Default available version"+- sync some changes from opensuse-haskell/cabal-rpm+- rename Setup to Options+- silence <$> import warnings+ * 0.10.1 (2016-11-29) - no longer need to remove License file by hand - use new %ghc_fix_rpath
README.md view
@@ -18,8 +18,7 @@ ## 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 ghc7),-but it should not be hard to patch it to build at least for ghc-6.12.+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)@@ -30,36 +29,51 @@ ## Usage To create a `.spec` file for a Haskell src package in the current dir: - $ cblrpm spec+ $ cabal-rpm spec or directly on a `.cabal` file: - $ cblrpm spec path/to/mypkg.cabal+ $ cabal-rpm spec path/to/mypkg.cabal or on a package source dir: - $ cblrpm spec mypkg-0.1+ $ cabal-rpm spec mypkg-0.1 You can also package directly from hackage: - $ cblrpm srpm somepkg+ $ cabal-rpm srpm somepkg or - $ cblrpm local somepkg-0.1+ $ cabal-rpm local somepkg-0.1 -will unpack the (latest) 'somepkg' package from hackage+will unpack 'somepkg-0.1' from hackage (if the dir does not exist, otherwise it uses the existing dir), create a spec file for it, and build it. -cblrpm creates `.spec` files in the current dir+cabal-rpm creates `.spec` files in the current dir and if a `.spec` file already exists it will append `.cblrpm` to the generated filename to avoid overwriting an existing file. - $ cblrpm install [pkg][-ver]+ $ cabal-rpm install [pkg][-ver] will yum/dnf install available missing dependencies and run "cabal install" to build the package.++ $ cabal-rpm diff++diffs the current spec file with a freshly generated spec file.++ $ cabal-rpm update++updates the package to the latest Hackage version++ $ cabal-rpm refresh++updates the spec file to the current cabal-rpm packaging.++There are more commands: prep, builddep, depends, requires, missingdeps.+See the manpage or help output for more details. ## Development The latest source code is available from: https://github.com/juhp/cabal-rpm
cabal-rpm.cabal view
@@ -1,5 +1,5 @@ Name: cabal-rpm-Version: 0.10.1+Version: 0.11 Synopsis: RPM packaging tool for Haskell Cabal-based packages Description: This package provides a RPM packaging tool for Haskell Cabal-based packages.@@ -8,16 +8,17 @@ 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- to latest version from Hackage.+ with a freshly generated one, the update command updates the spec file+ to latest version from Hackage, and the refresh command updates the+ spec file to the current cabal-rpm packaging. Homepage: https://github.com/juhp/cabal-rpm Bug-reports: https://github.com/juhp/cabal-rpm/issues License: GPL-3 License-file: COPYING Author: Jens Petersen <juhp@community.haskell.org>, Bryan O'Sullivan <bos@serpentine.com>-Maintainer: Jens Petersen <petersen@fedoraproject.org>+Maintainer: Jens Petersen <juhpetersen@gmail.com> Copyright: 2007-2008 Bryan O'Sullivan <bos@serpentine.com>,- 2012-2016 Jens Petersen <petersen@fedoraproject.org>+ 2012-2017 Jens Petersen <petersen@fedoraproject.org> Category: Distribution Build-type: Simple Extra-source-files: README.md ChangeLog man/cabal-rpm.1.md man/cabal-rpm.1@@ -57,8 +58,8 @@ Dependencies, Distro, FileUtils,+ Options, PackageUtils,- Setup, SysCmd Hs-Source-Dirs: src GHC-options: -fwarn-missing-signatures -Wall
man/cabal-rpm.1 view
@@ -1,4 +1,4 @@-.\" Automatically generated by Pandoc 1.17.2+.\" Automatically generated by Pandoc 1.19.1 .\" .TH "CBLRPM" "1" "2013\-01\-21" "" "" .hy@@ -17,17 +17,18 @@ [\f[I]options\f[]] requires [\f[I]path\-or\-pkg\f[]] cblrpm [\f[I]options\f[]] missingdeps [\f[I]path\-or\-pkg\f[]] cblrpm [\f[I]options\f[]] diff [\f[I]path\-or\-pkg\f[]] cblrpm-[\f[I]options\f[]] update [\f[I]path\-or\-pkg\f[]]+[\f[I]options\f[]] update [\f[I]path\-or\-pkg\f[]] cblrpm+[\f[I]options\f[]] refresh [\f[I]path\-or\-pkg\f[]] .SH DESCRIPTION .PP cblrpm generates RPM packages and .spec files from Haskell Cabal package. .PP If no \f[I]path\-or\-pkg\f[] is specified, cblrpm looks for a .spec or-.cabal file in the current directory.+\&.cabal file in the current directory. Otherwise, it will look for \f[I]path\-or\-pkg\f[]. If the argument is a directory then it will look there for a .spec or-.cabal file.+\&.cabal file. If the argument is a path to a .cabal file then it will use it. Otherwise if there is no \[aq]/\[aq] in the argument and it does not exist then cblrpm will try to unpack the package and use its .cabal@@ -71,7 +72,7 @@ .SH EXAMPLES .PP Below CMD can be one of: spec, srpm, prep, local, install, diff,-builddep, depends, requires, missingdeps, update+builddep, depends, requires, missingdeps, update, refresh .PP Do CMD for the package in current directory: .IP
man/cabal-rpm.1.md view
@@ -17,6 +17,7 @@ cblrpm [*options*] missingdeps [*path-or-pkg*] cblrpm [*options*] diff [*path-or-pkg*] cblrpm [*options*] update [*path-or-pkg*]+cblrpm [*options*] refresh [*path-or-pkg*] # DESCRIPTION cblrpm generates RPM packages and .spec files from Haskell Cabal package.@@ -55,7 +56,7 @@ # EXAMPLES Below CMD can be one of: spec, srpm, prep, local, install, diff, builddep, depends, requires,- missingdeps, update+ missingdeps, update, refresh Do CMD for the package in current directory:
src/Commands/Depends.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Commands.Depends--- Copyright : (C) 2014-2015 Jens Petersen+-- Copyright : (C) 2014-2017 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -18,11 +18,14 @@ ) where import Dependencies (dependencies, missingPackages, packageDependencies)+import Options (quiet) import PackageUtils (PackageData (..), prepare, stripPkgDevel)-import Setup (quiet) import SysCmd (repoquery, (+-+)) +#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else import Control.Applicative ((<$>))+#endif import Control.Monad (filterM, unless, void) import Data.List (nub, sort, (\\)) import System.Directory (removeDirectoryRecursive)@@ -65,7 +68,7 @@ missingDepsPkg :: String -> IO [String] missingDepsPkg pkg = do- pkgdata <- prepare (Just pkg) quiet+ pkgdata <- prepare quiet (Just pkg) maybe (return ()) removeDirectoryRecursive $ workingDir pkgdata missingPackages (packageDesc pkgdata) >>= filterM notAvail
src/Commands/Diff.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Commands.Diff--- Copyright : (C) 2014 Jens Petersen+-- Copyright : (C) 2014,2017 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -18,21 +18,24 @@ ) where import Commands.Spec (createSpecFile)-import FileUtils (mktempdir)-import PackageUtils (PackageData (..))-import Setup (RpmFlags (..))+import FileUtils (mktempdir, withCurrentDirectory)+import Options (RpmFlags (..))+import PackageUtils (PackageData (..), prepare) import SysCmd ((+-+), shell) +import Data.Maybe (isNothing) import Distribution.Simple.Utils (die) import System.Directory (removeDirectoryRecursive) -diff :: PackageData -> RpmFlags -> IO ()-diff pkgdata flags =+diff :: PackageData -> RpmFlags -> Maybe String -> IO ()+diff pkgdata flags mpkg = case specFilename pkgdata of Nothing -> die "No (unique) .spec file in directory." Just spec -> do tmpdir <- mktempdir- speccblrpm <- createSpecFile pkgdata flags (Just tmpdir)+ pd <- if isNothing mpkg then return pkgdata+ else withCurrentDirectory tmpdir $ prepare flags mpkg+ speccblrpm <- createSpecFile pd flags (Just tmpdir) shell $ "diff" +-+ "-u" +-+ spec +-+ speccblrpm +-+ "| sed -e s%" ++ speccblrpm ++ "%" ++ spec ++ ".cblrpm" ++ "%" removeDirectoryRecursive tmpdir
src/Commands/Install.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Commands.Install--- Copyright : (C) 2012-2015 Jens Petersen+-- Copyright : (C) 2012-2016 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -19,11 +19,14 @@ import Commands.RpmBuild (rpmBuild) import Dependencies (missingPackages, notInstalled)+import Options (RpmFlags (..)) import PackageUtils (PackageData (..), RpmStage (..), stripPkgDevel)-import Setup (RpmFlags (..)) import SysCmd (cmd, cmd_, pkgInstall, rpmInstall, (+-+)) +#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else import Control.Applicative ((<$>))+#endif import Control.Monad (unless, when) import System.FilePath ((</>))
src/Commands/Refresh.hs view
@@ -16,29 +16,67 @@ ) where import Commands.Spec (createSpecFile)-import PackageUtils (PackageData (..))-import Setup (RpmFlags (..))-import SysCmd (cmd_, shell, (+-+))+import FileUtils (withTempDirectory)+import Options (RpmFlags (..))+import PackageUtils (PackageData (..), removePrefix)+import SysCmd (cmd_, optionalProgram, shell, (+-+)) +#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else+import Control.Applicative ((<$>))+#endif+import Control.Monad (unless)+import Data.List (isPrefixOf) import Distribution.Simple.Utils (die)+import System.Directory (copyFile, createDirectoryIfMissing, doesFileExist,+ setCurrentDirectory)+import System.Environment (getEnv)+import System.FilePath ((</>)) refresh :: PackageData -> RpmFlags -> IO () refresh pkgdata flags = case specFilename pkgdata of Nothing -> die "No (unique) .spec file in directory." Just spec -> do- -- FIXME: later this should read the cabal-rpm version header line- oldspec <- createOldSpec "0.9.6" spec- newspec <- createSpecFile pkgdata flags Nothing- shell $ "diff -u2 -I \"- spec file generated by cabal-rpm\" -I \"Fedora Haskell SIG <haskell@lists.fedoraproject.org>\"" +-+ oldspec +-+ newspec +-+ "| sed -e 's/.cblrpm//' | patch" +-+ "|| :"+ first <- head . lines <$> readFile spec+ if "# generated by cabal-rpm-" `isPrefixOf` first+ then do+ let cblrpmver = removePrefix "# generated by cabal-rpm-" first+ oldspec <- createOldSpec cblrpmver spec+ newspec <- createSpecFile pkgdata flags Nothing+ shell $ "diff -u2 -I \"- spec file generated by cabal-rpm\" -I \"Fedora Haskell SIG <haskell@lists.fedoraproject.org>\"" +-+ oldspec +-+ newspec +-+ "| sed -e 's/.cblrpm//' | patch" +-+ "|| :"+ else putStrLn $ "No cabal-rpm header line in" +-+ spec -- setCurrentDirectory cwd -- when rwGit $ -- cmd_ "git" ["commit", "-a", "-m", "update to" +-+ newver] where- createOldSpec :: String -> String -> IO FilePath+ createOldSpec :: String -> FilePath -> IO FilePath createOldSpec crVer spec = do- cmd_ ("cabal-rpm-" ++ crVer) ["spec"]+ cblrpmVersion crVer let backup = spec ++ ".cblrpm" backup' = backup ++ "-" ++ crVer cmd_ "mv" [backup, backup'] return backup'++ cblrpmVersion :: String -> IO ()+ cblrpmVersion crver = do+ let cblrpmver = "cabal-rpm-" ++ crver+ inpath <- optionalProgram cblrpmver+ if inpath+ then cmd_ cblrpmver ["spec"]+ else do+ home <- getEnv "HOME"+ let bindir = home </> ".cblrpm/versions/"+ haveExe <- doesFileExist $ bindir </> cblrpmver+ unless haveExe $+ withTempDirectory $ \cwd -> do+ cmd_ "cabal" ["unpack", cblrpmver]+ setCurrentDirectory cblrpmver+ cmd_ "cabal" ["configure"]+ cmd_ "cabal" ["build"]+ createDirectoryIfMissing True bindir+ let bin = "dist/build/cabal-rpm/cabal-rpm"+ cmd_ "strip" [bin]+ copyFile bin $ bindir </> cblrpmver+ setCurrentDirectory cwd+ cmd_ (bindir </> cblrpmver) ["spec"]
src/Commands/RpmBuild.hs view
@@ -1,7 +1,7 @@ -- | -- Module : Commands.RpmBuild -- Copyright : (C) 2007-2008 Bryan O'Sullivan--- (C) 2012-2015 Jens Petersen+-- (C) 2012-2016 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -21,9 +21,9 @@ import Commands.Spec (createSpecFile) import Dependencies (missingPackages)+import Options (RpmFlags (..)) import PackageUtils (copyTarball, isScmDir, PackageData (..), packageName, packageVersion, rpmbuild, RpmStage (..))-import Setup (RpmFlags (..)) import SysCmd (cmd, pkgInstall, (+-+)) --import Control.Exception (bracket)@@ -33,7 +33,7 @@ --import Distribution.Version (VersionRange, foldVersionRange') -import System.Directory (copyFile, doesFileExist)+import System.Directory (doesFileExist) import System.FilePath (takeDirectory, (</>)) -- autoreconf :: Verbosity -> PackageDescription -> IO ()@@ -75,13 +75,6 @@ error "No tarball for source repo" copyTarball name version False srcdir-- let revision = maybe (0::Int) read (lookup "x-revision" (customFieldsPD pkgDesc))- cabalFile = srcdir </> show revision ++ ".cabal"-- cabalFileExists <- doesFileExist cabalFile- unless cabalFileExists $- copyFile cabalPath cabalFile rpmbuild stage False Nothing specFile return specFile
src/Commands/Spec.hs view
@@ -23,12 +23,15 @@ import Dependencies (notInstalled, packageDependencies, showDep, testsuiteDependencies) import Distro (Distro(..), detectDistro)+import Options (RpmFlags (..)) import PackageUtils (getPkgName, isScmDir, PackageData (..), packageName, packageVersion)-import Setup (RpmFlags (..)) import SysCmd ((+-+)) +#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else import Control.Applicative ((<$>))+#endif import Control.Monad (filterM, unless, void, when) import Data.Char (toLower, toUpper) import Data.List (groupBy, intercalate, intersect, isPrefixOf, isSuffixOf,@@ -43,12 +46,12 @@ import Distribution.Simple.Utils (notice, warn) import Distribution.PackageDescription (BuildInfo (..), PackageDescription (..),- Executable (..),+ Executable (..), FlagName (..), exeName, hasExes, hasLibs) --import Distribution.Version (VersionRange, foldVersionRange') -import System.Directory (copyFile, doesFileExist, getDirectoryContents)+import System.Directory (doesFileExist, getDirectoryContents) import System.IO (IOMode (..), hClose, hPutStrLn, openFile) #if defined(MIN_VERSION_time) && MIN_VERSION_time(1,5,0) import Data.Time.Format (defaultTimeLocale)@@ -110,6 +113,7 @@ let putHdr hdr val = hPutStrLn h (hdr ++ ":" ++ padding hdr ++ val) padding hdr = replicate (14 - length hdr) ' ' ++ " " putNewline = hPutStrLn h ""+ sectionNewline = putNewline >> putNewline put = hPutStrLn h putDef v s = put $ "%global" +-+ v +-+ s ghcPkg = if binlib then "-n ghc-%{name}" else ""@@ -189,8 +193,7 @@ putHdr "Release" $ release ++ (if distro == SUSE then [] else "%{?dist}") putHdr "Summary" summary case distro of- SUSE -> putHdr "Group" (if binlib then "Development/Languages/Other"- else "System/Libraries")+ SUSE -> putHdr "Group" "Development/Languages/Other" RHEL5 -> putHdr "Group" (if binlib then "Development/Languages" else "System Environment/Libraries") _ -> return ()@@ -200,7 +203,7 @@ putHdr "Source0" $ "https://hackage.haskell.org/package/" ++ pkg_name ++ "-%{version}/" ++ pkg_name ++ "-%{version}.tar.gz" when (revision /= "0") $ if distro == SUSE- then putHdr "Source1" $ "https://hackage.haskell.org/package/" ++ pkg_name ++ "-%{version}/revision/" ++ revision ++ ".cabal"+ then putHdr "Source1" $ "https://hackage.haskell.org/package/" ++ pkg_name ++ "-%{version}/revision/" ++ revision ++ ".cabal#/" ++ pkg_name ++ ".cabal" else putStrLn "Warning: this is a revised .cabal file" case distro of Fedora -> return ()@@ -268,20 +271,17 @@ put "%prep" put $ "%setup -q" ++ (if pkgname /= name then " -n %{pkg_name}-%{version}" else "")- when (distro == SUSE && revision /= "0") $ do- let revised = revision ++ ".cabal"+ when (distro == SUSE && revision /= "0") $ put $ "cp -p %{SOURCE1}" +-+ pkg_name ++ ".cabal"- copied <- doesFileExist revised- unless copied $- copyFile cabalPath revised- putNewline- putNewline+ sectionNewline put "%build"+ when (distro == SUSE && rpmConfigurationsFlags flags /= []) $ do+ let cabalFlags = [ "-f" ++ (if b then "" else "-") ++ n | (FlagName n, b) <- rpmConfigurationsFlags flags ]+ put $ "%define cabal_configure_options " ++ unwords cabalFlags let pkgType = if hasLib then "lib" else "bin" put $ "%ghc_" ++ pkgType ++ "_build"- putNewline- putNewline+ sectionNewline put "%install" put $ "%ghc_" ++ pkgType ++ "_install"@@ -302,6 +302,7 @@ let datafiles = dataFiles pkgDesc dupdocs = docs `intersect` datafiles unless (null dupdocs) $ do+ putNewline putStrLn $ "Warning: doc files found in datadir:" +-+ unwords dupdocs unless (distro == SUSE) $ put $ "rm %{buildroot}%{_datadir}/" ++ pkg_name ++ "-%{version}/" ++@@ -309,24 +310,21 @@ 1 -> head dupdocs _ -> "{" ++ intercalate "," dupdocs ++ "}" - putNewline- putNewline+ sectionNewline unless (null testsuiteDeps) $ do put "%check" put "%cabal_test"- putNewline- putNewline+ sectionNewline when hasLib $ do- let putInstallScript = do- put "%ghc_pkg_recache"- putNewline- putNewline put $ "%post" +-+ ghcPkgDevel- putInstallScript+ put "%ghc_pkg_recache"+ sectionNewline+ put $ "%postun" +-+ ghcPkgDevel- putInstallScript+ put "%ghc_pkg_recache"+ sectionNewline let license_macro = if distro == Fedora then "%license" else "%doc" let execs = sort $ map exeName $ filter isBuildable $ executables pkgDesc@@ -339,13 +337,11 @@ mapM_ (\ l -> put $ license_macro +-+ l) licensefiles unless (null docs) $ put $ "%doc" +-+ unwords docs- mapM_ (\ p -> put $ "%{_bindir}/" ++ (if p == name then "%{name}" else p)) execs unless (null datafiles) $ put $ "%{_datadir}/" ++ pkg_name ++ "-%{version}" - putNewline- putNewline+ sectionNewline when hasLib $ do let baseFiles = if binlib then "-f ghc-%{name}.files" else "-f %{name}.files"@@ -353,20 +349,18 @@ put $ "%files" +-+ ghcPkg +-+ baseFiles when (distro /= Fedora) $ put "%defattr(-,root,root,-)" mapM_ (\ l -> put $ license_macro +-+ l) licensefiles- when (not binlib && distro == SUSE) $+ when (distro == SUSE && not binlib) $ mapM_ (\ p -> put $ "%{_bindir}/" ++ (if p == name then "%{pkg_name}" else p)) execs unless (null datafiles || binlib) $ put $ "%{_datadir}/" ++ pkg_name ++ "-%{version}"- putNewline- putNewline+ sectionNewline put $ "%files" +-+ ghcPkgDevel +-+ develFiles when (distro /= Fedora) $ put "%defattr(-,root,root,-)" unless (null docs) $ put $ "%doc" +-+ unwords docs- when (not binlib && distro /= SUSE) $+ when (distro /= SUSE && not binlib) $ mapM_ (\ p -> put $ "%{_bindir}/" ++ (if p == name then "%{pkg_name}" else p)) execs- putNewline- putNewline+ sectionNewline put "%changelog" unless (distro == SUSE) $ do@@ -421,7 +415,7 @@ #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,16,0) showLicense SUSE (Apache Nothing) = "Apache-2.0" showLicense _ (Apache Nothing) = "ASL ?"-showLicense SUSE (Apache (Just ver)) = "Apache-" +-+ showVersion ver+showLicense SUSE (Apache (Just ver)) = "Apache-" ++ showVersion ver showLicense _ (Apache (Just ver)) = "ASL" +-+ showVersion ver #endif #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,18,0)@@ -431,6 +425,7 @@ #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,20,0) showLicense SUSE BSD2 = "BSD-2-Clause" showLicense _ BSD2 = "BSD"+showLicense SUSE (MPL ver) = "MPL-" ++ showVersion ver showLicense _ (MPL ver) = "MPLv" ++ showVersion ver #endif #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,22,0)
src/Commands/Update.hs view
@@ -1,6 +1,6 @@ -- | -- Module : Commands.Update--- Copyright : (C) 2014-2016 Jens Petersen+-- Copyright : (C) 2014-2017 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -19,11 +19,14 @@ import Commands.Spec (createSpecFile) import Distro (detectDistro, Distro(..)) import FileUtils (withTempDirectory)-import PackageUtils (PackageData (..), bringTarball, isGitDir, latestPkg,+import Options (RpmFlags (..))+import PackageUtils (PackageData (..), bringTarball, isGitDir, latestPackage, packageName, packageVersion, prepare, removePrefix)-import Setup (RpmFlags (..)) import SysCmd (cmd_, cmdBool, cmdIgnoreErr, (+-+))+#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else import Control.Applicative ((<$>))+#endif import Control.Monad (when) import Distribution.PackageDescription (PackageDescription (..)) import Distribution.Simple.Utils (die)@@ -31,8 +34,8 @@ import System.Directory (createDirectory, getCurrentDirectory, setCurrentDirectory) -update :: PackageData -> RpmFlags -> IO ()-update pkgdata flags =+update :: PackageData -> RpmFlags -> Maybe String -> IO ()+update pkgdata flags mpkgver = case specFilename pkgdata of Nothing -> die "No (unique) .spec file in directory." Just spec -> do@@ -40,9 +43,11 @@ name = packageName pkg ver = packageVersion pkg current = name ++ "-" ++ ver- latest <- latestPkg name+ latest <- case mpkgver of+ Just pv -> return pv+ Nothing -> latestPackage name if current == latest- then error $ current +-+ "is latest version."+ then error $ current +-+ "is already latest version." else do bringTarball latest gitDir <- getCurrentDirectory >>= isGitDir@@ -69,7 +74,7 @@ where createSpecVersion :: String -> String -> IO FilePath createSpecVersion ver spec = do- pkgdata' <- prepare (Just ver) flags+ pkgdata' <- prepare flags (Just ver) let pkgdata'' = pkgdata' { specFilename = Just spec } createDirectory ver createSpecFile pkgdata'' flags (Just ver)
src/Dependencies.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ -- | -- Module : Dependencies -- Copyright : (C) 2012-2016 Jens Petersen@@ -25,7 +27,10 @@ import PackageUtils (packageName) import SysCmd (cmd, cmdBool, repoquery, (+-+)) +#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else import Control.Applicative ((<$>))+#endif import Control.Monad (filterM, when) import Data.List (delete, nub)@@ -36,7 +41,11 @@ allBuildInfo, BuildInfo (..), TestSuite (..),- hasExes)+ hasExes, +#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,24,0)+ setupDepends+#endif+ ) import System.Directory (doesDirectoryExist, doesFileExist) import System.IO (hPutStrLn, stderr) @@ -46,8 +55,12 @@ -- returns list of deps and whether package is self-dependent buildDependencies :: PackageDescription -> String -> ([String], Bool) buildDependencies pkgDesc self =- let deps = nub $ map depName (buildDepends pkgDesc) in- (filter excludedPkgs (delete self deps), self `elem` deps && hasExes pkgDesc)+ let deps = nub $ map depName (buildDepends pkgDesc)+#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,24,0)+ ++ (maybe [] (map depName . setupDepends) (setupBuildInfo pkgDesc))+#endif+ in+ (filter excludedPkgs (delete self deps), self `elem` deps && hasExes pkgDesc) depName :: Dependency -> String depName (Dependency (PackageName n) _) = n
src/FileUtils.hs view
@@ -1,6 +1,6 @@ -- | -- Module : FileUtils--- Copyright : (C) 2014 Jens Petersen+-- Copyright : (C) 2014, 2016-2017 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -20,11 +20,15 @@ fileWithExtension_, getDirectoryContents_, mktempdir,+ withCurrentDirectory, withTempDirectory) where import SysCmd (cmd) +#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else import Control.Applicative ((<$>))+#endif import Control.Exception (bracket) import Data.List (isPrefixOf) import Data.Maybe (isJust)@@ -68,3 +72,10 @@ getDirectoryContents_ :: FilePath -> IO [FilePath] getDirectoryContents_ dir = filter (not . isPrefixOf ".") <$> getDirectoryContents dir++-- from directory-1.2.3.0+withCurrentDirectory :: FilePath -> IO a -> IO a+withCurrentDirectory dir action =+ bracket getCurrentDirectory setCurrentDirectory $ \ _ -> do+ setCurrentDirectory dir+ action
src/Main.hs view
@@ -1,7 +1,7 @@ -- | -- Module : Main -- Copyright : (C) 2007 Bryan O'Sullivan--- (C) 2012-2014 Jens Petersen+-- (C) 2012-2017 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -24,8 +24,8 @@ import Commands.Spec (createSpecFile_) import Commands.Update (update) +import Options (parseArgs) import PackageUtils (prepare, PackageData (..), RpmStage (..))-import Setup (parseArgs) import Control.Exception (bracket) import System.Directory (removeDirectoryRecursive)@@ -34,7 +34,7 @@ main :: IO () main = do (opts, cmd, mpkg) <- getArgs >>= parseArgs- bracket (prepare mpkg opts)+ bracket (prepare opts mpkg) (maybe (return ()) removeDirectoryRecursive . workingDir) (\pkgdata -> case cmd of@@ -44,13 +44,13 @@ "local" -> rpmBuild_ pkgdata opts Binary "build" -> rpmBuild_ pkgdata opts Binary "builddep" -> rpmBuild_ pkgdata opts BuildDep- "diff" -> diff pkgdata opts+ "diff" -> diff pkgdata opts mpkg "install" -> install pkgdata opts "depends" -> depends pkgdata Depends "refresh" -> refresh pkgdata opts "requires" -> depends pkgdata Requires "missingdeps" -> depends pkgdata Missing- "update" -> update pkgdata opts+ "update" -> update pkgdata opts mpkg "rpm" -> do putStrLn "* Warning the 'rpm' command has been renamed to 'local':" putStrLn "* this alias may be removed in a future release."
+ src/Options.hs view
@@ -0,0 +1,158 @@+-- |+-- Module : Options+-- Copyright : (C) 2007-2008 Bryan O'Sullivan+-- (C) 2012-2016 Jens Petersen+--+-- Maintainer : Jens Petersen <petersen@fedoraproject.org>+-- Stability : alpha+-- Portability : portable+--+-- Explanation: Command line option processing for building RPM+-- packages.++-- 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+-- the Free Software Foundation, either version 3 of the License, or+-- (at your option) any later version.++module Options (+ RpmFlags(..)+ , parseArgs+ , quiet+ ) where++import Control.Monad (unless, when)+import Data.Char (toLower)+import Data.Maybe (listToMaybe, fromMaybe)+import Data.Version (showVersion)++import Distribution.Compiler (CompilerId)+import Distribution.Text (simpleParse)+import Distribution.PackageDescription (FlagName (..))+import Distribution.ReadE (readEOrFail)+import Distribution.Verbosity (Verbosity, flagToVerbosity, normal,+ silent)++import System.Console.GetOpt (ArgDescr (..), ArgOrder (..), OptDescr (..),+ getOpt', usageInfo)+import System.Environment (getProgName)+import System.Exit (ExitCode (..), exitSuccess, exitWith)+import System.IO (Handle, hPutStrLn, stderr, stdout)++import Distro (Distro(..), readDistroName)+import Paths_cabal_rpm (version)+import SysCmd ((+-+))++data RpmFlags = RpmFlags+ { rpmConfigurationsFlags :: [(FlagName, Bool)]+ , rpmForce :: Bool+ , rpmHelp :: Bool+ , rpmBinary :: Bool+ , rpmStrict :: Bool+ , rpmRelease :: Maybe String+ , rpmCompilerId :: Maybe CompilerId+ , rpmDistribution :: Maybe Distro+ , rpmVerbosity :: Verbosity+ , rpmVersion :: Bool+ }+ deriving (Eq, Show)++emptyRpmFlags :: RpmFlags+emptyRpmFlags = RpmFlags+ { rpmConfigurationsFlags = []+ , rpmForce = False+ , rpmHelp = False+ , rpmBinary = False+ , rpmStrict = False+ , rpmRelease = Nothing+ , rpmCompilerId = Nothing+ , rpmDistribution = Nothing+ , rpmVerbosity = normal+ , rpmVersion = False+ }++quiet :: RpmFlags+quiet = emptyRpmFlags {rpmVerbosity = silent}++options :: [OptDescr (RpmFlags -> RpmFlags)]+options =+ [ Option "h?" ["help"] (NoArg (\x -> x { rpmHelp = True }))+ "Show this help text"+ , Option "b" ["binary"] (NoArg (\x -> x { rpmBinary = True }))+ "Force Haskell package name to be base package name"+ , Option "" ["force"] (NoArg (\x -> x { rpmForce = True }))+ "Overwrite existing spec file."+ , Option "" ["strict"] (NoArg (\x -> x { rpmStrict = True }))+ "Fail rather than produce an incomplete spec file."+ , Option "V" ["version"] (NoArg (\x -> x { rpmVersion = True }))+ "Show version number"+ , Option "f" ["flags"] (ReqArg (\flags x -> x { rpmConfigurationsFlags = rpmConfigurationsFlags x ++ flagList flags }) "FLAGS")+ "Set given flags in Cabal conditionals"+ , Option "" ["release"] (ReqArg (\rel x -> x { rpmRelease = Just rel }) "RELEASE")+ "Override the default package release"+ , Option "" ["compiler"] (ReqArg (\cid x -> x { rpmCompilerId = Just (parseCompilerId cid) }) "COMPILER-ID")+ "Finalize Cabal files targetting the given compiler version"+ , Option "" ["distro"] (ReqArg (\did x -> x { rpmDistribution = Just (readDistroName did) }) "DISTRO")+ "Choose the distribution generated spec files will target"+ , Option "v" ["verbose"] (ReqArg (\verb x -> x { rpmVerbosity = readEOrFail flagToVerbosity verb }) "n")+ "Change build verbosity"+ ]++-- Lifted from Distribution.Simple.Setup, since it's not exported.+flagList :: String -> [(FlagName, Bool)]+flagList = map tagWithValue . words+ where tagWithValue ('-':name) = (FlagName (map toLower name), False)+ tagWithValue name = (FlagName (map toLower name), True)++printHelp :: Handle -> IO ()+printHelp h = do+ progName <- getProgName+ let info = "Usage: " ++ progName ++ " [OPTION]... COMMAND [PATH|PKG|PKG-VERSION]\n"+ ++ "\n"+ ++ "PATH can be a .spec file, .cabal file, or pkg dir.\n"+ ++ "\n"+ ++ "Commands:\n"+ ++ " spec\t\t- generate a spec file\n"+ ++ " srpm\t\t- generate a src rpm file\n"+ ++ " prep\t\t- unpack source\n"+ ++ " local\t\t- build rpm package locally\n"+ ++ " builddep\t- install dependencies\n"+ ++ " install\t- install packages recursively\n"+ ++ " depends\t- list Cabal depends\n"+ ++ " requires\t- list package buildrequires\n"+ ++ " missingdeps\t- list missing buildrequires\n"+ ++ " diff\t\t- diff current spec file\n"+ ++ " update\t- update spec file package to latest version\n"+ ++ " refresh\t- refresh spec file to current cblrpm\n"+ ++ "\n"+ ++ "Options:"+ hPutStrLn h (usageInfo info options)++parseCompilerId :: String -> CompilerId+parseCompilerId x = fromMaybe err (simpleParse x)+ where err = error (show x ++ " is not a valid compiler id")++parseArgs :: [String] -> IO (RpmFlags, String, Maybe String)+parseArgs args = do+ let (os, args', unknown, errs) = getOpt' Permute options args+ opts = foldl (flip ($)) emptyRpmFlags os+ when (rpmHelp opts) $ do+ printHelp stdout+ exitSuccess+ when (rpmVersion opts) $ do+ putStrLn $ showVersion version+ exitSuccess+ unless (null errs) $+ error $ unlines errs+ unless (null unknown) $+ error $ "Unrecognised options:" +-+ unwords unknown+ when (null args') $ do+ printHelp stderr+ exitWith (ExitFailure 1)+ when (head args' `notElem` ["builddep", "depends", "diff", "install", "missingdeps", "prep", "requires", "spec", "srpm", "build", "local", "rpm", "update", "refresh"]) $ do+ hPutStrLn stderr $ "Unknown command:" +-+ head args'+ printHelp stderr+ exitWith (ExitFailure 1)+ when (length args' > 2) $+ error $ "Too many arguments:" +-+ unwords args'+ return (opts, head args', listToMaybe $ tail args')
src/PackageUtils.hs view
@@ -1,6 +1,6 @@ -- | -- Module : PackageUtils--- Copyright : (C) 2013-2015 Jens Petersen+-- Copyright : (C) 2013-2017 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -15,12 +15,11 @@ module PackageUtils ( bringTarball,- checkForSpecFile, copyTarball, getPkgName, isGitDir, isScmDir,- latestPkg,+ latestPackage, PackageData (..), packageName, packageVersion,@@ -34,14 +33,17 @@ import FileUtils (filesWithExtension, fileWithExtension, getDirectoryContents_, mktempdir)-import Setup (RpmFlags (..))-import SysCmd (cmd, cmd_, cmdSilent, (+-+))+import Options (RpmFlags (..))+import SysCmd (cmd, cmd_, cmdSilent, (+-+), optionalProgram) +#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else import Control.Applicative ((<$>))+#endif import Control.Monad (filterM, unless, when) import Data.Char (isDigit)-import Data.List (stripPrefix)+import Data.List (isPrefixOf, stripPrefix) import Data.Maybe (fromMaybe, isJust) import Data.Version (showVersion) @@ -211,7 +213,7 @@ tryUnpack :: String -> IO (FilePath, Maybe FilePath) tryUnpack pkg = do- pkgver <- if stripVersion pkg == pkg then latestPkg pkg else return pkg+ pkgver <- if stripVersion pkg == pkg then latestPackage pkg else return pkg isdir <- doesDirectoryExist pkgver if isdir then do@@ -226,14 +228,44 @@ setCurrentDirectory cwd return (tmpdir </> pth, Just tmpdir) -latestPkg :: String -> IO String-latestPkg pkg = do- contains_pkg <- lines <$> cmd "cabal" ["list", "-v0", "--simple-output", pkg]- let pkgs = filter ((== pkg) . takeWhile (/= ' ')) contains_pkg- if null pkgs- then error $ pkg ++ " hackage not found"- else return $ map (\c -> if c == ' ' then '-' else c) $ last pkgs+latestPackage :: String -> IO String+latestPackage pkg = do+ stk <- latestStackage pkg+ case stk of+ Just pv -> return pv+ Nothing -> latestHackage pkg +latestHackage :: String -> IO String+latestHackage pkg = do+ contains_pkg <- lines <$> cmd "cabal" ["list", "-v0", pkg]+ let top = dropWhile (/= "*" +-+ pkg) contains_pkg+ if null top+ then error $ pkg +-+ "hackage not found"+ else do+ let field = " Default available version: "+ let avails = map (removePrefix field) $ filter (isPrefixOf field) top+ if null avails+ then error $ pkg +-+ "latest available version not found"+ else do+ let res = pkg ++ "-" ++ head avails+ putStrLn $ res +-+ "in Hackage"+ return res++latestStackage :: String -> IO (Maybe String)+latestStackage pkg = do+ -- check for stackage-query+ haveStackage <- optionalProgram "stackage"+ if haveStackage+ then do+ let stream = "nightly"+ out <- cmd "stackage" ["list", stream, pkg]+ if null out+ then return Nothing+ else do+ putStrLn $ out +-+ "in Stackage" +-+ stream+ return $ Just out+ else return Nothing+ packageName :: PackageIdentifier -> String packageName pkg = name where PackageName name = pkgName pkg@@ -268,7 +300,7 @@ checkForSpecFile :: Maybe String -> IO (Maybe FilePath) checkForSpecFile Nothing = do -- emacs makes ".#*.spec" tmp files- allSpecs <- filesWithExtension "." ".spec"+ allSpecs <- allSpecfiles let specs = filter (\ f -> head f /= '.') allSpecs when (specs /= allSpecs) $ putStrLn "Warning: dir contains a hidden spec file"@@ -277,11 +309,14 @@ _ -> return Nothing checkForSpecFile (Just pkg) = do let specname = pkg <.> "spec"- specs <- filter (`elem` [specname, "ghc-" ++ specname]) <$> filesWithExtension "." ".spec"+ specs <- filter (`elem` [specname, "ghc-" ++ specname]) <$> allSpecfiles case specs of [one] -> return $ Just one _ -> return Nothing +allSpecfiles :: IO [FilePath]+allSpecfiles = filesWithExtension "." ".spec"+ checkForCabalFile :: String -> IO (Maybe FilePath) checkForCabalFile pkgmver = do let pkg = stripVersion pkgmver@@ -340,9 +375,9 @@ } -- Nothing implies existing packaging in cwd--- Something implies either new packaging or could be multiple spec files in dir-prepare :: Maybe String -> RpmFlags -> IO PackageData-prepare mpkgver flags = do+-- Something implies either new packaging or some existing spec file in dir+prepare :: RpmFlags -> Maybe String -> IO PackageData+prepare flags mpkgver = do let mpkg = stripVersion <$> mpkgver mspec <- checkForSpecFile mpkg case mspec of@@ -354,7 +389,7 @@ case mpkgver of Nothing -> do cwd <- getCurrentDirectory- prepare (Just $ takeFileName cwd) flags+ prepare flags (Just $ takeFileName cwd) Just pkgmver -> do mcabal <- checkForCabalFile pkgmver case mcabal of
− src/Setup.hs
@@ -1,159 +0,0 @@--- |--- Module : Setup--- Copyright : (C) 2007-2008 Bryan O'Sullivan--- (C) 2012-2014 Jens Petersen------ Maintainer : Jens Petersen <petersen@fedoraproject.org>--- Stability : alpha--- Portability : portable------ Explanation: Command line option processing for building RPM--- packages.---- 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--- the Free Software Foundation, either version 3 of the License, or--- (at your option) any later version.--module Setup (- RpmFlags(..)- , parseArgs- , quiet- ) where--import Control.Monad (unless, when)-import Data.Char (toLower)-import Data.Maybe (listToMaybe, fromMaybe)-import Data.Version (showVersion)--import Distribution.Compiler (CompilerId)-import Distribution.Text (simpleParse)-import Distribution.PackageDescription (FlagName (..))-import Distribution.ReadE (readEOrFail)-import Distribution.Verbosity (Verbosity, flagToVerbosity, normal,- silent)--import System.Console.GetOpt (ArgDescr (..), ArgOrder (..), OptDescr (..),- getOpt', usageInfo)-import System.Environment (getProgName)-import System.Exit (ExitCode (..), exitSuccess, exitWith)-import System.IO (Handle, hPutStrLn, stderr, stdout)--import Distro (Distro(..), readDistroName)-import Paths_cabal_rpm (version)-import SysCmd ((+-+))--data RpmFlags = RpmFlags- { rpmConfigurationsFlags :: [(FlagName, Bool)]- , rpmForce :: Bool- , rpmHelp :: Bool- , rpmBinary :: Bool- , rpmStrict :: Bool- , rpmRelease :: Maybe String- , rpmCompilerId :: Maybe CompilerId- , rpmDistribution :: Maybe Distro- , rpmVerbosity :: Verbosity- , rpmVersion :: Bool- }- deriving (Eq, Show)--emptyRpmFlags :: RpmFlags-emptyRpmFlags = RpmFlags- { rpmConfigurationsFlags = []- , rpmForce = False- , rpmHelp = False- , rpmBinary = False- , rpmStrict = False- , rpmRelease = Nothing- , rpmCompilerId = Nothing- , rpmDistribution = Nothing- , rpmVerbosity = normal- , rpmVersion = False- }--quiet :: RpmFlags-quiet = emptyRpmFlags {rpmVerbosity = silent}--options :: [OptDescr (RpmFlags -> RpmFlags)]-options =- [- Option "h?" ["help"] (NoArg (\x -> x { rpmHelp = True }))- "Show this help text",- Option "b" ["binary"] (NoArg (\x -> x { rpmBinary = True }))- "Force Haskell package name to be base package name",- Option "f" ["flags"] (ReqArg (\flags x -> x { rpmConfigurationsFlags = rpmConfigurationsFlags x ++ flagList flags }) "FLAGS")- "Set given flags in Cabal conditionals",- Option "" ["force"] (NoArg (\x -> x { rpmForce = True }))- "Overwrite existing spec file.",- Option "" ["strict"] (NoArg (\x -> x { rpmStrict = True }))- "Fail rather than produce an incomplete spec file.",- Option "" ["release"] (ReqArg (\rel x -> x { rpmRelease = Just rel }) "RELEASE")- "Override the default package release",- Option "" ["compiler"] (ReqArg (\cid x -> x { rpmCompilerId = Just (parseCompilerId cid) }) "COMPILER-ID")- "Finalize Cabal files targetting the given compiler version",- Option "" ["distro"] (ReqArg (\did x -> x { rpmDistribution = Just (readDistroName did) }) "DISTRO")- "Choose the distribution generated spec files will target",- Option "v" ["verbose"] (ReqArg (\verb x -> x { rpmVerbosity = readEOrFail flagToVerbosity verb }) "n")- "Change build verbosity",- Option "V" ["version"] (NoArg (\x -> x { rpmVersion = True }))- "Show version number"- ]---- Lifted from Distribution.Simple.Setup, since it's not exported.-flagList :: String -> [(FlagName, Bool)]-flagList = map tagWithValue . words- where tagWithValue ('-':name) = (FlagName (map toLower name), False)- tagWithValue name = (FlagName (map toLower name), True)--printHelp :: Handle -> IO ()-printHelp h = do- progName <- getProgName- let info = "Usage: " ++ progName ++ " [OPTION]... COMMAND [PATH|PKG|PKG-VERSION]\n"- ++ "\n"- ++ "PATH can be a .spec file, .cabal file, or pkg dir.\n"- ++ "\n"- ++ "Commands:\n"- ++ " spec\t\t- generate a spec file\n"- ++ " srpm\t\t- generate a src rpm file\n"- ++ " prep\t\t- unpack source\n"- ++ " local\t\t- build rpm package locally\n"- ++ " builddep\t- install dependencies\n"- ++ " install\t- install packages recursively\n"- ++ " depends\t- list Cabal depends\n"- ++ " requires\t- list package buildrequires\n"- ++ " missingdeps\t- list missing buildrequires\n"- ++ " diff\t\t- diff current spec file\n"- ++ " update\t- update spec file package to latest version\n"--- ++ " mock\t\t- mock build package\n"- ++ "\n"- ++ "Options:"- hPutStrLn h (usageInfo info options)--parseCompilerId :: String -> CompilerId-parseCompilerId x = fromMaybe err (simpleParse x)- where err = error (show x ++ " is not a valid compiler id")--parseArgs :: [String] -> IO (RpmFlags, String, Maybe String)-parseArgs args = do- let (os, args', unknown, errs) = getOpt' Permute options args- opts = foldl (flip ($)) emptyRpmFlags os- when (rpmHelp opts) $ do- printHelp stdout- exitSuccess- when (rpmVersion opts) $ do- putStrLn $ showVersion version- exitSuccess- unless (null errs) $- error $ unlines errs- unless (null unknown) $- error $ "Unrecognised options:" +-+ unwords unknown- when (null args') $ do- printHelp stderr- exitWith (ExitFailure 1)- when (head args' `notElem` ["builddep", "depends", "diff", "install", "missingdeps", "prep", "requires", "spec", "srpm", "build", "local", "rpm", "update", "refresh"]) $ do- hPutStrLn stderr $ "Unknown command:" +-+ head args'- printHelp stderr- exitWith (ExitFailure 1)- when (length args' > 2) $- error $ "Too many arguments:" +-+ unwords args'- return (opts, head args', listToMaybe $ tail args')
src/SysCmd.hs view
@@ -1,6 +1,6 @@ -- | -- Module : SysCmd--- Copyright : (C) 2013-2015 Jens Petersen+-- Copyright : (C) 2013-2016 Jens Petersen -- -- Maintainer : Jens Petersen <petersen@fedoraproject.org> -- Stability : alpha@@ -21,6 +21,7 @@ cmdIgnoreErr, cmdQuiet, cmdSilent,+ optionalProgram, pkgInstall, repoquery, rpmInstall,@@ -29,8 +30,11 @@ sudo, (+-+)) where +#if (defined(MIN_VERSION_base) && MIN_VERSION_base(4,8,2))+#else+import Control.Applicative ((<$>))+#endif import Control.Monad (unless, void, when)-import Data.Functor ((<$>)) import Data.List ((\\)) import Data.Maybe (fromMaybe, isJust, isNothing) @@ -48,14 +52,14 @@ import System.Exit (ExitCode(..)) findProgram :: FilePath -> IO (Maybe FilePath)-findProgram prog =+findProgram = #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,18,0)- findProgramOnSearchPath normal defaultProgramSearchPath prog+ \ prog -> findProgramOnSearchPath normal defaultProgramSearchPath prog #if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(1,23,0)- >>= return . fmap fst+ >>= return . fmap fst #endif #else- findProgramLocation normal prog+ findProgramLocation normal #endif requireProgram :: String -> IO ()