From f8ab58caaa589f08b1ab8ede3a302b97c12d3a7a Mon Sep 17 00:00:00 2001
From: Javier Sagredo <jasataco@gmail.com>
Date: Tue, 9 Jul 2024 00:59:27 +0200
Subject: [PATCH] Fix local+noindex repos on Windows

---
 .../src/Distribution/Client/IndexUtils.hs          |  4 ++--
 cabal-testsuite/src/Test/Cabal/Prelude.hs          | 14 +++++---------
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/cabal-install/src/Distribution/Client/IndexUtils.hs b/cabal-install/src/Distribution/Client/IndexUtils.hs
index 5958deca55..23a7754a06 100644
--- a/cabal-install/src/Distribution/Client/IndexUtils.hs
+++ b/cabal-install/src/Distribution/Client/IndexUtils.hs
@@ -149,7 +149,7 @@ import System.FilePath
   , (<.>)
   , (</>)
   )
-import qualified System.FilePath.Posix as FilePath.Posix
+import qualified System.FilePath as FilePath
 import System.IO
 import System.IO.Error (isDoesNotExistError)
 import System.IO.Unsafe (unsafeInterleaveIO)
@@ -928,7 +928,7 @@ withIndexEntries verbosity (RepoIndex _repoCtxt (RepoLocalNoIndex (LocalRepo nam
           let bs = BS.toStrict contents
            in ((`CacheGPD` bs) <$> parseGenericPackageDescriptionMaybe bs)
       where
-        filename = prettyShow pkgId FilePath.Posix.</> prettyShow (packageName pkgId) ++ ".cabal"
+        filename = prettyShow pkgId FilePath.</> prettyShow (packageName pkgId) ++ ".cabal"
     readCabalEntry _ _ x = x
 withIndexEntries verbosity index callback _ = do
   -- non-secure repositories
diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs
index d110bd9f43..176b3d994a 100644
--- a/cabal-testsuite/src/Test/Cabal/Prelude.hs
+++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs
@@ -544,7 +544,6 @@ src `archiveTo` dst = do
     -- TODO: --format ustar, like createArchive?
     -- --force-local is necessary for handling colons in Windows paths.
     tar $ ["-czf", dst]
-       ++ ["--force-local" | buildOS == Windows]
        ++ ["-C", src_parent, src_dir]
 
 infixr 4 `archiveTo`
@@ -554,10 +553,6 @@ infixr 4 `archiveTo`
 -- external repository corresponding to all of these packages
 withRepo :: FilePath -> TestM a -> TestM a
 withRepo repo_dir m = do
-    -- https://github.com/haskell/cabal/issues/7065
-    -- you don't simply put a windows path into URL...
-    skipIfWindows
-
     env <- getTestEnv
 
     -- 1. Initialize repo directory
@@ -603,16 +598,17 @@ withRepo repo_dir m = do
     withReaderT (\env' -> env' { testHaveRepo = True }) m
     -- TODO: Arguably should undo everything when we're done...
   where
-    repoUri env ="file+noindex://" ++ testRepoDir env
+    repoUri env ="file+noindex://" ++ (if isWindows
+                                        then map (\x -> case x of
+                                            '\\' -> '/'
+                                            _ -> x)
+                                        else id) (testRepoDir env)
 
 -- | Given a directory (relative to the 'testCurrentDir') containing
 -- a series of directories representing packages, generate an
 -- remote repository corresponding to all of these packages
 withRemoteRepo :: FilePath -> TestM a -> TestM a
 withRemoteRepo repoDir m = do
-    -- https://github.com/haskell/cabal/issues/7065
-    -- you don't simply put a windows path into URL...
-    skipIfWindows
 
     -- we rely on the presence of python3 for a simple http server
     skipUnless "no python3" =<< isAvailableProgram python3Program
-- 
GitLab