Skip to content

Commit

Permalink
Remove support for root-cmd, fixes haskell#3353.
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Z. Yang <[email protected]>
  • Loading branch information
ezyang committed Apr 17, 2016
1 parent fad9f12 commit 7600f3c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 46 deletions.
1 change: 0 additions & 1 deletion cabal-install/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
39 changes: 8 additions & 31 deletions cabal-install/Distribution/Client/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -1044,7 +1043,6 @@ updateSandboxTimestampsFile _ _ _ _ _ = return ()
-- ------------------------------------------------------------

data InstallMisc = InstallMisc {
rootCmd :: Maybe FilePath,
libVersion :: Maybe Version
}

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -1383,7 +1376,6 @@ installUnpackedPackage
-> Lock
-> Int
-> SetupScriptOptions
-> InstallMisc
-> ConfigFlags
-> InstallFlags
-> HaddockFlags
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cabal-install/Distribution/Client/ProjectConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ resolveBuildTimeSettings verbosity
buildSettingIgnoreExpiry = fromFlag projectConfigIgnoreExpiry
buildSettingReportPlanningFailure
= fromFlag projectConfigReportPlanningFailure
buildSettingRootCmd = flagToMaybe projectConfigRootCmd

ProjectConfigBuildOnly{..} = defaults
<> fromProjectFile
Expand Down
2 changes: 0 additions & 2 deletions cabal-install/Distribution/Client/ProjectConfig/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ convertLegacyBuildOnlyFlags globalFlags configFlags
installDryRun = projectConfigDryRun,
installOnly = _,
installOnlyDeps = projectConfigOnlyDeps,
installRootCmd = projectConfigRootCmd,
installSummaryFile = projectConfigSummaryFile,
installLogFile = projectConfigLogFile,
installBuildReports = projectConfigBuildReports,
Expand Down Expand Up @@ -499,7 +498,6 @@ convertToLegacySharedConfig
installStrongFlags = projectConfigStrongFlags,
installOnly = mempty,
installOnlyDeps = projectConfigOnlyDeps,
installRootCmd = projectConfigRootCmd,
installSummaryFile = projectConfigSummaryFile,
installLogFile = projectConfigLogFile,
installBuildReports = projectConfigBuildReports,
Expand Down
6 changes: 2 additions & 4 deletions cabal-install/Distribution/Client/ProjectConfig/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -360,7 +359,6 @@ data BuildTimeSettings
buildSettingLocalRepos :: [FilePath],
buildSettingCacheDir :: FilePath,
buildSettingHttpTransport :: Maybe String,
buildSettingIgnoreExpiry :: Bool,
buildSettingRootCmd :: Maybe String
buildSettingIgnoreExpiry :: Bool
}

7 changes: 0 additions & 7 deletions cabal-install/Distribution/Client/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1181,7 +1180,6 @@ defaultInstallFlags = InstallFlags {
installUpgradeDeps = Flag False,
installOnly = Flag False,
installOnlyDeps = Flag False,
installRootCmd = mempty,
installSummaryFile = mempty,
installLogFile = mempty,
installBuildReports = Flag NoReports,
Expand Down Expand Up @@ -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 })
Expand Down

0 comments on commit 7600f3c

Please sign in to comment.