Skip to content

Commit

Permalink
Add data structures to support machine readable debian/copyright file
Browse files Browse the repository at this point in the history
  • Loading branch information
ddssff committed Nov 28, 2014
1 parent 53564b4 commit a5f512c
Show file tree
Hide file tree
Showing 24 changed files with 360 additions and 194 deletions.
2 changes: 1 addition & 1 deletion Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ test3 label =
"",
""])
T.compat ~= Just 7
T.copyright ~= Just "This package was debianized by John Goerzen <jgoerzen@complete.org> on\nWed, 6 Oct 2004 09:46:14 -0500.\n\nCopyright information removed from this test data.\n\n"
T.copyright ~= Just (Right "This package was debianized by John Goerzen <jgoerzen@complete.org> on\nWed, 6 Oct 2004 09:46:14 -0500.\n\nCopyright information removed from this test data.\n\n")
T.source ~= Just (SrcPkgName {unSrcPkgName = "haskell-devscripts"})
T.maintainer ~= Just (NameAddr {nameAddr_name = Just "Debian Haskell Group", nameAddr_addr = "pkg-haskell-maintainers@lists.alioth.debian.org"})
T.uploaders ~= [NameAddr {nameAddr_name = Just "Marco Silva", nameAddr_addr = "marcot@debian.org"},NameAddr {nameAddr_name = Just "Joachim Breitner", nameAddr_addr = "nomeata@debian.org"}]
Expand Down
4 changes: 3 additions & 1 deletion cabal-debian.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: cabal-debian
Version: 4.17.5
Version: 4.18
License: BSD3
License-File: debian/copyright
Author: David Fox <dsf@seereason.com>
Expand Down Expand Up @@ -165,6 +165,7 @@ Library
HUnit,
memoize,
mtl,
network-uri,
parsec >= 3,
pretty,
prettyclass,
Expand Down Expand Up @@ -202,6 +203,7 @@ Library
Debian.Debianize.Types
Debian.Debianize.Types.Atoms
Debian.Debianize.Types.BinaryDebDescription
Debian.Debianize.Types.CopyrightDescription
Debian.Debianize.Types.SourceDebDescription
Debian.Debianize.VersionSplits
Other-Modules:
Expand Down
8 changes: 4 additions & 4 deletions debian/Debianize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ main =
do sourceFormat ~= Just Native3
standardsVersion ~= Just (StandardsVersion 3 9 3 Nothing)
compat ~= Just 9
copyright ~= Just (pack (unlines [ "This package is not part of the Debian GNU/Linux distribution."
, ""
, "Copyright: (c) 2010-2011, SeeReason Partners LLC"
, "License: All Rights Reserved"]))
copyright ~= Just (Right (pack (unlines [ "This package is not part of the Debian GNU/Linux distribution."
, ""
, "Copyright: (c) 2010-2011, SeeReason Partners LLC"
, "License: All Rights Reserved"])))
conflicts (BinPkgName "cabal-debian") %= (++ [[Rel (BinPkgName "haskell-debian-utils") (Just (SLT (parseDebianVersion ("3.59" :: String)))) Nothing]])
depends (BinPkgName "cabal-debian") %= (++ [[Rel (BinPkgName "apt-file") Nothing Nothing]])
depends (BinPkgName "cabal-debian") %= (++ [[Rel (BinPkgName "debian-policy") Nothing Nothing]])
Expand Down
2 changes: 1 addition & 1 deletion debian/cabal-debian.install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dist-ghc/build/cabal-debian/cabal-debian usr/bin
dist-ghc/build/cabal-debian/cabal-debian /usr/bin
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
haskell-cabal-debian (4.18) unstable; urgency=low

* Add types to support machine readable copyright files.

-- David Fox <dsf@seereason.com> Thu, 27 Nov 2014 07:11:35 -0800

haskell-cabal-debian (4.17.5) unstable; urgency=low

