Commit aff83e61 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Remove support for root-cmd, fixes #3353.


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 030259c7
......@@ -248,7 +248,6 @@ instance Semigroup SavedConfig where
installUpgradeDeps = combine installUpgradeDeps,
installOnly = combine installOnly,
installOnlyDeps = combine installOnlyDeps,
installRootCmd = combine installRootCmd,
installSummaryFile = lastNonEmptyNL installSummaryFile,
installLogFile = combine installLogFile,
installBuildReports = combine installBuildReports,
......
......@@ -106,7 +106,6 @@ import qualified Distribution.Client.InstallSymlink as InstallSymlink
import qualified Distribution.Client.Win32SelfUpgrade as Win32SelfUpgrade
import qualified Distribution.Client.World as World
import qualified Distribution.InstalledPackageInfo as Installed
import Distribution.Client.Compat.ExecutablePath
import Distribution.Client.JobControl
import qualified Distribution.Solver.Types.ComponentDeps as CD
......@@ -139,7 +138,7 @@ import qualified Distribution.Simple.Setup as Cabal
, registerCommand, RegisterFlags(..), emptyRegisterFlags
, testCommand, TestFlags(..), emptyTestFlags )
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose, rawSystemExit, comparing
( createDirectoryIfMissingVerbose, comparing
, writeFileAtomic, withUTF8FileContents )
import Distribution.Simple.InstallDirs as InstallDirs
( PathTemplate, fromPathTemplate, toPathTemplate, substPathTemplate
......@@ -164,14 +163,14 @@ import Distribution.Simple.Utils as Utils
( notice, info, warn, debug, debugNoWrap, die
, intercalate, withTempDirectory )
import Distribution.Client.Utils
( determineNumJobs, inDir, logDirChange, mergeBy, MergeResult(..)
( determineNumJobs, logDirChange, mergeBy, MergeResult(..)
, tryCanonicalizePath )
import Distribution.System
( Platform, OS(Windows), buildOS )
import Distribution.Text
( display )
import Distribution.Verbosity as Verbosity
( Verbosity, showForCabal, normal, verbose )
( Verbosity, normal, verbose )
import Distribution.Simple.BuildPaths ( exeExtension )
--TODO:
......@@ -1050,7 +1049,6 @@ updateSandboxTimestampsFile _ _ _ _ _ = return ()
-- ------------------------------------------------------------
data InstallMisc = InstallMisc {
rootCmd :: Maybe FilePath,
libVersion :: Maybe Version
}
......@@ -1090,7 +1088,7 @@ performInstallations verbosity
installUnpackedPackage verbosity buildLimit installLock numJobs
(setupScriptOptions installedPkgIndex
cacheLock rpkg)
miscOptions configFlags'
configFlags'
installFlags haddockFlags
cinfo platform pkg rpkg pkgoverride mpath useLogFile
......@@ -1165,11 +1163,6 @@ performInstallations verbosity
(compilerInfo comp) platform
miscOptions = InstallMisc {
rootCmd = if fromFlag (configUserInstall configFlags)
|| (isUseSandbox useSandbox)
then Nothing -- ignore --root-cmd if --user
-- or working inside a sandbox.
else flagToMaybe (installRootCmd installFlags),
libVersion = flagToMaybe (configCabalVersion configExFlags)
}
......@@ -1389,7 +1382,6 @@ installUnpackedPackage
-> Lock
-> Int
-> SetupScriptOptions
-> InstallMisc
-> ConfigFlags
-> InstallFlags
-> HaddockFlags
......@@ -1402,7 +1394,7 @@ installUnpackedPackage
-> UseLogFile -- ^ File to log output to (if any)
-> IO BuildResult
installUnpackedPackage verbosity buildLimit installLock numJobs
scriptOptions miscOptions
scriptOptions
configFlags installFlags haddockFlags
cinfo platform pkg rpkg pkgoverride workingDir useLogFile = do
......@@ -1463,12 +1455,9 @@ installUnpackedPackage verbosity buildLimit installLock numJobs
-- Actual installation
withWin32SelfUpgrade verbosity ipid configFlags
cinfo platform pkg $ do
case rootCmd miscOptions of
(Just cmd) -> reexec cmd
Nothing -> do
setup Cabal.copyCommand copyFlags mLogPath
when shouldRegister $ do
setup Cabal.registerCommand registerFlags mLogPath
setup Cabal.copyCommand copyFlags mLogPath
when shouldRegister $ do
setup Cabal.registerCommand registerFlags mLogPath
-- Capture installed package configuration file, so that
-- it can be incorporated into the final InstallPlan
......@@ -1583,18 +1572,6 @@ installUnpackedPackage verbosity buildLimit installLock numJobs
(Just pkg)
cmd flags [])
reexec cmd = do
-- look for our own executable file and re-exec ourselves using a helper
-- program like sudo to elevate privileges:
self <- getExecutablePath
weExist <- doesFileExist self
if weExist
then inDir workingDir $
rawSystemExit verbosity cmd
[self, "install", "--only"
,"--verbose=" ++ showForCabal verbosity]
else die $ "Unable to find cabal executable at: " ++ self
-- helper
onFailure :: (SomeException -> BuildFailure) -> IO BuildResult -> IO BuildResult
......
......@@ -259,7 +259,6 @@ resolveBuildTimeSettings verbosity
buildSettingIgnoreExpiry = fromFlag projectConfigIgnoreExpiry
buildSettingReportPlanningFailure
= fromFlag projectConfigReportPlanningFailure
buildSettingRootCmd = flagToMaybe projectConfigRootCmd
ProjectConfigBuildOnly{..} = defaults
<> fromProjectFile
......
......@@ -402,7 +402,6 @@ convertLegacyBuildOnlyFlags globalFlags configFlags
installDryRun = projectConfigDryRun,
installOnly = _,
installOnlyDeps = projectConfigOnlyDeps,
installRootCmd = projectConfigRootCmd,
installSummaryFile = projectConfigSummaryFile,
installLogFile = projectConfigLogFile,
installBuildReports = projectConfigBuildReports,
......@@ -499,7 +498,6 @@ convertToLegacySharedConfig
installStrongFlags = projectConfigStrongFlags,
installOnly = mempty,
installOnlyDeps = projectConfigOnlyDeps,
installRootCmd = projectConfigRootCmd,
installSummaryFile = projectConfigSummaryFile,
installLogFile = projectConfigLogFile,
installBuildReports = projectConfigBuildReports,
......
......@@ -129,8 +129,7 @@ data ProjectConfigBuildOnly
projectConfigIgnoreExpiry :: Flag Bool,
projectConfigCacheDir :: Flag FilePath,
projectConfigLogsDir :: Flag FilePath,
projectConfigWorldFile :: Flag FilePath,
projectConfigRootCmd :: Flag String
projectConfigWorldFile :: Flag FilePath
}
deriving (Eq, Show, Generic)
......@@ -363,7 +362,6 @@ data BuildTimeSettings
buildSettingLocalRepos :: [FilePath],
buildSettingCacheDir :: FilePath,
buildSettingHttpTransport :: Maybe String,
buildSettingIgnoreExpiry :: Bool,
buildSettingRootCmd :: Maybe String
buildSettingIgnoreExpiry :: Bool
}
......@@ -1153,7 +1153,6 @@ data InstallFlags = InstallFlags {
installUpgradeDeps :: Flag Bool,
installOnly :: Flag Bool,
installOnlyDeps :: Flag Bool,
installRootCmd :: Flag String,
installSummaryFile :: NubList PathTemplate,
installLogFile :: Flag PathTemplate,
installBuildReports :: Flag ReportLevel,
......@@ -1184,7 +1183,6 @@ defaultInstallFlags = InstallFlags {
installUpgradeDeps = Flag False,
installOnly = Flag False,
installOnlyDeps = Flag False,
installRootCmd = mempty,
installSummaryFile = mempty,
installLogFile = mempty,
installBuildReports = Flag NoReports,
......@@ -1354,11 +1352,6 @@ installOptions showOrParseArgs =
installOnlyDeps (\v flags -> flags { installOnlyDeps = v })
(yesNoOpt showOrParseArgs)
, option [] ["root-cmd"]
"Command used to gain root privileges, when installing with --global."
installRootCmd (\v flags -> flags { installRootCmd = v })
(reqArg' "COMMAND" toFlag flagToList)
, option [] ["symlink-bindir"]
"Add symlinks to installed executables into this directory."
installSymlinkBinDir (\v flags -> flags { installSymlinkBinDir = v })
......
......@@ -305,19 +305,18 @@ instance Arbitrary ProjectConfigBuildOnly where
<*> (fmap getShortToken <$> arbitrary)
<*> (fmap getShortToken <$> arbitrary) -- 16
<*> (fmap getShortToken <$> arbitrary)
<*> (fmap getShortToken <$> arbitrary)
where
arbitraryNumJobs = fmap (fmap getPositive) <$> arbitrary
shrink (ProjectConfigBuildOnly
x00 x01 x02 x03 x04 x05 x06 x07
x08 x09 x10 x11 x12 x13 x14 x15
x16 x17) =
x16) =
[ ProjectConfigBuildOnly
x00' x01' x02' x03' x04'
x05' x06' x07' x08' (postShrink_NumJobs x09')
x10' x11' x12 x13' x14
x15 x16 x17
x15 x16
| ((x00', x01', x02', x03', x04'),
(x05', x06', x07', x08', x09'),
(x10', x11', x13'))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment