Open osa1 opened 9 years ago
There are some bugs, e.g. #2353.
Fixing this is trivial, but we'll need to fix #2661 and #2681 first before making this feature public. See discussion in #2607, specifically https://github.com/haskell/cabal/pull/2607#issuecomment-113414514.
It looks like both the referenced bugs were fixed. Are there any further blockers?
Here's a script I bodged together from the one in the other ticket, but updated for the latest cabal.
module Main (main) where
import Control.Monad
import Control.Applicative
import Distribution.Verbosity
import Distribution.Client.IndexUtils
import qualified Distribution.PackageDescription.Parsec as PackageDesc.Parse
import Distribution.PackageDescription.PrettyPrint
import Distribution.ParseUtils
import qualified Data.ByteString.Char8 as BS
import Data.List
check :: FilePath -> IO ()
check cabal = do
print cabal
cabalfile <- BS.readFile cabal
let desc1 = parsePackageDescription cabalfile
case desc1 of
Nothing -> print "failparse"
Just desc -> do
let desc' = parsePackageDescription $ BS.pack (showGenericPackageDescription desc)
when (Just desc /= desc') $ do
print $ Just desc
print $ desc'
fail cabal
parsePackageDescription content = either (const Nothing) Just $ snd $ PackageDesc.Parse.runParseResult $ PackageDesc.Parse.parseGenericPackageDescription $ content
myFilter x = not $ "lambdaBase" `isInfixOf` x || "wiringPi" `isInfixOf` x || "constrained-monads" `isInfixOf` x
main :: IO ()
main = do
-- Generate listing with
-- find . -type f -name '*.cabal' > cabal-files
cabalFiles <- Prelude.filter myFilter . Prelude.lines <$> Prelude.readFile "cabal-files"
mapM_ check cabalFiles
The errors it seems to run into are all about round-trips with character encodings.
E.g. in the original you have something like copyright = "2016 Donnacha Ois\237n Kidney",
and in the processed file you have copyright = "2016 Donnacha Ois\65533 Kidney"
Any ideas why this command is hidden? I recently discovered this and I think it's very useful.