diff options
author | kitsunyan | 2018-05-31 16:08:10 +0000 |
---|---|---|
committer | kitsunyan | 2018-05-31 16:08:10 +0000 |
commit | de157edb51e1131f8215cc22931c006b9adf3803 (patch) | |
tree | f0e0fe7d7a588859cd94489486c105c4f6759685 /src/main.nim | |
parent | 1fa779a2d7a88fe4e3e4bbc36605a7f30930ece6 (diff) |
Add support for "--sysroot" option
Diffstat (limited to 'src/main.nim')
-rw-r--r-- | src/main.nim | 13 |
1 files changed, 9 insertions, 4 deletions
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) |