diff options
author | kitsunyan | 2018-06-10 03:46:10 +0000 |
---|---|---|
committer | kitsunyan | 2018-06-10 03:46:10 +0000 |
commit | 3faa7e763c9fbc93edca6aece732dfd2674fdc50 (patch) | |
tree | 00145bcb0c52ff904f8a3bd414b6c73b2742a07c /src | |
parent | 4e6a207ce3d764f73ce3294723c263e38d9b68d3 (diff) |
Handle dependencies/explicits using "pacman -D" instead of two "pacman -S" calls
Diffstat (limited to 'src')
-rw-r--r-- | src/feature/syncinstall.nim | 32 |
1 files changed, 27 insertions, 5 deletions
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: |