hackage-repo-tool 0.1.1 → 0.1.1.1
raw patch · 5 files changed
+105/−49 lines, 5 filesdep +old-timedep ~Cabaldep ~basedep ~directorynew-uploader
Dependencies added: old-time
Dependency ranges changed: Cabal, base, directory, optparse-applicative
Files
- ChangeLog.md +7/−2
- hackage-repo-tool.cabal +45/−29
- src/Hackage/Security/RepoTool/Options.hs +7/−0
- src/Hackage/Security/RepoTool/Util/IO.hs +38/−17
- src/Main.hs +8/−1
ChangeLog.md view
@@ -1,11 +1,16 @@+0.1.1.1+-------+* Make `hackage-repo-tool` buildable on Windows (#175)+* Fix build-failure w/ `directory-1.2`+ 0.1.1 ------* Update for hackage-security-0.5+* Update for `hackage-security-0.5` 0.1.0.1 ------- * Add missing module to other-modules (#100)-* Allow for hackage-security-0.3+* Allow for `hackage-security-0.3` * Include ChangeLog.md in sdist (#98) 0.1.0.0
hackage-repo-tool.cabal view
@@ -1,36 +1,44 @@+cabal-version: 1.12 name: hackage-repo-tool-version: 0.1.1+version: 0.1.1.1+ synopsis: Utility to manage secure file-based package repositories-description: This utility can be used to manage secure file-based- repositories (creating TUF metadata as well as a Hackage- index tarball). Currently it also provides various- lower level utilities for creating and signing TUF files.+description: This utility can be used to manage secure file-based package+ repositories (creating [TUF](https://theupdateframework.github.io/)+ metadata as well as a Hackage index tarball) which can be used by+ clients such as [cabal-install](http://hackage.haskell.org/package/cabal-install).+ Currently it also provides various lower level utilities for creating+ and signing TUF files. .- This is part of the Hackage Security infrastructure.-homepage: http://github.com/well-typed/hackage-security/+ This is part of the [Hackage Security](https://github.com/haskell/hackage-security#readme)+ infrastructure. license: BSD3 license-file: LICENSE author: Edsko de Vries-maintainer: edsko@well-typed.com+maintainer: cabal-devel@haskell.org copyright: Copyright 2015 Well-Typed LLP category: Distribution-homepage: https://github.com/well-typed/hackage-security-bug-reports: https://github.com/well-typed/hackage-security/issues+homepage: https://github.com/haskell/hackage-security+bug-reports: https://github.com/haskell/hackage-security/issues build-type: Simple-cabal-version: >=1.10 extra-source-files: ChangeLog.md source-repository head type: git- location: https://github.com/well-typed/hackage-security.git+ location: https://github.com/haskell/hackage-security.git flag use-network-uri- description: Are we using network-uri?+ description: Are we using @network-uri@? manual: False +flag use-old-time+ description: Are we using @old-time@?+ manual: False+ executable hackage-repo-tool+ hs-source-dirs: src main-is: Main.hs other-modules: Hackage.Security.RepoTool.Options Hackage.Security.RepoTool.Layout@@ -38,18 +46,33 @@ Hackage.Security.RepoTool.Paths Hackage.Security.RepoTool.Util.IO Prelude- build-depends: base >= 4.4 && < 5,- Cabal >= 1.12 && < 1.25,++ build-depends: base >= 4.5 && < 5,+ Cabal >= 1.14 && < 2.4, bytestring >= 0.9 && < 0.11,- directory >= 1.1 && < 1.3,+ directory >= 1.1 && < 1.4, filepath >= 1.2 && < 1.5,- optparse-applicative >= 0.11 && < 0.13,- tar >= 0.4 && < 0.5,- time >= 1.2 && < 1.6,- unix >= 2.5 && < 2.8,+ optparse-applicative >= 0.11 && < 0.15,+ tar >= 0.4 && < 0.6,+ time >= 1.2 && < 1.9, zlib >= 0.5 && < 0.7, hackage-security >= 0.5 && < 0.6- hs-source-dirs: src+ if !os(windows)+ build-depends: unix >= 2.5 && < 2.8++ if flag(use-old-time)+ build-depends: directory < 1.2+ , old-time == 1.1.*+ else+ build-depends: directory >= 1.2++ -- see comments in hackage-security.cabal+ if flag(use-network-uri)+ build-depends: network-uri >= 2.6 && < 2.7,+ network >= 2.6 && < 2.7+ else+ build-depends: network >= 2.5 && < 2.6+ default-language: Haskell2010 default-extensions: DeriveDataTypeable FlexibleContexts@@ -58,12 +81,5 @@ ScopedTypeVariables StandaloneDeriving RecordWildCards- other-extensions: TemplateHaskell- ghc-options: -Wall - -- see comments in hackage-security.cabal- if flag(use-network-uri)- build-depends: network-uri >= 2.6 && < 2.7,- network >= 2.6 && < 2.7- else- build-depends: network >= 2.5 && < 2.6+ ghc-options: -Wall
src/Hackage/Security/RepoTool/Options.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Hackage.Security.RepoTool.Options ( GlobalOpts(..) , Command(..)@@ -60,8 +61,10 @@ -- | Create mirrors metadata | CreateMirrors KeysLoc (Path Absolute) [URI] +#ifndef mingw32_HOST_OS -- | Create a directory with symlinks in cabal-local-rep layout | SymlinkCabalLocalRepo RepoLoc RepoLoc+#endif -- | Sign an individual file | Sign [KeyLoc] DeleteExistingSignatures (Path Absolute)@@ -123,6 +126,7 @@ ]) <*> (many $ argument (str >>= readURI) (metavar "MIRROR")) +#ifndef mingw32_HOST_OS parseSymlinkCabalLocalRepo :: Parser Command parseSymlinkCabalLocalRepo = SymlinkCabalLocalRepo <$> parseRepoLoc@@ -130,6 +134,7 @@ long "cabal-repo" , help "Location of the cabal repo" ])+#endif parseSign :: Parser Command parseSign = Sign@@ -181,8 +186,10 @@ progDesc "Create root metadata" , command "create-mirrors" $ info (helper <*> parseCreateMirrors) $ progDesc "Create mirrors metadata. All MIRRORs specified on the command line will be written to the file."+#ifndef mingw32_HOST_OS , command "symlink-cabal-local-repo" $ info (helper <*> parseSymlinkCabalLocalRepo) $ progDesc "Create a directory in cabal-local-repo layout with symlinks to the specified repository."+#endif , command "sign" $ info (helper <*> parseSign) $ progDesc "Sign a file" ])
src/Hackage/Security/RepoTool/Util/IO.hs view
@@ -4,40 +4,59 @@ -- * Miscellaneous compress , getFileModTime+#ifndef mingw32_HOST_OS , createSymbolicLink+#endif -- * Tar archives , TarGzError , tarExtractFile ) where -import Control.Exception-import Data.Typeable-import System.IO.Error-import qualified Codec.Archive.Tar as Tar-import qualified Codec.Archive.Tar.Entry as Tar-import qualified Codec.Compression.GZip as GZip-import qualified Data.ByteString.Lazy as BS.L---- Unlike the hackage-security library properly,--- this currently works on unix systems only-import System.Posix.Types (EpochTime)-import qualified System.Posix.Files as Posix+import qualified Codec.Archive.Tar as Tar+import qualified Codec.Archive.Tar.Entry as Tar+import qualified Codec.Compression.GZip as GZip+import Control.Exception+import qualified Data.ByteString.Lazy as BS.L+import Data.Typeable+import qualified System.Directory as Directory+import System.IO.Error -- hackage-security-import Hackage.Security.Util.Path+import Hackage.Security.Util.Path -- hackage-repo-tool-import Hackage.Security.RepoTool.Options-import Hackage.Security.RepoTool.Layout-import Hackage.Security.RepoTool.Paths+import Hackage.Security.RepoTool.Layout+import Hackage.Security.RepoTool.Options+import Hackage.Security.RepoTool.Paths +import System.Posix.Types (EpochTime)+#ifndef mingw32_HOST_OS+import qualified System.Posix.Files as Posix+#endif++#if MIN_VERSION_directory(1,2,0)+import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds)+#else+import System.Time (ClockTime (TOD))+#endif+ -- | Get the modification time of the specified file -- -- Returns 0 if the file does not exist . getFileModTime :: GlobalOpts -> RepoLoc -> TargetPath' -> IO EpochTime getFileModTime opts repoLoc targetPath = handle handler $- Posix.modificationTime <$> Posix.getFileStatus (toFilePath fp)+ -- Underlying implementation of 'Directory.getModificationTime' converts+ -- from POSIX seconds, so there shouldn't be loss of precision.+ -- NB: Apparently, this has low clock resolution on GHC < 7.8.+ -- I don't think we care.+#if MIN_VERSION_directory(1,2,0)+ fromInteger . floor . utcTimeToPOSIXSeconds+ <$> Directory.getModificationTime (toFilePath fp)+#else+ Directory.getModificationTime (toFilePath fp) >>= \(TOD s _) ->+ return (fromInteger s)+#endif where fp :: Path Absolute fp = anchorTargetPath' opts repoLoc targetPath@@ -51,6 +70,7 @@ withFile dst WriteMode $ \h -> BS.L.hPut h =<< GZip.compress <$> readLazyByteString src +#ifndef mingw32_HOST_OS -- | Create a symbolic link (unix only) -- -- Create the directory for the target if it does not exist.@@ -66,6 +86,7 @@ linkTarget' <- toAbsoluteFilePath linkTarget linkLoc' <- toAbsoluteFilePath linkLoc Posix.createSymbolicLink linkTarget' linkLoc'+#endif {------------------------------------------------------------------------------- Working with tar archives
src/Main.hs view
@@ -9,10 +9,13 @@ import GHC.Conc.Sync (setUncaughtExceptionHandler) import Network.URI (URI) import System.Exit-import System.IO.Error (isAlreadyExistsError) import qualified Data.ByteString.Lazy as BS.L import qualified System.FilePath as FilePath +#ifndef mingw32_HOST_OS+import System.IO.Error (isAlreadyExistsError)+#endif+ -- Cabal import Distribution.Package import Distribution.Text@@ -54,8 +57,10 @@ createRoot opts keysLoc rootLoc CreateMirrors keysLoc mirrorsLoc mirrors -> createMirrors opts keysLoc mirrorsLoc mirrors+#ifndef mingw32_HOST_OS SymlinkCabalLocalRepo repoLoc cabalRepoLoc -> symlinkCabalLocalRepo opts repoLoc cabalRepoLoc+#endif Sign keys deleteExisting file -> signFile keys deleteExisting file @@ -597,6 +602,7 @@ expectedTarGz :: TargetPath' expectedTarGz = InRepPkg repoLayoutPkgTarGz pkgId +#ifndef mingw32_HOST_OS {------------------------------------------------------------------------------- Creating Cabal-local-repo -------------------------------------------------------------------------------}@@ -621,6 +627,7 @@ target = anchorRepoPath opts repoLoc file loc = anchorRepoPath opts' cabalRepoLoc file opts' = opts { globalRepoLayout = cabalLocalRepoLayout }+#endif {------------------------------------------------------------------------------- Signing individual files