diff --git a/.github/mergify.yml b/.github/mergify.yml index b0dbe1033b8..cc2a294cf0a 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -44,6 +44,7 @@ pull_request_rules: - label=squash+merge me - label=merge delay passed - '#approved-reviews-by>=2' + - '-label~=^blocked:' # merge+no rebase strategy - actions: @@ -55,6 +56,11 @@ pull_request_rules: - label=merge+no rebase - label=merge delay passed - '#approved-reviews-by>=2' + - '-label~=^blocked:' + # unlike the others, we need to force this one to be up to date + # because it's intended for when Mergify doesn't have permission + # to rebase + - '#commits-behind=0' # rebase+merge strategy for backports: require 1 approver instead of 2 - actions: diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index 43f8bf0d2a4..d909d20e17d 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -64,7 +64,6 @@ import Distribution.Simple.Glob ( Glob , GlobResult (..) , globMatches - , parseFileGlob , runDirFileGlob ) import Distribution.Simple.Utils hiding (findPackageDesc, notice) @@ -271,8 +270,6 @@ checkGenericPackageDescription checkP (not . null $ dups names) (PackageBuildImpossible $ DuplicateSections dupes) - -- PackageDescription checks. - checkPackageDescription packageDescription_ -- Flag names. mapM_ checkFlagName genPackageFlags_ @@ -465,18 +462,6 @@ checkPackageDescription mapM_ (checkPath False "license-file" PathKindFile) licPaths mapM_ checkLicFileExist licenseFiles_ - -- § Globs. - dataGlobs <- mapM (checkGlob "data-files") dataFiles_ - extraGlobs <- mapM (checkGlob "extra-source-files") extraSrcFiles_ - docGlobs <- mapM (checkGlob "extra-doc-files") extraDocFiles_ - -- We collect globs to feed them to checkMissingDocs. - - -- § Missing documentation. - checkMissingDocs - (catMaybes dataGlobs) - (catMaybes extraGlobs) - (catMaybes docGlobs) - -- § Datafield checks. checkSetupBuildInfo setupBuildInfo_ mapM_ checkTestedWith testedWith_ @@ -515,13 +500,26 @@ checkPackageDescription (isJust setupBuildInfo_ && buildType pkg /= Custom) (PackageBuildWarning NoCustomSetup) + -- § Globs. + dataGlobs <- catMaybes <$> mapM (checkGlob "data-files" ) dataFiles_ + extraSrcGlobs <- catMaybes <$> mapM (checkGlob "extra-source-files" ) extraSrcFiles_ + docGlobs <- catMaybes <$> mapM (checkGlob "extra-doc-files" ) extraDocFiles_ + -- extraGlobs <- catMaybes <$> mapM (checkGlob "extra-files" . getSymbolicPath) extraFiles_ + -- Contents. checkConfigureExists (buildType pkg) checkSetupExists (buildType pkg) checkCabalFile (packageName pkg) - mapM_ (checkGlobFile specVersion_ "." "extra-source-files") extraSrcFiles_ - mapM_ (checkGlobFile specVersion_ "." "extra-doc-files") extraDocFiles_ - mapM_ (checkGlobFile specVersion_ dataDir_ "data-files") dataFiles_ + extraSrcFilesGlobResults <- mapM (checkGlobFile "." "extra-source-files") extraSrcGlobs + extraDocFilesGlobResults <- mapM (checkGlobFile "." "extra-doc-files") docGlobs + -- extraFilesGlobResults <- mapM (checkGlobFile "." "extra-files") extraGlobs + extraDataFilesGlobResults <- mapM (checkGlobFile dataDir_ "data-files") dataGlobs + + -- § Missing documentation. + checkMissingDocs + extraDataFilesGlobResults + extraSrcFilesGlobResults + extraDocFilesGlobResults where checkNull :: Monad m @@ -830,29 +828,28 @@ checkSetupExists _ = checkGlobFile :: Monad m - => CabalSpecVersion - -> FilePath -- Glob pattern. - -> FilePath -- Folder to check. + => FilePath -- Folder to check. -> CabalField -- .cabal field we are checking. - -> CheckM m () -checkGlobFile cv ddir title fp = do + -> Glob -- Glob pattern. + -> CheckM m [GlobResult FilePath] +checkGlobFile ddir title parsedGlob = do let adjDdir = if null ddir then "." else ddir dir | title == "data-files" = adjDdir | otherwise = "." - - case parseFileGlob cv fp of - -- We just skip over parse errors here; they're reported elsewhere. - Left _ -> return () - Right parsedGlob -> do - liftInt ciPreDistOps $ \po -> do - rs <- runDirFileGlobM po dir parsedGlob - return $ checkGlobResult title fp rs + mpo <- asksCM (ciPreDistOps . ccInterface) + case mpo of + Nothing -> + pure [] + Just po -> do + rs <- liftCM $ runDirFileGlobM po dir parsedGlob + mapM_ tellP (checkGlobResult title parsedGlob rs) + return rs -- | Checks for matchless globs and too strict matching (<2.4 spec). checkGlobResult :: CabalField -- .cabal field we are checking - -> FilePath -- Glob pattern (to show the user + -> Glob -- Glob pattern (to show the user -- which pattern is the offending -- one). -> [GlobResult FilePath] -- List of glob results. @@ -861,7 +858,7 @@ checkGlobResult title fp rs = dirCheck ++ catMaybes (map getWarning rs) where dirCheck | all (not . withoutNoMatchesWarning) rs = - [PackageDistSuspiciousWarn $ GlobNoMatch title fp] + [PackageDistSuspiciousWarn $ GlobNoMatch title (prettyShow fp)] | otherwise = [] -- If there's a missing directory in play, since globs in Cabal packages @@ -880,9 +877,9 @@ checkGlobResult title fp rs = dirCheck ++ catMaybes (map getWarning rs) -- suffix. This warning detects when pre-2.4 package descriptions -- are omitting files purely because of the stricter check. getWarning (GlobWarnMultiDot file) = - Just $ PackageDistSuspiciousWarn (GlobExactMatch title fp file) + Just $ PackageDistSuspiciousWarn (GlobExactMatch title (prettyShow fp) file) getWarning (GlobMissingDirectory dir) = - Just $ PackageDistSuspiciousWarn (GlobNoDir title fp dir) + Just $ PackageDistSuspiciousWarn (GlobNoDir title (prettyShow fp) dir) -- GlobMatchesDirectory is handled elsewhere if relevant; -- we can discard it here. getWarning (GlobMatchesDirectory _) = Nothing @@ -984,9 +981,9 @@ pd2gpd pd = gpd -- present in our .cabal file. checkMissingDocs :: Monad m - => [Glob] -- data-files globs. - -> [Glob] -- extra-source-files globs. - -> [Glob] -- extra-doc-files globs. + => [[GlobResult FilePath]] -- data-files globs. + -> [[GlobResult FilePath]] -- extra-source-files globs. + -> [[GlobResult FilePath]] -- extra-doc-files globs. -> CheckM m () checkMissingDocs dgs esgs edgs = do extraDocSupport <- (>= CabalSpecV1_18) <$> asksCM ccSpecVersion @@ -1002,11 +999,10 @@ checkMissingDocs dgs esgs edgs = do -- 2. Realise Globs. let realGlob t = - concatMap globMatches - <$> mapM (runDirFileGlobM ops "") t - rgs <- realGlob dgs - res <- realGlob esgs - red <- realGlob edgs + concatMap globMatches t + let rgs = realGlob dgs + let res = realGlob esgs + let red = realGlob edgs -- 3. Check if anything in 1. is missing in 2. let mcs = checkDoc extraDocSupport des (rgs ++ res ++ red) diff --git a/Cabal/src/Distribution/PackageDescription/Check/Monad.hs b/Cabal/src/Distribution/PackageDescription/Check/Monad.hs index 23d37570800..0ca3359597c 100644 --- a/Cabal/src/Distribution/PackageDescription/Check/Monad.hs +++ b/Cabal/src/Distribution/PackageDescription/Check/Monad.hs @@ -37,6 +37,7 @@ module Distribution.PackageDescription.Check.Monad , checkP , checkPkg , liftInt + , liftCM , tellP , checkSpecVer ) where diff --git a/Cabal/src/Distribution/Simple/Build/Macros.hs b/Cabal/src/Distribution/Simple/Build/Macros.hs index 3dbce8616fc..f3c51d71c96 100644 --- a/Cabal/src/Distribution/Simple/Build/Macros.hs +++ b/Cabal/src/Distribution/Simple/Build/Macros.hs @@ -58,7 +58,7 @@ generateCabalMacrosHeader pkg_descr lbi clbi = , let (major1, major2, minor) = majorMinor ver ] , Z.zPackageKey = case clbi of - LibComponentLocalBuildInfo{} -> componentCompatPackageKey clbi + LibComponentLocalBuildInfo{componentCompatPackageKey = compatPackageKey} -> compatPackageKey _ -> "" , Z.zComponentId = prettyShow (componentComponentId clbi) , Z.zPackageVersion = pkgVersion (package pkg_descr) diff --git a/Cabal/src/Distribution/Simple/PreProcess/Types.hs b/Cabal/src/Distribution/Simple/PreProcess/Types.hs index 02a5bdbc531..5531bc7d629 100644 --- a/Cabal/src/Distribution/Simple/PreProcess/Types.hs +++ b/Cabal/src/Distribution/Simple/PreProcess/Types.hs @@ -41,11 +41,12 @@ import qualified Text.PrettyPrint as Disp -- > ppTestHandler = -- > PreProcessor { -- > platformIndependent = True, +-- > ppOrdering = \_ _ -> return, -- > runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> -- > do info verbosity (inFile++" has been preprocessed to "++outFile) -- > stuff <- readFile inFile -- > writeFile outFile ("-- preprocessed as a test\n\n" ++ stuff) --- > return ExitSuccess +-- > return () -- -- We split the input and output file names into a base directory and the -- rest of the file name. The input base dir is the path in the list of search diff --git a/Cabal/src/Distribution/Simple/Register.hs b/Cabal/src/Distribution/Simple/Register.hs index 4cfc5ba8801..ee8c99fbabb 100644 --- a/Cabal/src/Distribution/Simple/Register.hs +++ b/Cabal/src/Distribution/Simple/Register.hs @@ -489,9 +489,9 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi { IPI.sourcePackageId = packageId pkg , IPI.installedUnitId = componentUnitId clbi , IPI.installedComponentId_ = componentComponentId clbi - , IPI.instantiatedWith = componentInstantiatedWith clbi + , IPI.instantiatedWith = expectLibraryComponent (maybeComponentInstantiatedWith clbi) , IPI.sourceLibName = libName lib - , IPI.compatPackageKey = componentCompatPackageKey clbi + , IPI.compatPackageKey = expectLibraryComponent (maybeComponentCompatPackageKey clbi) , -- If GHC >= 8.4 we register with SDPX, otherwise with legacy license IPI.license = if ghc84 @@ -510,7 +510,7 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi , IPI.indefinite = componentIsIndefinite clbi , IPI.exposed = libExposed lib , IPI.exposedModules = - componentExposedModules clbi + expectLibraryComponent (maybeComponentExposedModules clbi) -- add virtual modules into the list of exposed modules for the -- package database as well. ++ map (\name -> IPI.ExposedModule name Nothing) (virtualModules bi) @@ -591,7 +591,13 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi , dynlibdir installDirs : extraLibDirs bi ) | otherwise = +-- <<<<<<< HEAD (libdir installDirs : dynlibdir installDirs : extraLibDirs bi, []) +-- ======= +-- (libdir installDirs : dynlibdir installDirs : extraLibDirs', []) + expectLibraryComponent (Just attribute) = attribute + expectLibraryComponent Nothing = (error "generalInstalledPackageInfo: Expected a library component, got something else.") +-- >>>>>>> 68333b35a (Merge branch 'mattp/skip-glob-filepaths-2' into mattp/cabal-glob-perf-improvements) -- the compiler doesn't understand the dynamic-library-dirs field so we -- add the dyn directory to the "normal" list in the library-dirs field diff --git a/Cabal/src/Distribution/Simple/Setup/Repl.hs b/Cabal/src/Distribution/Simple/Setup/Repl.hs index 2fae5bffcd4..ef9b6935aa6 100644 --- a/Cabal/src/Distribution/Simple/Setup/Repl.hs +++ b/Cabal/src/Distribution/Simple/Setup/Repl.hs @@ -100,8 +100,7 @@ replCommand progDb = , commandDescription = Just $ \pname -> wrapText $ "If the current directory contains no package, ignores COMPONENT " - ++ "parameters and opens an interactive interpreter session; if a " - ++ "sandbox is present, its package database will be used.\n" + ++ "parameters and opens an interactive interpreter session.\n" ++ "\n" ++ "Otherwise, (re)configures with the given or default flags, and " ++ "loads the interpreter with the relevant modules. For executables, " diff --git a/Cabal/src/Distribution/Types/ComponentLocalBuildInfo.hs b/Cabal/src/Distribution/Types/ComponentLocalBuildInfo.hs index 0728656620e..9e63cae52ea 100644 --- a/Cabal/src/Distribution/Types/ComponentLocalBuildInfo.hs +++ b/Cabal/src/Distribution/Types/ComponentLocalBuildInfo.hs @@ -6,6 +6,8 @@ module Distribution.Types.ComponentLocalBuildInfo ( ComponentLocalBuildInfo (..) , componentIsIndefinite , maybeComponentInstantiatedWith + , maybeComponentCompatPackageKey + , maybeComponentExposedModules ) where import Distribution.Compat.Prelude @@ -126,3 +128,13 @@ maybeComponentInstantiatedWith :: ComponentLocalBuildInfo -> Maybe [(ModuleName, maybeComponentInstantiatedWith LibComponentLocalBuildInfo{componentInstantiatedWith = insts} = Just insts maybeComponentInstantiatedWith _ = Nothing + +maybeComponentCompatPackageKey :: ComponentLocalBuildInfo -> Maybe String +maybeComponentCompatPackageKey + LibComponentLocalBuildInfo{componentCompatPackageKey = key} = Just key +maybeComponentCompatPackageKey _ = Nothing + +maybeComponentExposedModules :: ComponentLocalBuildInfo -> Maybe [Installed.ExposedModule] +maybeComponentExposedModules + LibComponentLocalBuildInfo{componentExposedModules = exposed} = Just exposed +maybeComponentExposedModules _ = Nothing diff --git a/cabal-install/src/Distribution/Client/CmdInstall.hs b/cabal-install/src/Distribution/Client/CmdInstall.hs index b39b97278ae..8df481f589a 100644 --- a/cabal-install/src/Distribution/Client/CmdInstall.hs +++ b/cabal-install/src/Distribution/Client/CmdInstall.hs @@ -1123,8 +1123,8 @@ symlink overwritePolicy installDir (mkSourceBinDir unit) - (mkExeName exe) (mkFinalExeName exe) + (mkExeName exe) -- | -- -- * When 'InstallCheckOnly', warn if install would fail overwrite policy @@ -1169,7 +1169,7 @@ installCheckUnitExes errorMessage installdir exe = case overwritePolicy of NeverOverwrite -> "Path '" - <> (installdir prettyShow exe) + <> (installdir mkFinalExeName exe) <> "' already exists. " <> "Use --overwrite-policy=always to overwrite." -- This shouldn't even be possible, but we keep it in case symlinking or diff --git a/cabal-testsuite/PackageTests/Install/ProgramAffixes/overwrite-policy.out b/cabal-testsuite/PackageTests/Install/ProgramAffixes/overwrite-policy.out new file mode 100644 index 00000000000..cf1c952c9d3 --- /dev/null +++ b/cabal-testsuite/PackageTests/Install/ProgramAffixes/overwrite-policy.out @@ -0,0 +1,160 @@ +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Build profile: -w ghc- -O1 +In order, the following will be built: + - p-1.0 (exe:p) (requires build) +Configuring p-1.0... +Preprocessing executable 'p' for p-1.0... +Building executable 'p' for p-1.0... +Installing executable p in +Warning: The directory /overwrite-policy.dist/home/.cabal/store/ghc-/incoming/new-/overwrite-policy.dist/home/.cabal/store/ghc-/-/bin is not in the system search path. +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Error: [Cabal-7149] +Path '/overwrite-policy.dist/usr/bin/p' already exists. Use --overwrite-policy=always to overwrite. +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p-my-suffix' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Error: [Cabal-7149] +Path '/overwrite-policy.dist/usr/bin/p-my-suffix' already exists. Use --overwrite-policy=always to overwrite. +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p-my-suffix' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/my-prefix-p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Error: [Cabal-7149] +Path '/overwrite-policy.dist/usr/bin/my-prefix-p' already exists. Use --overwrite-policy=always to overwrite. +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/my-prefix-p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Error: [Cabal-7149] +Path '/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' already exists. Use --overwrite-policy=always to overwrite. +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Symlinking 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Error: [Cabal-7149] +Path '/overwrite-policy.dist/usr/bin/p' already exists. Use --overwrite-policy=always to overwrite. +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p-my-suffix' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Error: [Cabal-7149] +Path '/overwrite-policy.dist/usr/bin/p-my-suffix' already exists. Use --overwrite-policy=always to overwrite. +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p-my-suffix' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/my-prefix-p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Error: [Cabal-7149] +Path '/overwrite-policy.dist/usr/bin/my-prefix-p' already exists. Use --overwrite-policy=always to overwrite. +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/my-prefix-p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Error: [Cabal-7149] +Path '/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' already exists. Use --overwrite-policy=always to overwrite. +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' +# cabal install +Wrote tarball sdist to /overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz +Resolving dependencies... +Copying 'p' to '/overwrite-policy.dist/usr/bin/p' diff --git a/cabal-testsuite/PackageTests/Install/ProgramAffixes/overwrite-policy.test.hs b/cabal-testsuite/PackageTests/Install/ProgramAffixes/overwrite-policy.test.hs new file mode 100644 index 00000000000..f94fa436387 --- /dev/null +++ b/cabal-testsuite/PackageTests/Install/ProgramAffixes/overwrite-policy.test.hs @@ -0,0 +1,66 @@ +import Test.Cabal.Prelude +import System.FilePath (()) +import System.Directory (removeFile) + +main = cabalTest $ do + runTestForInstallMethod "symlink" + runTestForInstallMethod "copy" + +runTestForInstallMethod :: String -> TestM () +runTestForInstallMethod method = do + env <- getTestEnv + let installdir = testPrefixDir env "bin" + + -- install the binary, don't overwrite anything + cabal "install" + ["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] + -- install the binary, don't overwrite anything + fails $ cabal "install" + ["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] + -- install the binary again, forcing an overwrite, should succeed. + cabal "install" + ["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "always"] + -- remove the installed binary. + liftIO $ removeFile (installdir "p" <.> exeExt) + + testPolicyForAffix installdir method ["--program-suffix", "-my-suffix"] + testPolicyForAffix installdir method ["--program-prefix", "my-prefix-"] + testPolicyForAffix installdir method ["--program-prefix", "my-prefix-", "--program-suffix", "-my-suffix"] + -- remove the installed binaries. + liftIO $ removeFile (installdir "p" <.> exeExt) + liftIO $ removeFile (installdir "p-my-suffix" <.> exeExt) + liftIO $ removeFile (installdir "my-prefix-p" <.> exeExt) + liftIO $ removeFile (installdir "my-prefix-p-my-suffix" <.> exeExt) + +-- | Run a policy test for a given 'install-method' and program-affix +-- (i.e., '--program-suffix' or '--program-prefix'). +-- +-- When a program affix is given, the installation should not be affected +-- by installing the binary with no affix and vice-versa. +-- So, installing the program without any affix is not affected by installations with +-- some program affix. +testPolicyForAffix :: FilePath -> String -> [String] -> TestM () +testPolicyForAffix installdir method affixArgs = do + -- install the binary again, forcing an overwrite, must succeed. + -- The rest of this test assumes the binary has been installed before. + cabal "install" + ["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "always"] + + -- Install the binary with some program affix, don't need overwrite anything + cabal "install" + (["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] ++ affixArgs) + -- Once the binary is installed, we can't overwrite it unless we are told so. + fails $ cabal "install" + (["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] ++ affixArgs) + -- Successfully overwrite the binary if told so. + cabal "install" + (["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "always"] ++ affixArgs) + + -- remove the installed binary. + liftIO $ removeFile (installdir "p" <.> exeExt) + -- Make sure we can still install the original program with no program affix without overwriting, + -- even though, the program is already installed with some affix. + cabal "install" + ["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] + +exeExt = if isWindows then "exe" else "" diff --git a/changelog.d/pr-10493 b/changelog.d/pr-10493 new file mode 100644 index 00000000000..ec4beabe2df --- /dev/null +++ b/changelog.d/pr-10493 @@ -0,0 +1,11 @@ +synopsis: Remove descriptions for sandbox in replCommand +packages: Cabal +prs: #10493 +issues: #10482 +significance: significant + +description: { + +- Text provided by `Setup.hs repl --help` contained outdated information concerning sandbox, which have now been removed. + +} \ No newline at end of file diff --git a/doc/setup-commands.rst b/doc/setup-commands.rst index 20bdafabfae..ff9dd95dca7 100644 --- a/doc/setup-commands.rst +++ b/doc/setup-commands.rst @@ -1387,3 +1387,60 @@ This command takes the following option: .. include:: references.inc + +.. _setup-repl: + +runhaskell Setup.hs repl +------------------------ + +Open an interpreter session for the given component. + +Usage: + +.. program:: runhaskell Setup.hs repl [COMPONENT] [FLAGS] + +If the current directory contains no package, ignores COMPONENT parameters and +opens an interactive interpreter session. + +Otherwise, (re)configures with the given or default flags, and loads the +interpreter with the relevant modules. For executables, tests and benchmarks, +loads the main module (and its dependencies); for libraries all exposed/other +modules. + +The default component is the library itself, or the executable if that is the +only component. + +Support for loading specific modules is planned but not implemented yet. For +certain scenarios, ``Setup.hs exec -- ghci :l Foo`` may be used instead. Note +that ``exec`` will not (re)configure and you will have to specify the location +of other modules, if required. + +Flags for repl: + +.. option:: -v, --verbose[=n] + + Control verbosity (n is 0--3, default verbosity level is 1). + +.. option:: --builddir=DIR + + The directory where Cabal puts generated build files (default dist). + +.. option:: --with-PROG=PATH + + Give the path to PROG. + +.. option:: --PROG-option=OPT + + Give an extra option to PROG (no need to quote options containing spaces). + +.. option:: --PROG-options=OPTS + + Give extra options to PROG. + +.. option:: --repl-no-load + + Disable loading of project modules at REPL startup. + +.. option:: --repl-options=FLAG + + Use the option(s) for the repl.