From 7600f3cc8c69964dc0c4efe62096483c271803b7 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sat, 16 Apr 2016 21:01:23 -0700 Subject: [PATCH] Remove support for root-cmd, fixes #3353. Signed-off-by: Edward Z. Yang --- cabal-install/Distribution/Client/Config.hs | 1 - cabal-install/Distribution/Client/Install.hs | 39 ++++--------------- .../Distribution/Client/ProjectConfig.hs | 1 - .../Client/ProjectConfig/Legacy.hs | 2 - .../Client/ProjectConfig/Types.hs | 6 +-- cabal-install/Distribution/Client/Setup.hs | 7 ---- 6 files changed, 10 insertions(+), 46 deletions(-) diff --git a/cabal-install/Distribution/Client/Config.hs b/cabal-install/Distribution/Client/Config.hs index 1c66e8d622f..609d3de5106 100644 --- a/cabal-install/Distribution/Client/Config.hs +++ b/cabal-install/Distribution/Client/Config.hs @@ -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, diff --git a/cabal-install/Distribution/Client/Install.hs b/cabal-install/Distribution/Client/Install.hs index 1a1026b0327..3a55715a250 100644 --- a/cabal-install/Distribution/Client/Install.hs +++ b/cabal-install/Distribution/Client/Install.hs @@ -107,7 +107,6 @@ import qualified Distribution.Client.PackageIndex as SourcePackageIndex 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.Client.ComponentDeps as CD @@ -131,7 +130,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 @@ -158,14 +157,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: @@ -1044,7 +1043,6 @@ updateSandboxTimestampsFile _ _ _ _ _ = return () -- ------------------------------------------------------------ data InstallMisc = InstallMisc { - rootCmd :: Maybe FilePath, libVersion :: Maybe Version } @@ -1084,7 +1082,7 @@ performInstallations verbosity installUnpackedPackage verbosity buildLimit installLock numJobs (setupScriptOptions installedPkgIndex cacheLock rpkg) - miscOptions configFlags' + configFlags' installFlags haddockFlags cinfo platform pkg rpkg pkgoverride mpath useLogFile @@ -1159,11 +1157,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) } @@ -1383,7 +1376,6 @@ installUnpackedPackage -> Lock -> Int -> SetupScriptOptions - -> InstallMisc -> ConfigFlags -> InstallFlags -> HaddockFlags @@ -1396,7 +1388,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 @@ -1457,12 +1449,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 @@ -1577,18 +1566,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 diff --git a/cabal-install/Distribution/Client/ProjectConfig.hs b/cabal-install/Distribution/Client/ProjectConfig.hs index e00d76250b4..0a935f49640 100644 --- a/cabal-install/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/Distribution/Client/ProjectConfig.hs @@ -256,7 +256,6 @@ resolveBuildTimeSettings verbosity buildSettingIgnoreExpiry = fromFlag projectConfigIgnoreExpiry buildSettingReportPlanningFailure = fromFlag projectConfigReportPlanningFailure - buildSettingRootCmd = flagToMaybe projectConfigRootCmd ProjectConfigBuildOnly{..} = defaults <> fromProjectFile diff --git a/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs index 31b4f1888fe..659a7a74bf3 100644 --- a/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/Distribution/Client/ProjectConfig/Legacy.hs @@ -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, diff --git a/cabal-install/Distribution/Client/ProjectConfig/Types.hs b/cabal-install/Distribution/Client/ProjectConfig/Types.hs index 570bbb3af5d..53212bc87ea 100644 --- a/cabal-install/Distribution/Client/ProjectConfig/Types.hs +++ b/cabal-install/Distribution/Client/ProjectConfig/Types.hs @@ -126,8 +126,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) @@ -360,7 +359,6 @@ data BuildTimeSettings buildSettingLocalRepos :: [FilePath], buildSettingCacheDir :: FilePath, buildSettingHttpTransport :: Maybe String, - buildSettingIgnoreExpiry :: Bool, - buildSettingRootCmd :: Maybe String + buildSettingIgnoreExpiry :: Bool } diff --git a/cabal-install/Distribution/Client/Setup.hs b/cabal-install/Distribution/Client/Setup.hs index 95b08cf7131..19cb1ab7b37 100644 --- a/cabal-install/Distribution/Client/Setup.hs +++ b/cabal-install/Distribution/Client/Setup.hs @@ -1150,7 +1150,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, @@ -1181,7 +1180,6 @@ defaultInstallFlags = InstallFlags { installUpgradeDeps = Flag False, installOnly = Flag False, installOnlyDeps = Flag False, - installRootCmd = mempty, installSummaryFile = mempty, installLogFile = mempty, installBuildReports = Flag NoReports, @@ -1350,11 +1348,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 })