cabal2spec 2.4.1 → 2.4.2
raw patch · 4 files changed
+37/−39 lines, 4 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Cabal2Spec: type CopyrightYear = Int
- Cabal2Spec: cabal2spec :: Platform -> CompilerId -> FlagAssignment -> ForceBinary -> RunTests -> FilePath -> FilePath -> IO ()
+ Cabal2Spec: cabal2spec :: Platform -> CompilerId -> FlagAssignment -> ForceBinary -> RunTests -> Maybe CopyrightYear -> FilePath -> FilePath -> IO ()
- Cabal2Spec: createSpecFile :: FilePath -> PackageDescription -> ForceBinary -> RunTests -> FlagAssignment -> IO ()
+ Cabal2Spec: createSpecFile :: FilePath -> PackageDescription -> ForceBinary -> RunTests -> FlagAssignment -> Maybe CopyrightYear -> IO ()
Files
- cabal2spec.cabal +16/−22
- cabal2spec/Main.hs +10/−8
- src/Cabal2Spec.hs +10/−8
- test/Main.hs +1/−1
cabal2spec.cabal view
@@ -1,5 +1,5 @@ name: cabal2spec-version: 2.4.1+version: 2.4.2 synopsis: Convert Cabal files into rpm spec files description: Convert Cabal files into a@@ -14,7 +14,7 @@ license-file: LICENSE author: Peter Simons, Bryan O'Sullivan, Jens Petersen maintainer: simons@cryp.to-tested-with: GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.1, GHC == 8.10.1+tested-with: GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.2 category: Distribution homepage: https://github.com/peti/cabal2spec build-type: Simple@@ -28,27 +28,21 @@ location: git://github.com/peti/cabal2spec.git library- exposed-modules: Cabal2Spec- hs-source-dirs: src- build-depends: base < 5, Cabal > 3.0 && < 3.2, filepath, time >= 1.5- default-language: Haskell2010- ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates- -Wredundant-constraints+ exposed-modules: Cabal2Spec+ hs-source-dirs: src+ build-depends: base < 5, Cabal > 3.0 && < 3.2, filepath, time >= 1.5+ default-language: Haskell2010 executable cabal2spec- main-is: Main.hs- other-modules: Paths_cabal2spec- hs-source-dirs: cabal2spec- build-depends: base, Cabal, cabal2spec, filepath, optparse-applicative- default-language: Haskell2010- ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates- -Wredundant-constraints+ main-is: Main.hs+ other-modules: Paths_cabal2spec+ hs-source-dirs: cabal2spec+ build-depends: base, Cabal, cabal2spec, filepath, optparse-applicative+ default-language: Haskell2010 test-suite regression-test- type: exitcode-stdio-1.0- main-is: Main.hs- hs-source-dirs: test- build-depends: base, Cabal, cabal2spec, filepath, tasty, tasty-golden- default-language: Haskell2010- ghc-options: -Wall -Wcompat -Wincomplete-uni-patterns -Wincomplete-record-updates- -Wredundant-constraints+ type: exitcode-stdio-1.0+ main-is: Main.hs+ hs-source-dirs: test+ build-depends: base, Cabal, cabal2spec, filepath, tasty, tasty-golden+ default-language: Haskell2010
cabal2spec/Main.hs view
@@ -17,13 +17,14 @@ import System.FilePath data Options = Options- { optPlatform :: Platform- , optCompiler :: CompilerId- , optForceExe :: ForceBinary- , optRunTests :: RunTests- , optFlags :: [(FlagName, Bool)]- , optOutputFile :: Maybe FilePath- , optCabalFile :: FilePath+ { optPlatform :: Platform+ , optCompiler :: CompilerId+ , optForceExe :: ForceBinary+ , optRunTests :: RunTests+ , optCopyrightYear :: Maybe CopyrightYear+ , optFlags :: [(FlagName, Bool)]+ , optOutputFile :: Maybe FilePath+ , optCabalFile :: FilePath } deriving (Show) @@ -33,6 +34,7 @@ <*> option (maybeReader simpleParse) (long "compiler" <> help "compiler to use when evaluating the Cabal file" <> value buildCompilerId <> showDefaultWith (show . display)) <*> switch (long "force-exe" <> help "treat this package as a executable-only build even if it defined a library") <*> switch (long "enable-tests" <> help "enable the test suite in the generated build")+ <*> optional (option auto (long "copyright-year" <> help "specify the year to be used in the copyright header")) <*> many (option parseFlag (short 'f' <> long "flag" <> help "Cabal flag (may be specified multiple times)")) <*> optional (strOption (short 'o' <> long "output" <> metavar "FILE" <> help "write generated spec file to this path")) <*> strArgument (metavar "CABAL-FILE")@@ -59,4 +61,4 @@ Options {..} <- execParser pinfo let specFile = fromMaybe (optCabalFile `replaceExtension` "spec") optOutputFile putStrLn $ "Writing spec file to " ++ show specFile ++ " ..."- cabal2spec optPlatform optCompiler (mkFlagAssignment optFlags) optForceExe optRunTests optCabalFile specFile+ cabal2spec optPlatform optCompiler (mkFlagAssignment optFlags) optForceExe optRunTests optCopyrightYear optCabalFile specFile
src/Cabal2Spec.hs view
@@ -1,4 +1,4 @@-module Cabal2Spec ( cabal2spec, createSpecFile, ForceBinary, RunTests ) where+module Cabal2Spec ( cabal2spec, createSpecFile, ForceBinary, RunTests, CopyrightYear ) where import Control.Monad import Data.Char@@ -26,14 +26,15 @@ type ForceBinary = Bool type RunTests = Bool+type CopyrightYear = Int -cabal2spec :: Platform -> CompilerId -> FlagAssignment -> ForceBinary -> RunTests+cabal2spec :: Platform -> CompilerId -> FlagAssignment -> ForceBinary -> RunTests -> Maybe CopyrightYear -> FilePath -> FilePath -> IO ()-cabal2spec platform compilerId flags forceBinary runTests cabalFile specFile = do+cabal2spec platform compilerId flags forceBinary runTests copyrightYear cabalFile specFile = do gpd <- readGenericPackageDescription silent cabalFile case finalizePD flags requestedComponents (const True) platform (unknownCompilerInfo compilerId NoAbiTag) [] gpd of Left missing -> fail ("finalizePD: " ++ show missing)- Right (pd,_) -> createSpecFile specFile pd forceBinary runTests flags+ Right (pd,_) -> createSpecFile specFile pd forceBinary runTests flags copyrightYear requestedComponents :: ComponentRequestedSpec requestedComponents = defaultComponentRequestedSpec@@ -50,8 +51,8 @@ mapTools "gtk2hsTypeGen" = "gtk2hs-buildtools" mapTools tool = tool -createSpecFile :: FilePath -> PackageDescription -> ForceBinary -> RunTests -> FlagAssignment -> IO ()-createSpecFile specFile pkgDesc forceBinary runTests flagAssignment = do+createSpecFile :: FilePath -> PackageDescription -> ForceBinary -> RunTests -> FlagAssignment -> Maybe CopyrightYear -> IO ()+createSpecFile specFile pkgDesc forceBinary runTests flagAssignment copyrightYear = do let deps :: [String] deps = map showDep deps' deps' :: [String]@@ -97,8 +98,9 @@ ghcPkgDevel = if binlib then "-n ghc-%{name}-devel" else "devel" do- now <- getCurrentTime- let year = formatTime defaultTimeLocale "%Y" now+ year <- case copyrightYear of+ Just y -> return (show y)+ Nothing -> formatTime defaultTimeLocale "%Y" <$> getCurrentTime put "#" put $ "# spec file for package " ++ pkgname put "#"
test/Main.hs view
@@ -24,4 +24,4 @@ (\ref new -> ["diff", "-u", ref, new]) goldenFile specFile- (cabal2spec pid cid mempty True False cabalFile specFile)+ (cabal2spec pid cid mempty True False (Just 2020) cabalFile specFile)