From 3faa7e763c9fbc93edca6aece732dfd2674fdc50 Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sun, 10 Jun 2018 06:46:10 +0300 Subject: Handle dependencies/explicits using "pacman -D" instead of two "pacman -S" calls --- src/feature/syncinstall.nim | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/feature/syncinstall.nim') diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 137d095..1fc2b6c 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -582,10 +582,24 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], handleTmpRoot(false) (newSeq[(string, string)](), 1) else: - let pacmanParams = pacmanCmd & pacmanParams(config.color, - commonArgs & ("U", none(string), ArgumentType.short)) - let asdeps = install.filter(p => not (p.name in explicits)).map(p => p.file) - let asexplicit = install.filter(p => p.name in explicits).map(p => p.file) + let installWithReason = withAlpmConfig(config, false, handle, dbs, errors): + let local = handle.local + install.map(proc (pkg: auto): tuple[name: string, file: string, mode: string] = + let explicit = pkg.name in explicits + let package = local[pkg.name] + let mode = if package != nil: (block: + let installedExplicitly = package.reason == AlpmReason.explicit + if explicit == installedExplicitly: + "auto" + elif explicit: + "explicit" + else: + "dependency") + elif explicit: + "auto" + else: + "dependency" + (pkg.name, pkg.file, mode)) let (cacheDir, cacheUser, cacheGroup) = if config.preserveBuilt == PreserveBuilt.internal: (config.cache, 0, 0) @@ -599,9 +613,17 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], # pass -1 values to disable caching ("", -1, -1) + let pacmanUpgradeParams = pacmanCmd & pacmanParams(config.color, + commonArgs & ("U", none(string), ArgumentType.short)) + + let pacmanDatabaseParams = pacmanCmd & pacmanParams(config.color, + commonArgs.keepOnlyOptions(commonOptions) & ("D", none(string), ArgumentType.short)) + let installParams = sudoPrefix & (pkgLibDir & "/install") & cacheDir & $cacheUser & $cacheGroup & - $pacmanParams.len & pacmanParams & $asdeps.len & asdeps & $asexplicit.len & asexplicit + $pacmanUpgradeParams.len & pacmanUpgradeParams & + $pacmanDatabaseParams.len & pacmanDatabaseParams & + lc[x | (i <- installWithReason, x <- [i.name, i.file, i.mode]), string] let code = forkWait(() => execResult(installParams)) if code != 0: -- cgit v1.2.3-70-g09d2