* Use the prettyclass package and the PP wrappers in the latest
Expand Down
44 changes: 23 additions & 21 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Build-Depends: debhelper (>= 7.0),
ghc-prof,
libghc-cabal-ghcjs-dev (>= 1.21) | ghc | libghc-cabal-dev (>= 1.9),
libghc-cabal-ghcjs-dev (>= 1.21) | ghc | libghc-cabal-dev (<< 1.21),
libghc-cabal-ghcjs-prof (>= 1.21) | ghc-prof | libghc-cabal-prof (>= 1.9),
libghc-cabal-ghcjs-prof (>= 1.21) | ghc-prof | libghc-cabal-prof (<< 1.21),
libghc-diff-dev,
libghc-diff-prof,
Expand All @@ -22,15 +21,17 @@ Build-Depends: debhelper (>= 7.0),
libghc-data-lens-template-dev,
libghc-data-lens-template-prof,
libghc-debian-dev (>= 3.84),
libghc-debian-prof (>= 3.84),
libghc-debian-prof
libghc-hsemail-dev,
libghc-hsemail-prof,
libghc-memoize-dev,
libghc-memoize-prof,
libghc-mtl-dev,
libghc-mtl-prof,
libghc-network-uri-dev,
libghc-network-uri-prof,
libghc-parsec3-dev (>= 3),
libghc-parsec3-prof (>= 3),
libghc-parsec3-prof (>= 3) | libghc-parsec2-prof (<< 3),
libghc-prettyclass-dev,
libghc-prettyclass-prof,
libghc-puremd5-dev,
Expand All @@ -52,11 +53,12 @@ Build-Depends-Indep: ghc-doc,
libghc-unixutils-doc,
libghc-data-lens-doc,
libghc-data-lens-template-doc,
libghc-debian-doc (>= 3.84),
libghc-debian-doc
libghc-hsemail-doc,
libghc-memoize-doc,
libghc-mtl-doc,
libghc-parsec3-doc (>= 3),
libghc-network-uri-doc,
libghc-parsec3-doc (>= 3) | libghc-parsec2-doc (<< 3),
libghc-prettyclass-doc,
libghc-puremd5-doc,
libghc-regex-tdfa-doc,
Expand All @@ -74,25 +76,31 @@ X-Description: Create a Debianization for a Cabal package
@cabal-debian --help@, for documentation of the library API follow
the link to the @Debian.Debianize@ module below.

Package: libghc-cabal-debian-dev
Package: cabal-debian
Architecture: any
Section: misc
Depends: ${haskell:Depends},
${misc:Depends},
${shlibs:Depends},
apt-file,
debian-policy,
debhelper,
haskell-devscripts (>= 0.8.19),
Recommends: ${haskell:Recommends},
Suggests: ${haskell:Suggests},
Conflicts: ${haskell:Conflicts},
Conflicts: ${haskell:Conflicts}, haskell-debian-utils (<< 3.59),
Provides: ${haskell:Provides},
Description: ${haskell:ShortDescription}${haskell:ShortBlurb}
${haskell:LongDescription}
.
${haskell:Blurb}

Package: libghc-cabal-debian-prof
Package: libghc-cabal-debian-dev
Architecture: any
Depends: ${haskell:Depends},
${misc:Depends},
${shlibs:Depends},
debian-policy,
Recommends: ${haskell:Recommends},
Suggests: ${haskell:Suggests},
Conflicts: ${haskell:Conflicts},
Expand All @@ -102,33 +110,27 @@ Description: ${haskell:ShortDescription}${haskell:ShortBlurb}
.
${haskell:Blurb}

Package: libghc-cabal-debian-doc
Architecture: all
Section: doc
Package: libghc-cabal-debian-prof
Architecture: any
Depends: ${haskell:Depends},
${misc:Depends},
Recommends: ${haskell:Recommends},
Suggests: ${haskell:Suggests},
Conflicts: ${haskell:Conflicts},
Provides: ${haskell:Provides},
Description: ${haskell:ShortDescription}${haskell:ShortBlurb}
${haskell:LongDescription}
.
${haskell:Blurb}

Package: cabal-debian
Architecture: any
Section: misc
Package: libghc-cabal-debian-doc
Architecture: all
Section: doc
Depends: ${haskell:Depends},
${misc:Depends},
${shlibs:Depends},
apt-file,
debian-policy,
debhelper,
haskell-devscripts (>= 0.8.19),
Recommends: ${haskell:Recommends},
Suggests: ${haskell:Suggests},
Conflicts: ${haskell:Conflicts}, haskell-debian-utils (<< 3.59),
Provides: ${haskell:Provides},
Conflicts: ${haskell:Conflicts},
Description: ${haskell:ShortDescription}${haskell:ShortBlurb}
${haskell:LongDescription}
.
Expand Down
1 change: 0 additions & 1 deletion debian/libghc-cabal-debian-doc.links

This file was deleted.

3 changes: 2 additions & 1 deletion src/Debian/Debianize/Files.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ copyright =
licenseFile <- lift $ access T.licenseFile
return [("debian/copyright", case (licenseFile, copyrt, license) of
(Just x, _, _) -> x <> "\n"
(_, Just x, y) -> x <> "\n" <> maybe mempty (\ z -> pack ("License: " <> (show (ppPrint z)) <> "\n")) y
(_, Just (Right x), y) -> x <> "\n" <> maybe mempty (\ z -> pack ("License: " <> (show (ppPrint z)) <> "\n")) y
(_, Just (Left x), y) -> ppDisplay' x <> "\n"
(_, _, Just x) -> pack ("License: " <> show (ppPrint x) <> "\n")
_ -> pack ("License: " <> show (ppPrint AllRightsReserved)))]

