-- | -- Module : Commands.Refresh -- Copyright : (C) 2016 Jens Petersen -- -- Maintainer : Jens Petersen -- -- Explanation: refresh spec file to newer cabal-rpm -- 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 Commands.Refresh ( refresh ) where import Commands.Spec (createSpecFile) import PackageUtils (PackageData (..)) import Setup (RpmFlags (..)) import SysCmd (cmd_, shell, (+-+)) import Distribution.Simple.Utils (die) 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 \"" +-+ oldspec +-+ newspec +-+ "| sed -e 's/.cblrpm//' | patch" +-+ "|| :" -- setCurrentDirectory cwd -- when rwGit $ -- cmd_ "git" ["commit", "-a", "-m", "update to" +-+ newver] where createOldSpec :: String -> String -> IO FilePath createOldSpec crVer spec = do cmd_ ("cabal-rpm-" ++ crVer) ["spec"] let backup = spec ++ ".cblrpm" backup' = backup ++ "-" ++ crVer cmd_ "mv" [backup, backup'] return backup'