Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
build: off

before_test:
# http://help.appveyor.com/discussions/problems/6312-curl-command-not-found
- set PATH=C:\Program Files\Git\mingw64\bin;%PATH%

- curl -sS -ostack.zip -L --insecure http://www.stackage.org/stack/windows-x86_64
- 7z x stack.zip stack.exe

clone_folder: "c:\\stack"
environment:
global:
STACK_ROOT: "c:\\sr"

test_script:
- stack setup > nul
# The ugly echo "" hack is to avoid complaints about 0 being an invalid file
# descriptor
- echo "" | stack --no-terminal test
3 changes: 2 additions & 1 deletion hackage-repo-tool/hackage-repo-tool.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ executable hackage-repo-tool
optparse-applicative >= 0.11 && < 0.15,
tar >= 0.4 && < 0.6,
time >= 1.2 && < 1.9,
unix >= 2.5 && < 2.8,
zlib >= 0.5 && < 0.7,
hackage-security >= 0.5 && < 0.6
if !os(windows)
build-depends: unix >= 2.5 && < 2.8
hs-source-dirs: src
default-language: Haskell2010
default-extensions: DeriveDataTypeable
Expand Down
25 changes: 19 additions & 6 deletions hackage-repo-tool/src/Hackage/Security/RepoTool/Util/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ module Hackage.Security.RepoTool.Util.IO (

import Control.Exception
import Data.Typeable
import Data.Time.Clock.POSIX
import System.IO.Error
import qualified System.Directory as Directory
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

-- hackage-security
import Hackage.Security.Util.Path

Expand All @@ -31,13 +28,23 @@ import Hackage.Security.RepoTool.Options
import Hackage.Security.RepoTool.Layout
import Hackage.Security.RepoTool.Paths

import System.Posix.Types (EpochTime)
#ifndef mingw32_HOST_OS
import qualified System.Posix.Files as Posix
#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.
fromInteger . floor . utcTimeToPOSIXSeconds
<$> Directory.getModificationTime (toFilePath fp)
where
fp :: Path Absolute
fp = anchorTargetPath' opts repoLoc targetPath
Expand All @@ -62,10 +69,16 @@ createSymbolicLink :: (FsRoot root, FsRoot root')
-> Path root' -- ^ Link location
-> IO ()
createSymbolicLink linkTarget linkLoc = do
#ifndef mingw32_HOST_OS
createDirectoryIfMissing True (takeDirectory linkLoc)
linkTarget' <- toAbsoluteFilePath linkTarget
linkLoc' <- toAbsoluteFilePath linkLoc
Posix.createSymbolicLink linkTarget' linkLoc'
#else
error $ "Cannot create symbolic links on Windows"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@23Skidoo this makes symlink-cabal-local-repo command fail. Not that it's useful on Windows, but I'd much happier disabling that codepath cleanly (i.e. disabling the command on windows), and not creating technical debt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, but this #ifdef will still be needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by cleanly i mean: #ifdef the whole function, and see what breaks -> disable that with good error message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I can look into it tomorrow.

where
_ = (linkTarget, linkLoc) -- -Wall suppression
#endif

{-------------------------------------------------------------------------------
Working with tar archives
Expand Down