Expand Down
28 changes: 23 additions & 5 deletions src/Debian/Debianize/Input.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ import qualified Debian.Debianize.Types as T (maintainer, official)
import qualified Debian.Debianize.Types.Atoms as T (changelog, makeAtoms, compilerFlavors)
import Debian.Debianize.Types.BinaryDebDescription (BinaryDebDescription, newBinaryDebDescription)
import qualified Debian.Debianize.Types.BinaryDebDescription as B
import Debian.Debianize.Types.CopyrightDescription (inputCopyrightDescription, newCopyrightDescription, CopyrightDescription(_summaryCopyright, _summaryLicense))
import qualified Debian.Debianize.Types.SourceDebDescription as S
import Debian.Debianize.Types.Atoms
(control, warning, sourceFormat, watch, rulesHead, compat, packageDescription,
license, licenseFile, copyright, changelog, installInit, postInst, postRm, preInst, preRm,
logrotateStanza, link, install, installDir, intermediateFiles, cabalFlagAssignments, verbosity, buildEnv)
import Debian.Debianize.Monad (DebT)
import Debian.Debianize.Prelude (getDirectoryContents', readFileMaybe, read', intToVerbosity', (~=), (~?=), (+=), (++=), (+++=))
import Debian.Debianize.Prelude (getDirectoryContents', readFileMaybe, read', intToVerbosity', (~=), (~?=), (+=), (++=), (+++=), (%=))
import Debian.Debianize.Types.Atoms (EnvSet(dependOS))
import Debian.GHC (newestAvailableCompilerId)
import Debian.Orphans ()
Expand Down Expand Up @@ -229,7 +230,7 @@ inputAtoms debian name@"source/format" = liftIO (readFile (debian </> name)) >>=
inputAtoms debian name@"watch" = liftIO (readFile (debian </> name)) >>= \ text -> watch ~= Just text
inputAtoms debian name@"rules" = liftIO (readFile (debian </> name)) >>= \ text -> rulesHead ~= (Just text)
inputAtoms debian name@"compat" = liftIO (readFile (debian </> name)) >>= \ text -> compat ~= Just (read' (\ s -> error $ "compat: " ++ show s) (unpack text))
inputAtoms debian name@"copyright" = liftIO (readFile (debian </> name)) >>= \ text -> copyright ~= Just text
inputAtoms debian name@"copyright" = liftIO (inputCopyrightDescription (debian </> name)) >>= \ x -> copyright ~= Just x
inputAtoms debian name@"changelog" =
liftIO (readFile (debian </> name)) >>= return . parseChangeLog . unpack >>= \ log -> changelog ~= Just log
inputAtoms debian name =
Expand Down Expand Up @@ -297,9 +298,26 @@ inputCabalization =
path -> readFileMaybe path
#endif
licenseFile ~?= licenseFileText
copyright ~?= (case Cabal.copyright pkgDesc of
"" -> Nothing
s -> Just (pack s))))
-- Create a machine readable copyright file from the information
-- available in the cabal file - specifically, the copyright field,
-- the license field and/or the contents of the file specified by
-- the license file field.
copyright %= (\ x ->
let newCopyright = newCopyrightDescription { _summaryCopyright = case Cabal.copyright pkgDesc of
"" -> Just "Copyright missing"
s -> Just (pack s)
, _summaryLicense = licenseFileText } in
case x of
Nothing -> Just $ Left $ newCopyright
Just (Right _) -> Just $ Left $ newCopyright
Just (Left t) -> Just (Left t))
{-
copyright ~?= (Just $ Left $ newCopyrightDescription { _summaryCopyright = case Cabal.copyright pkgDesc of
"" -> Just "Copyright missing"
s -> Just (pack s)
, _summaryLicense = licenseFileText })
-}
))
ePkgDescs

inputCabalization' :: Verbosity -> Set (FlagName, Bool) -> [CompilerId] -> IO [Either [Dependency] PackageDescription]
Expand Down
5 changes: 3 additions & 2 deletions src/Debian/Debianize/Types/Atoms.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Data.Monoid (Monoid(..))
import Data.Set as Set (Set, singleton, insert)
import Data.Text (Text)
import Debian.Changes (ChangeLog)
import Debian.Debianize.Types.CopyrightDescription
import qualified Debian.Debianize.Types.SourceDebDescription as S
import Debian.Debianize.VersionSplits (VersionSplits)
import Debian.Orphans ()
Expand Down Expand Up @@ -158,7 +159,7 @@ data Atoms
-- ^ Supply some info about a cabal package.
, compat_ :: Maybe Int
-- ^ The debhelper compatibility level, from debian/compat.
, copyright_ :: Maybe Text
, copyright_ :: Maybe (Either CopyrightDescription Text)
-- ^ Copyright information
, license_ :: Maybe License
-- ^ License information Cabal License value
Expand Down Expand Up @@ -554,7 +555,7 @@ official :: Lens Atoms Bool
official = lens official_ (\ b a -> a {official_ = b})

-- | The copyright information from the cabal file
copyright :: Lens Atoms (Maybe Text)
copyright :: Lens Atoms (Maybe (Either CopyrightDescription Text))
copyright = lens copyright_ (\ a b -> b {copyright_ = a})

-- | The license information from the cabal file
Expand Down

0 comments on commit a5f512c

Please sign in to comment.