From 415455883c1b8ce8d3077146471370c4fe9346d3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Jan 2025 16:37:54 -0400 Subject: [PATCH 1/4] debug test suite crash on windows --- Git/HashObject.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Git/HashObject.hs b/Git/HashObject.hs index 35031f20ae..85d027348b 100644 --- a/Git/HashObject.hs +++ b/Git/HashObject.hs @@ -49,6 +49,10 @@ hashFile hdl@(HashObjectHandle h _ _) file = do -- So, make the filename absolute, which will work now -- and also if git's behavior later changes. file' <- absPath file + -- XXX windows crash debugging +#ifndef mingw32_HOST_OS + hPutStrLn stderr $ show ("hashFile called on file", file, "abspath is", file') +#endif if newline `S.elem` file' || carriagereturn `S.elem` file then hashFile' hdl file else CoProcess.query h (send file') receive From 998de2e7cea9e184f48c4219d09ad18f5147cae3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Jan 2025 17:19:01 -0400 Subject: [PATCH 2/4] remove temp debugging code --- Git/HashObject.hs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Git/HashObject.hs b/Git/HashObject.hs index 85d027348b..704d310c9d 100644 --- a/Git/HashObject.hs +++ b/Git/HashObject.hs @@ -5,7 +5,6 @@ - Licensed under the GNU AGPL version 3 or higher. -} -{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Git.HashObject where @@ -49,10 +48,6 @@ hashFile hdl@(HashObjectHandle h _ _) file = do -- So, make the filename absolute, which will work now -- and also if git's behavior later changes. file' <- absPath file - -- XXX windows crash debugging -#ifndef mingw32_HOST_OS - hPutStrLn stderr $ show ("hashFile called on file", file, "abspath is", file') -#endif if newline `S.elem` file' || carriagereturn `S.elem` file then hashFile' hdl file else CoProcess.query h (send file') receive From 55cf9ce28fe1c8a4ee64f1843cd3a88e85bcbf35 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Jan 2025 17:22:21 -0400 Subject: [PATCH 3/4] disable OsPath build flag on windows for now Test suite failure looks like this: fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory fatal: could not open '\\?\C:\Users\appveyor\AppData\Local\Temp\1\hash-cc81b41d-dfda-4ae8-904b-b531742443cc' for reading: No such file or directory git-annex: fd:4: Data.ByteString.hGetLine: end of file git-annex: user error (git ["--git-dir=.git","--work-tree=.","--literal-pathspecs","hash-object","-w","--no-filters","--stdin-paths"] exited 128) This is apparently in Git.HashObject, and probably in hashBlob, which uses a temp file with a name starting with "hash", but I have not been able to tell what's wrong. I don't understand where the "\\?" path prefix (windows UNC-style path) is coming from in the path that gets fed into git hash-file, or why git hash-file can't open the file. --- git-annex.cabal | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/git-annex.cabal b/git-annex.cabal index b662fe482e..b610cdf65c 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -333,12 +333,14 @@ Executable git-annex P2P.Http.State if flag(OsPath) - Build-Depends: - os-string (>= 2.0.0), - directory (>= 1.3.8.3), - filepath (>= 1.5.2.0), - file-io (>= 0.1.3) - CPP-Options: -DWITH_OSPATH + -- Currently this build flag does not pass the test suite on Windows + if (! os(windows)) + Build-Depends: + os-string (>= 2.0.0), + directory (>= 1.3.8.3), + filepath (>= 1.5.2.0), + file-io (>= 0.1.3) + CPP-Options: -DWITH_OSPATH if (os(windows)) Build-Depends: From aaf4dd3b9cc71752624dd81352c242eeabe912c2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Jan 2025 18:12:00 -0400 Subject: [PATCH 4/4] fix liuxstandalone build --- Build/LinuxMkLibs.hs | 5 +++-- Build/Standalone.hs | 22 ++++++++++++---------- Utility/FileIO.hs | 1 - 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Build/LinuxMkLibs.hs b/Build/LinuxMkLibs.hs index 434b6c31bd..fad73c4c76 100644 --- a/Build/LinuxMkLibs.hs +++ b/Build/LinuxMkLibs.hs @@ -26,11 +26,12 @@ import Utility.Path.AbsRel import Utility.FileMode import Utility.CopyFile import Utility.FileSystemEncoding +import Utility.SystemDirectory mklibs :: FilePath -> a -> IO Bool mklibs top _installedbins = do - fs <- dirContentsRecursive top - exes <- filterM checkExe fs + fs <- dirContentsRecursive (toRawFilePath top) + exes <- filterM checkExe (map fromRawFilePath fs) libs <- runLdd exes glibclibs <- glibcLibs diff --git a/Build/Standalone.hs b/Build/Standalone.hs index 367527430a..36a4d5a002 100644 --- a/Build/Standalone.hs +++ b/Build/Standalone.hs @@ -25,6 +25,7 @@ import Utility.Path.AbsRel import Utility.Directory import Utility.Env import Utility.FileSystemEncoding +import Utility.SystemDirectory import Build.BundledPrograms #ifdef darwin_HOST_OS import System.IO @@ -71,14 +72,15 @@ installGitLibs topdir = do -- install git-core programs; these are run by the git command createDirectoryIfMissing True gitcoredestdir execpath <- getgitpath "exec-path" - cfs <- dirContents execpath + cfs <- dirContents (toRawFilePath execpath) forM_ cfs $ \f -> do + let f' = fromRawFilePath f destf <- ((gitcoredestdir ) . fromRawFilePath) <$> relPathDirToFile (toRawFilePath execpath) - (toRawFilePath f) + f createDirectoryIfMissing True (takeDirectory destf) - issymlink <- isSymbolicLink <$> getSymbolicLinkStatus f + issymlink <- isSymbolicLink <$> getSymbolicLinkStatus f' if issymlink then do -- many git-core files may symlink to eg @@ -91,20 +93,20 @@ installGitLibs topdir = do -- Other git-core files symlink to a file -- beside them in the directory. Those -- links can be copied as-is. - linktarget <- readSymbolicLink f + linktarget <- readSymbolicLink f' if takeFileName linktarget == linktarget - then cp f destf + then cp f' destf else do let linktarget' = progDir topdir takeFileName linktarget unlessM (doesFileExist linktarget') $ do createDirectoryIfMissing True (takeDirectory linktarget') - L.readFile f >>= L.writeFile linktarget' + L.readFile f' >>= L.writeFile linktarget' removeWhenExistsWith removeLink destf rellinktarget <- relPathDirToFile (toRawFilePath (takeDirectory destf)) (toRawFilePath linktarget') createSymbolicLink (fromRawFilePath rellinktarget) destf - else cp f destf + else cp f' destf -- install git's template files -- git does not have an option to get the path of these, @@ -112,14 +114,14 @@ installGitLibs topdir = do -- next to the --man-path, in eg /usr/share/git-core manpath <- getgitpath "man-path" let templatepath = manpath ".." "git-core" "templates" - tfs <- dirContents templatepath + tfs <- dirContents (toRawFilePath templatepath) forM_ tfs $ \f -> do destf <- ((templatedestdir ) . fromRawFilePath) <$> relPathDirToFile (toRawFilePath templatepath) - (toRawFilePath f) + f createDirectoryIfMissing True (takeDirectory destf) - cp f destf + cp (fromRawFilePath f) destf where gitcoredestdir = topdir "git-core" templatedestdir = topdir "templates" diff --git a/Utility/FileIO.hs b/Utility/FileIO.hs index f3bd23ad71..4b12b2ba0e 100644 --- a/Utility/FileIO.hs +++ b/Utility/FileIO.hs @@ -93,7 +93,6 @@ openTempFile p s = do -- file content in that case, unlike the Strings used by the Prelude. import Utility.OsPath import System.IO (withFile, openFile, openTempFile, IO) -import qualified System.IO import Data.ByteString.Lazy (readFile, writeFile, appendFile) import qualified Data.ByteString as B