From b5c693fa5882f5219580929b045bf5d8a1a5ef61 Mon Sep 17 00:00:00 2001 From: Tamar Christina Date: Tue, 26 Dec 2017 07:36:54 +0000 Subject: [PATCH] Cabal: Fix path redundancy new-build output folders. --- Cabal/Distribution/Simple/InstallDirs.hs | 4 ++-- cabal-install/Distribution/Client/ProjectBuilding.hs | 10 ++++------ cabal-install/Distribution/Client/Store.hs | 5 ++++- cabal-install/changelog | 2 ++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cabal/Distribution/Simple/InstallDirs.hs b/Cabal/Distribution/Simple/InstallDirs.hs index f74bc14d6cd..96c178abb04 100644 --- a/Cabal/Distribution/Simple/InstallDirs.hs +++ b/Cabal/Distribution/Simple/InstallDirs.hs @@ -59,7 +59,7 @@ import Distribution.Text import System.Directory (getAppUserDataDirectory) import System.FilePath ( (), isPathSeparator - , pathSeparator, dropDrive ) + , pathSeparator, takeBaseName ) #ifdef mingw32_HOST_OS import qualified Prelude @@ -286,7 +286,7 @@ absoluteInstallDirs :: PackageIdentifier -> InstallDirs FilePath absoluteInstallDirs pkgId libname compilerId copydest platform dirs = (case copydest of - CopyTo destdir -> fmap ((destdir ) . dropDrive) + CopyTo destdir -> fmap ((destdir ) . takeBaseName) _ -> id) . appendSubdirs () . fmap fromPathTemplate diff --git a/cabal-install/Distribution/Client/ProjectBuilding.hs b/cabal-install/Distribution/Client/ProjectBuilding.hs index 1e91b5e187c..3e88b823d43 100644 --- a/cabal-install/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/Distribution/Client/ProjectBuilding.hs @@ -940,12 +940,10 @@ buildAndInstallUnpackedPackage verbosity annotateFailure mlogFile InstallFailed $ do let copyPkgFiles tmpDir = do - setup Cabal.copyCommand (copyFlags tmpDir) - -- Note that the copy command has put the files into - -- @$tmpDir/$prefix@ so we need to return this dir so - -- the store knows which dir will be the final store entry. - let prefix = dropDrive (InstallDirs.prefix (elabInstallDirs pkg)) + let prefix = let path = InstallDirs.prefix (elabInstallDirs pkg) + in takeBaseName path entryDir = tmpDir prefix + setup Cabal.copyCommand (copyFlags entryDir) LBS.writeFile (entryDir "cabal-hash.txt") (renderPackageHashInputs (packageHashInputs pkgshared pkg)) @@ -954,7 +952,7 @@ buildAndInstallUnpackedPackage verbosity -- While this breaks the prefix-relocatable property of the lirbaries -- it is necessary on macOS to stay under the load command limit of the -- macOS mach-o linker. See also @PackageHash.hashedInstalledPackageIdVeryShort@. - otherFiles <- filter (not . isPrefixOf entryDir) <$> listFilesRecursive tmpDir + otherFiles <- filter (not . isPrefixOf entryDir) <$> listFilesRecursive tmpDir -- here's where we could keep track of the installed files ourselves -- if we wanted to by making a manifest of the files in the tmp dir return (entryDir, otherFiles) diff --git a/cabal-install/Distribution/Client/Store.hs b/cabal-install/Distribution/Client/Store.hs index 4afdb3a264f..2649eb1dcd2 100644 --- a/cabal-install/Distribution/Client/Store.hs +++ b/cabal-install/Distribution/Client/Store.hs @@ -209,7 +209,10 @@ newStoreEntry verbosity storeDirLayout@StoreDirLayout{..} -- Atomically rename the temp dir to the final store entry location. renameDirectory incomingEntryDir finalEntryDir forM_ otherFiles $ \file -> do - let finalStoreFile = storeDirectory compid makeRelative (incomingTmpDir (dropDrive (storeDirectory compid))) file + let finalStoreFile = storeDirectory compid + makeRelative (incomingTmpDir + (takeBaseName (storeDirectory compid))) + file createDirectoryIfMissing True (takeDirectory finalStoreFile) renameFile file finalStoreFile diff --git a/cabal-install/changelog b/cabal-install/changelog index 9ed760eb5ac..861e19fc5e9 100644 --- a/cabal-install/changelog +++ b/cabal-install/changelog @@ -46,6 +46,8 @@ * Added support for '--enable-tests' and '--enable-benchmarks' to 'cabal fetch' (#4948). * Removed support for building cabal-install with GHC < 7.10. + * Redundancy in new-build incoming store paths removed. This makes incoming + tmp paths much shorter. (#4515, #3972) 2.0.0.1 Mikhail Glushenkov December 2017 * Support for GHC's numeric -g debug levels (#4673).