cabal-debian 4.25 → 4.26
raw patch · 4 files changed
+62/−42 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Tests.hs +1/−1
- cabal-debian.cabal +1/−1
- debian/changelog +7/−0
- src/Debian/Debianize/Finalize.hs +53/−40
Tests.hs view
@@ -587,7 +587,7 @@ test7 label = TestLabel label $ TestCase (do new <- readProcessWithExitCode "runhaskell" ["--ghc-arg=-package-db=dist/package.conf.inplace", "debian/Debianize.hs", "--dry-run", "--native"] ""- assertEqual label (ExitSuccess, "Ignored: debian/cabal-debian.1\nIgnored: debian/cabal-debian.manpages\nDebianization (dry run):\ndebian/cabal-debian-tests.install: Deleted\n\n", "") new)+ assertEqual label (ExitSuccess, "Ignored debianization file: debian/cabal-debian.1\nIgnored debianization file: debian/cabal-debian.manpages\nDebianization (dry run):\ndebian/cabal-debian-tests.install: Deleted\n\n", "") new) test8 :: String -> Test test8 label =
cabal-debian.cabal view
@@ -1,5 +1,5 @@ Name: cabal-debian-Version: 4.25+Version: 4.26 Copyright: Copyright (c) 2007-2014, David Fox, Jeremy Shaw License: BSD3 License-File: LICENSE
debian/changelog view
@@ -1,3 +1,10 @@+haskell-cabal-debian (4.26) unstable; urgency=low++ * Revamp the way the final debian version number is computed in+ Debian.Debianize.Finalize.debianVersion.++ -- David Fox <dsf@seereason.com> Sun, 05 Apr 2015 10:49:33 -0700+ haskell-cabal-debian (4.25) unstable; urgency=low * Make sure /proc is mounted when we run ghc to determine its version
src/Debian/Debianize/Finalize.hs view
@@ -16,9 +16,10 @@ import Data.ByteString.Lazy.UTF8 (fromString) import Data.Char (toLower) import Data.Digest.Pure.MD5 (md5)-import Data.List as List (filter, intercalate, map, nub, null, unlines)+import Data.Function (on)+import Data.List as List (filter, intercalate, map, nub, null, unlines, maximumBy) import Data.Map as Map (delete, elems, insertWith, lookup, Map, toList)-import Data.Maybe (fromMaybe, isJust, isNothing)+import Data.Maybe (fromMaybe, isJust, isNothing, fromJust) import Data.Monoid ((<>), mempty) import Data.Set as Set (difference, filter, fold, fromList, insert, map, null, Set, singleton, toList, union, unions) import Data.Set.Extra as Set (mapM_)@@ -46,7 +47,7 @@ import qualified Debian.Relation as D (BinPkgName(BinPkgName), Relation(..)) import Debian.Release (parseReleaseName) import Debian.Time (getCurrentLocalRFC822Time)-import Debian.Version (buildDebianVersion, DebianVersion, parseDebianVersion)+import qualified Debian.Version as V (buildDebianVersion, DebianVersion, parseDebianVersion, epoch, version, revision) import Distribution.Compiler (CompilerFlavor(GHC)) #if MIN_VERSION_Cabal(1,22,0) import Distribution.Compiler (CompilerFlavor(GHCJS))@@ -55,7 +56,6 @@ import Distribution.PackageDescription as Cabal (allBuildInfo, author, BuildInfo(buildable, extraLibs), Executable(buildInfo, exeName), FlagName(FlagName), maintainer, PackageDescription(testSuites)) import qualified Distribution.PackageDescription as Cabal (PackageDescription(dataFiles, executables, library, package)) import Prelude hiding ((.), init, log, map, unlines, unlines, writeFile)-import System.Environment (getProgName) import System.FilePath ((<.>), (</>), makeRelative, splitFileName, takeDirectory, takeFileName) import Text.ParserCombinators.Parsec.Rfc2822 (NameAddr(..)) import Text.PrettyPrint.HughesPJClass (Pretty(pPrint))@@ -147,43 +147,56 @@ T.debianDescription ~?= Just cabDesc -} --- | Combine various bits of information to produce the debian version--- which will be used for the debian package. If the override--- parameter is provided this exact version will be used, but an error--- will be thrown if that version is unusably old - i.e. older than--- the cabal version of the package. Otherwise, the cabal version is--- combined with the given epoch number and revision string to create--- a version.-debianVersion :: Monad m => CabalT m DebianVersion+-- | Construct the final Debian version number.+-- Inputs:+--+-- 1. --deb-version argument+-- 2. --revision argument+-- 3. cabal version number+-- 4. latest version in debian/changelog+--+-- The --deb-version argument overrides everything.+debianVersion :: (Monad m, Functor m) => CabalT m V.DebianVersion debianVersion =- do pkgDesc <- access A.packageDescription- let pkgId = Cabal.package pkgDesc- epoch <- debianEpoch (pkgName pkgId)- debVer <- access (A.debInfo . D.debVersion)- case debVer of- Just override- | override < parseDebianVersion (ppShow (pkgVersion pkgId)) ->- error ("Version from --deb-version (" ++ ppShow override ++- ") is older than hackage version (" ++ ppShow (pkgVersion pkgId) ++- "), maybe you need to unpin this package?")- Just override -> return override- Nothing ->- do let ver = ppShow (pkgVersion pkgId)- rev <- access (A.debInfo . D.revision)- let rev' = case rev of Nothing -> Nothing- Just "" -> Nothing- Just "-" -> Nothing- Just ('-':r) -> Just r- Just _ -> error "The Debian revision needs to start with a dash"- fmt <- access (A.debInfo . D.sourceFormat)- -- If no revision number has been set and the format- -- is not Native3 we need to set it (see- -- https://github.com/ddssff/cabal-debian/issues/16)- let rev'' = maybe (case fmt of- Just Native3 -> Nothing- _ -> Just "1") Just rev'- return $ buildDebianVersion epoch ver rev''+ do cabalName <- (pkgName . Cabal.package) <$> access A.packageDescription+ (cabalVersion :: V.DebianVersion) <- (V.parseDebianVersion . ppShow . pkgVersion . Cabal.package) <$> access A.packageDescription+ cabalEpoch <- debianEpoch cabalName+ fmt <- access (A.debInfo . D.sourceFormat)+ cabalRevision <-+ do x <- access (A.debInfo . D.revision) -- from the --revision option+ let y = case x of+ Nothing -> Nothing+ Just "" -> Nothing+ Just "-" -> Nothing+ Just ('-':r) -> Just r+ Just _ -> error "The --revision argument must start with a dash"+ return $ case fmt of+ Just Native3 -> y+ _ -> maybe (Just "1") (Just . max "1") y+ versionArg <- access (A.debInfo . D.debVersion) -- from the --deb-version option+ (debianVersion :: Maybe V.DebianVersion) <- access (A.debInfo . D.changelog) >>= return . maybe Nothing changelogVersion + case () of+ _ | maybe False (\ v -> v < V.buildDebianVersion cabalEpoch (ppShow cabalVersion) Nothing) versionArg ->+ error ("Version from --deb-version (" ++ ppShow versionArg +++ ") is older than cabal version (" ++ ppShow cabalVersion +++ "), maybe you need to unpin this package?")+ _ | isJust versionArg -> return $ fromJust versionArg+ _ | isJust debianVersion ->+ case (V.epoch (fromJust debianVersion),+ V.parseDebianVersion (V.version (fromJust debianVersion)),+ V.revision (fromJust debianVersion)) of+ (debianEpoch, debianVersion', (debianRevision :: Maybe String)) ->+ let finalEpoch = max debianEpoch cabalEpoch+ finalVersion = max debianVersion' cabalVersion+ (finalRevision :: Maybe String) = maximumBy (compare `on` fmap V.parseDebianVersion) [debianRevision, cabalRevision] in+ return $ V.buildDebianVersion finalEpoch (ppShow finalVersion) finalRevision+ _ -> return $ V.buildDebianVersion cabalEpoch (ppShow cabalVersion) cabalRevision++changelogVersion :: ChangeLog -> Maybe V.DebianVersion+changelogVersion (ChangeLog (Entry {logVersion = x} : _)) = Just x+changelogVersion _ = Nothing+ -- | Return the Debian epoch number assigned to the given cabal -- package - the 1 in version numbers like 1:3.5-2. debianEpoch :: Monad m => PackageName -> CabalT m (Maybe Int)@@ -288,7 +301,7 @@ let msg = "Initial release (Closes: #nnnn)" (A.debInfo . D.changelog) %= fixLog src ver cmts debianMaintainer msg where- fixLog :: Maybe SrcPkgName -> DebianVersion -> Maybe [[Text]] -> NameAddr -> Text -> Maybe ChangeLog -> Maybe ChangeLog+ fixLog :: Maybe SrcPkgName -> V.DebianVersion -> Maybe [[Text]] -> NameAddr -> Text -> Maybe ChangeLog -> Maybe ChangeLog -- Ensure that the package name is correct in the first log entry. fixLog src ver cmts _maint _ (Just (ChangeLog (entry : older))) | logVersion entry == ver =