From ed77fe64584d901e037be2978a40a0ebc2a8b5e3 Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sat, 24 Mar 2018 06:22:59 +0300 Subject: Install explicit and dependent packages separately --- src/feature/syncinstall.nim | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'src/feature') diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 4727f25..1506216 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -441,11 +441,13 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], let files = lc[(p.key, formatArchiveFile(p.value, br.ext)) | (br <- buildResults, p <- br.pkgInfos.namedPairs), (string, string)].toTable - let install = lc[x | (g <- basePackages, i <- g, x <- files.opt(i.name)), string] + let install = lc[(i.name, x) | (g <- basePackages, i <- g, x <- files.opt(i.name)), + tuple[name: string, file: string]] proc handleTmpRoot(clear: bool) = + let files = install.map(p => p.file) for _, file in files: - if clear or not (file in install): + if clear or not (file in files): try: removeFile(file) except: @@ -466,19 +468,29 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], handleTmpRoot(false) 1 else: - let explicit = basePackages.filter(p => p.filter(i => i.name in explicits).len > 0).len > 0 - let asdepsSeq = if not explicit: @[("asdeps", none(string), ArgumentType.long)] else: @[] - - let installCode = pacmanRun(true, config.color, commonArgs & - ("U", none(string), ArgumentType.short) & asdepsSeq & - install.map(i => (i, none(string), ArgumentType.target))) + 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) + + proc doInstall(files: seq[string], addArgs: seq[Argument]): int = + if files.len > 0: + pacmanRun(true, config.color, commonArgs & + ("U", none(string), ArgumentType.short) & addArgs & + files.map(f => (f, none(string), ArgumentType.target))) + else: + 0 - if installCode != 0: + let asdepsCode = doInstall(asdeps, @[("asdeps", none(string), ArgumentType.long)]) + if asdepsCode != 0: handleTmpRoot(false) - installCode + asdepsCode else: - handleTmpRoot(true) - 0 + let asexplicitCode = doInstall(asexplicit, @[]) + if asexplicitCode != 0: + handleTmpRoot(false) + asexplicitCode + else: + handleTmpRoot(true) + 0 proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int, noconfirm: bool, explicits: HashSet[string], installed: seq[Installed], -- cgit v1.2.3-70-g09d2