From de157edb51e1131f8215cc22931c006b9adf3803 Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Thu, 31 May 2018 19:08:10 +0300 Subject: Add support for "--sysroot" option --- src/main.nim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/main.nim') diff --git a/src/main.nim b/src/main.nim index 7171716..54fbb08 100644 --- a/src/main.nim +++ b/src/main.nim @@ -9,6 +9,10 @@ import "feature/syncsource", "feature/localquery" +proc execSudo*(args: seq[Argument]): int = + execResult(sudoPrefix & getAppFilename() & + lc[x | (y <- args, x <- y.collectArg), string]) + proc passValidation(args: seq[Argument], config: Config, nonRootArgs: openArray[OptionPair], rootArgs: openArray[OptionPair], opts: varargs[seq[CommandOption]]): int = @@ -90,11 +94,9 @@ proc handleSync(args: seq[Argument], config: Config): int = let printMode = args.check(%%%"print") or args.check(%%%"print-format") if currentUser.uid != 0 and config.sudoExec and not printMode: - let collectedArgs = sudoPrefix & getAppFilename() & - lc[x | (y <- args, x <- y.collectArg), string] - execResult(collectedArgs) + execSudo(args) else: - let isNonDefaultRoot = not config.isRootDefault + let isNonDefaultRoot = not config.defaultRoot let isRootNoDrop = currentUser.uid == 0 and not canDropPrivileges() let build = args.check(%%%"build") @@ -225,6 +227,9 @@ let init = withErrorHandler(none(bool), parsedArgs.check((some("V"), "version")): let code = handleVersion() raise haltError(code) + elif parsedArgs.check(%%%"sysroot") and currentUser.uid != 0: + let code = execSudo(parsedArgs) + raise haltError(code) else: let pacmanConfig = obtainPacmanConfig(parsedArgs) let config = obtainConfig(pacmanConfig) -- cgit v1.2.3-70-g09d2