aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common.nim4
-rw-r--r--src/feature/localquery.nim2
-rw-r--r--src/feature/syncinstall.nim42
3 files changed, 31 insertions, 17 deletions
diff --git a/src/common.nim b/src/common.nim
index c2f7053..d1c4daa 100644
--- a/src/common.nim
+++ b/src/common.nim
@@ -144,7 +144,7 @@ proc mapAurTargets*[T: RpcPackageInfo](targets: seq[SyncPackageTarget],
foundInfo: target.foundInfo, pkgInfo: none(T)))
proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptional: bool,
- assumeExplicit: seq[string]): (HashSet[string], HashSet[string], HashSet[string]) =
+ assumeExplicit: HashSet[string]): (HashSet[string], HashSet[string], HashSet[string]) =
let (explicit, dependsTable, alternatives) = block:
var explicit = newSeq[string]()
var dependsTable = initTable[string,
@@ -173,7 +173,7 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona
if provides.len > 0:
alternatives.add($pkg.name, provides)
- (explicit.toSet + assumeExplicit.toSet, dependsTable, alternatives)
+ (explicit.toSet + assumeExplicit, dependsTable, alternatives)
let providedBy = lc[(y, x.key) | (x <- alternatives.namedPairs, y <- x.value),
tuple[reference: PackageReference, name: string]]
diff --git a/src/feature/localquery.nim b/src/feature/localquery.nim
index d2beaa5..f4142ee 100644
--- a/src/feature/localquery.nim
+++ b/src/feature/localquery.nim
@@ -7,7 +7,7 @@ proc handleQueryOrphans*(args: seq[Argument], config: Config): int =
let (installed, orphans, _) = withAlpm(config.root, config.db, newSeq[string](),
config.arch, handle, dbs, errors):
for e in errors: printError(config.color, e)
- queryUnrequired(handle, true, false, @[])
+ queryUnrequired(handle, true, false, initSet[string]())
let targets = args.targets.map(t => (if t[0 .. 5] == "local/": t[6 .. ^1] else: t))
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index 04e9c0d..03d1342 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -8,7 +8,8 @@ type
Installed = tuple[
name: string,
version: string,
- groups: seq[string]
+ groups: seq[string],
+ explicit: bool
]
SatisfyResult = tuple[
@@ -518,8 +519,7 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument],
(newSeq[(string, string)](), 1)
else:
let asdeps = install.filter(p => not (p.name in explicits)).map(p => p.file)
- let explicitPkgs = install.filter(p => p.name in explicits)
- let asexplicit = explicitPkgs.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:
@@ -529,12 +529,14 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument],
else:
0
- let asdepsCode = doInstall(asdeps, @[("asdeps", none(string), ArgumentType.long)])
+ let asdepsCode = doInstall(asdeps,
+ @[("asdeps", none(string), ArgumentType.long)])
if asdepsCode != 0:
handleTmpRoot(false)
(newSeq[(string, string)](), asdepsCode)
else:
- let asexplicitCode = doInstall(asexplicit, @[])
+ let asexplicitCode = doInstall(asexplicit,
+ @[("asexplicit", none(string), ArgumentType.long)])
if asexplicitCode != 0:
handleTmpRoot(false)
(newSeq[(string, string)](), asexplicitCode)
@@ -547,7 +549,7 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument],
proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int,
noconfirm: bool, explicits: HashSet[string], installed: seq[Installed],
satisfied: Table[PackageReference, SatisfyResult], unsatisfied: seq[PackageReference],
- targetNames: seq[string], build: bool, directPacmanTargets: seq[string],
+ keepNames: HashSet[string], build: bool, directPacmanTargets: seq[string],
additionalPacmanTargets: seq[string], basePackages: seq[seq[seq[PackageInfo]]]): int =
let workDirectPacmanTargets = if build: @[] else: directPacmanTargets
@@ -712,7 +714,7 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int,
else:
let (_, initialUnrequired, initialUnrequiredWithoutOptional) = withAlpm(config.root,
config.db, newSeq[string](), config.arch, handle, dbs, errors):
- queryUnrequired(handle, true, true, targetNames)
+ queryUnrequired(handle, true, true, keepNames)
let (additionalCode, additionalSome) = if additionalPacmanTargets.len > 0: (block:
printColon(config.color, tr"Installing build dependencies...")
@@ -766,10 +768,10 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int,
printWarning(config.color, tr"installation aborted")
removeTmp()
- let newTargetNames = targetNames.map(n => installedAs.opt(n).get(n))
+ let newKeepNames = keepNames.map(n => installedAs.opt(n).get(n))
let (_, finalUnrequired, finalUnrequiredWithoutOptional) = withAlpm(config.root,
config.db, newSeq[string](), config.arch, handle, dbs, errors):
- queryUnrequired(handle, true, true, newTargetNames)
+ queryUnrequired(handle, true, true, newKeepNames)
let unrequired = finalUnrequired - initialUnrequired
let unrequiredOptional = finalUnrequiredWithoutOptional -
@@ -977,7 +979,7 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
let (syncTargets, checkAur) = findSyncTargets(handle, dbs, targets,
not build, not build)
- let installed = lc[($p.name, $p.version, p.groupsSeq) |
+ let installed = lc[($p.name, $p.version, p.groupsSeq, p.reason == AlpmReason.explicit) |
(p <- handle.local.packages), Installed]
let foreignUpgrade = if upgradeCount > 0: (block:
@@ -1140,10 +1142,22 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
satisfied, unsatisfied, directPacmanTargets, additionalPacmanTargets,
orderedPkgInfos)
else:
- let targetNames = targets.map(t => t.name)
- let explicits = if not args.check((none(string), "asdeps")): targetNames else: @[]
+ let foreignInstalled = installed.filter(i => i.name in foreignUpgrade)
+ let foreignExplicitsNamesSet = foreignInstalled
+ .filter(i => i.explicit).map(i => i.name).toSet
+ let foreignDepsNamesSet = foreignInstalled
+ .filter(i => not i.explicit).map(i => i.name).toSet
+ let targetNamesSet = targets.map(t => t.name).toSet
+ let keepNames = foreignExplicitsNamesSet + foreignDepsNamesSet + targetNamesSet
+
+ let explicits = if args.check((none(string), "asexplicit")):
+ targetNamesSet + foreignExplicitsNamesSet + foreignDepsNamesSet
+ elif args.check((none(string), "asdeps")):
+ initSet[string]()
+ else:
+ foreignExplicitsNamesSet + (targetNamesSet - foreignDepsNamesSet)
handleInstall(pacmanArgs, config, upgradeCount, noconfirm,
- explicits.toSet, installed, satisfied, unsatisfied,
- targetNames, build, directPacmanTargets, additionalPacmanTargets,
+ explicits, installed, satisfied, unsatisfied,
+ keepNames, build, directPacmanTargets, additionalPacmanTargets,
orderedPkgInfos)