Hello community, here is the log from the commit of package ghc-temporary for openSUSE:Factory checked in at 2018-10-25 08:19:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-temporary (Old) and /work/SRC/openSUSE:Factory/.ghc-temporary.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-temporary" Thu Oct 25 08:19:03 2018 rev:10 rq:642899 version:1.3 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-temporary/ghc-temporary.changes 2018-07-21 10:23:32.450981835 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-temporary.new/ghc-temporary.changes 2018-10-25 08:19:07.383997567 +0200 @@ -1,0 +2,12 @@ +Thu Oct 4 09:42:54 UTC 2018 - [email protected] + +- Update temporary to version 1.3. + ## 1.3 + + * Generated directory names are now based on random hex strings rather than PIDs. + + This got a major version bump as a courtesy to users who may depend on the + specific form of generated names, but that form is not part of the API + contract and should not be depended upon. + +------------------------------------------------------------------- Old: ---- temporary-1.2.1.1.tar.gz New: ---- temporary-1.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-temporary.spec ++++++ --- /var/tmp/diff_new_pack.1gKrzr/_old 2018-10-25 08:19:09.603996587 +0200 +++ /var/tmp/diff_new_pack.1gKrzr/_new 2018-10-25 08:19:09.619996580 +0200 @@ -12,14 +12,14 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %global pkg_name temporary %bcond_with tests Name: ghc-%{pkg_name} -Version: 1.2.1.1 +Version: 1.3 Release: 0 Summary: Portable temporary file and directory support License: BSD-3-Clause @@ -30,6 +30,7 @@ BuildRequires: ghc-directory-devel BuildRequires: ghc-exceptions-devel BuildRequires: ghc-filepath-devel +BuildRequires: ghc-random-devel BuildRequires: ghc-rpm-macros BuildRequires: ghc-transformers-devel BuildRequires: ghc-unix-devel ++++++ temporary-1.2.1.1.tar.gz -> temporary-1.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/temporary-1.2.1.1/CHANGELOG.md new/temporary-1.3/CHANGELOG.md --- old/temporary-1.2.1.1/CHANGELOG.md 2017-07-26 13:48:57.000000000 +0200 +++ new/temporary-1.3/CHANGELOG.md 2018-04-10 16:15:41.000000000 +0200 @@ -1,3 +1,11 @@ +## 1.3 + +* Generated directory names are now based on random hex strings rather than PIDs. + + This got a major version bump as a courtesy to users who may depend on the + specific form of generated names, but that form is not part of the API + contract and should not be depended upon. + ## 1.2.1.1 * Improve the docs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/temporary-1.2.1.1/System/IO/Temp.hs new/temporary-1.3/System/IO/Temp.hs --- old/temporary-1.2.1.1/System/IO/Temp.hs 2017-07-26 13:47:57.000000000 +0200 +++ new/temporary-1.3/System/IO/Temp.hs 2018-04-10 16:20:22.000000000 +0200 @@ -1,4 +1,4 @@ -{-# LANGUAGE CPP #-} +{-# LANGUAGE CPP, ScopedTypeVariables #-} -- | Functions to create temporary files and directories. -- -- Most functions come in two flavours: those that create files/directories @@ -21,11 +21,15 @@ -- placed between between the name and the extension to yield a unique file -- name, e.g. @name1804289383846930886.ext@. -- --- For directories, no extension is recognized, so a number will be simply --- appended to the end of the template. Moreover, the number will be --- smaller, as it is derived from the current process's PID --- (but the result is still a unique directory name). So, for instance, --- the directory template @dir@ may result in a directory named @dir30112@. +-- For directories, no extension is recognized. +-- A random hexadecimal string (whose length depends on the system's word +-- size) is appended to the end of the template. +-- For instance, +-- the directory template @dir@ may result in a directory named +-- @dir-e4bd89e5d00acdee@. +-- +-- You shouldn't rely on the specific form of file or directory names +-- generated by the library; it has changed in the past and may change in the future. module System.IO.Temp ( withSystemTempFile, withSystemTempDirectory, withTempFile, withTempDirectory, @@ -43,17 +47,23 @@ import qualified Control.Monad.Catch as MC import Control.Monad.IO.Class +import Data.Bits -- no import list: we use different functions + -- depending on the base version +#if !MIN_VERSION_base(4,8,0) +import Data.Word (Word) +#endif import System.Directory import System.IO (Handle, hClose, openTempFile, openBinaryTempFile, openBinaryTempFileWithDefaultPermissions, hPutStr) import System.IO.Error (isAlreadyExistsError) -import System.Posix.Internals (c_getpid) import System.FilePath ((</>)) +import System.Random #ifdef mingw32_HOST_OS import System.Directory ( createDirectory ) #else import qualified System.Posix #endif +import Text.Printf -- | Create, open, and use a temporary file in the system standard temporary directory. -- @@ -164,18 +174,26 @@ :: FilePath -- ^ Parent directory to create the directory in -> String -- ^ Directory name template -> IO FilePath -createTempDirectory dir template = do - pid <- c_getpid - findTempName pid +createTempDirectory dir template = findTempName where - findTempName x = do - let dirpath = dir </> template ++ show x + findTempName = do + x :: Word <- randomIO + let dirpath = dir </> template ++ printf "-%.*x" (wordSize `div` 4) x r <- MC.try $ mkPrivateDir dirpath case r of Right _ -> return dirpath - Left e | isAlreadyExistsError e -> findTempName (x+1) + Left e | isAlreadyExistsError e -> findTempName | otherwise -> ioError e +-- | Word size in bits +wordSize :: Int +wordSize = +#if MIN_VERSION_base(4,7,0) + finiteBitSize (undefined :: Word) +#else + bitSize (undefined :: Word) +#endif + mkPrivateDir :: String -> IO () #ifdef mingw32_HOST_OS mkPrivateDir s = createDirectory s diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/temporary-1.2.1.1/temporary.cabal new/temporary-1.3/temporary.cabal --- old/temporary-1.2.1.1/temporary.cabal 2017-07-26 13:48:43.000000000 +0200 +++ new/temporary-1.3/temporary.cabal 2018-04-10 16:15:54.000000000 +0200 @@ -1,5 +1,5 @@ name: temporary -version: 1.2.1.1 +version: 1.3 cabal-version: >= 1.10 synopsis: Portable temporary file and directory support description: Functions for creating temporary files and directories. @@ -20,7 +20,7 @@ Haskell2010 exposed-modules: System.IO.Temp build-depends: base >= 3 && < 10, filepath >= 1.1, directory >= 1.0, - transformers >= 0.2.0.0, exceptions >= 0.6 + transformers >= 0.2.0.0, exceptions >= 0.6, random >= 1.1 -- note: the transformers dependency is needed for MonadIO -- on older GHCs; on newer ones, it is included in base. ghc-options: -Wall
