Hello community,

here is the log from the commit of package ghc-x509-store for openSUSE:Factory 
checked in at 2016-11-05 21:26:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-x509-store (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-x509-store.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-x509-store"

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-x509-store/ghc-x509-store.changes    
2016-07-20 09:19:56.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-x509-store.new/ghc-x509-store.changes       
2016-11-05 21:26:59.000000000 +0100
@@ -1,0 +2,5 @@
+Tue Oct 11 08:49:30 UTC 2016 - [email protected]
+
+- Update to version 1.6.2 with cabal2obs.
+
+-------------------------------------------------------------------

Old:
----
  x509-store-1.6.1.tar.gz

New:
----
  x509-store-1.6.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-x509-store.spec ++++++
--- /var/tmp/diff_new_pack.LlcpCs/_old  2016-11-05 21:27:00.000000000 +0100
+++ /var/tmp/diff_new_pack.LlcpCs/_new  2016-11-05 21:27:00.000000000 +0100
@@ -18,26 +18,26 @@
 
 %global pkg_name x509-store
 Name:           ghc-%{pkg_name}
-Version:        1.6.1
+Version:        1.6.2
 Release:        0
 Summary:        X.509 collection accessing and storing methods
 License:        BSD-3-Clause
-Group:          System/Libraries
+Group:          Development/Languages/Other
 Url:            https://hackage.haskell.org/package/%{pkg_name}
 Source0:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
 BuildRequires:  ghc-Cabal-devel
-# Begin cabal-rpm deps:
 BuildRequires:  ghc-asn1-encoding-devel
 BuildRequires:  ghc-asn1-types-devel
 BuildRequires:  ghc-bytestring-devel
 BuildRequires:  ghc-containers-devel
 BuildRequires:  ghc-cryptonite-devel
+BuildRequires:  ghc-directory-devel
+BuildRequires:  ghc-filepath-devel
 BuildRequires:  ghc-mtl-devel
 BuildRequires:  ghc-pem-devel
 BuildRequires:  ghc-rpm-macros
 BuildRequires:  ghc-x509-devel
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-# End cabal-rpm deps
 
 %description
 X.509 collection accessing and storing methods for certificate, crl, exception
@@ -57,15 +57,12 @@
 %prep
 %setup -q -n %{pkg_name}-%{version}
 
-
 %build
 %ghc_lib_build
 
-
 %install
 %ghc_lib_install
 
-
 %post devel
 %ghc_pkg_recache
 

++++++ x509-store-1.6.1.tar.gz -> x509-store-1.6.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/x509-store-1.6.1/Data/X509/CertificateStore.hs 
new/x509-store-1.6.2/Data/X509/CertificateStore.hs
--- old/x509-store-1.6.1/Data/X509/CertificateStore.hs  2015-09-07 
16:58:33.000000000 +0200
+++ new/x509-store-1.6.2/Data/X509/CertificateStore.hs  2016-10-03 
09:36:01.000000000 +0200
@@ -1,16 +1,26 @@
 module Data.X509.CertificateStore
     ( CertificateStore
     , makeCertificateStore
+    , readCertificateStore
     -- * Queries
     , findCertificate
     , listCertificates
     ) where
 
-import Data.List (foldl')
+import Data.Char (isDigit, isHexDigit)
+import Data.Either (rights)
+import Data.List (foldl', isPrefixOf)
 import Data.Monoid
+import Data.PEM (pemParseBS, pemContent)
 import Data.X509
 import qualified Data.Map as M
-import Control.Monad (mplus)
+import Control.Applicative ((<$>))
+import Control.Monad (mplus, filterM)
+import System.Directory (getDirectoryContents, doesFileExist, 
doesDirectoryExist)
+import System.FilePath ((</>))
+import qualified Control.Exception as E
+import qualified Data.ByteString as B
+
 
 -- | A Collection of certificate or store of certificates.
 data CertificateStore = CertificateStore (M.Map DistinguishedName 
SignedCertificate)
@@ -38,3 +48,51 @@
 listCertificates :: CertificateStore -> [SignedCertificate]
 listCertificates (CertificateStore store) = map snd $ M.toList store
 listCertificates (CertificateStores l)    = concatMap listCertificates l
+
+-- | Create certificate store by reading certificates from file or directory
+--
+-- This function can be used to read multiple certificates from either
+-- single file (multiple PEM formatted certificates concanated) or
+-- directory (one certificate per file, file names are hashes from
+-- certificate).
+readCertificateStore :: FilePath -> IO (Maybe CertificateStore)
+readCertificateStore path = do
+    isDir  <- doesDirectoryExist path
+    isFile <- doesFileExist path
+    wrapStore <$> (if isDir then makeDirStore else if isFile then 
makeFileStore else return [])
+  where
+    wrapStore :: [SignedCertificate] -> Maybe CertificateStore
+    wrapStore [] = Nothing
+    wrapStore l  = Just $ makeCertificateStore l
+
+    makeFileStore = readCertificates path
+    makeDirStore  = do
+        certFiles <- listDirectoryCerts path
+        concat <$> mapM readCertificates certFiles
+
+-- Try to read certificate from the content of a file.
+--
+-- The file may contains multiple certificates
+readCertificates :: FilePath -> IO [SignedCertificate]
+readCertificates file = E.catch (either (const []) (rights . map getCert) . 
pemParseBS <$> B.readFile file) skipIOError
+    where
+        getCert = decodeSignedCertificate . pemContent
+        skipIOError :: E.IOException -> IO [SignedCertificate]
+        skipIOError _ = return []
+
+-- List all the path susceptible to contains a certificate in a directory
+--
+-- if the parameter is not a directory, hilarity follows.
+listDirectoryCerts :: FilePath -> IO [FilePath]
+listDirectoryCerts path =
+    getDirContents >>= filterM doesFileExist
+  where
+    isHashedFile s = length s == 10
+                  && isDigit (s !! 9)
+                  && (s !! 8) == '.'
+                  && all isHexDigit (take 8 s)
+    isCert x = (not $ isPrefixOf "." x) && (not $ isHashedFile x)
+
+    getDirContents = E.catch (map (path </>) . filter isCert <$> 
getDirectoryContents path) emptyPaths
+            where emptyPaths :: E.IOException -> IO [FilePath]
+                  emptyPaths _ = return []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/x509-store-1.6.1/x509-store.cabal 
new/x509-store-1.6.2/x509-store.cabal
--- old/x509-store-1.6.1/x509-store.cabal       2015-09-07 16:58:33.000000000 
+0200
+++ new/x509-store-1.6.2/x509-store.cabal       2016-10-03 09:36:19.000000000 
+0200
@@ -1,5 +1,5 @@
 Name:                x509-store
-Version:             1.6.1
+Version:             1.6.2
 Description:         X.509 collection accessing and storing methods for 
certificate, crl, exception list
 License:             BSD3
 License-file:        LICENSE
@@ -18,6 +18,8 @@
                    , bytestring
                    , mtl
                    , containers
+                   , directory
+                   , filepath
                    , pem >= 0.1 && < 0.3
                    , asn1-types >= 0.3 && < 0.4
                    , asn1-encoding >= 0.9 && < 0.10


Reply via email to