From 3d420e1b546c5636e38653cb21d5dc0f4306a30a Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sat, 2 Jun 2018 10:08:15 +0300 Subject: Allow to query virtual packages using "-Qdttt" --- src/feature/localquery.nim | 20 ++++++++++++++++---- src/feature/syncinstall.nim | 8 ++++---- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'src/feature') diff --git a/src/feature/localquery.nim b/src/feature/localquery.nim index f8436cd..4a21fa9 100644 --- a/src/feature/localquery.nim +++ b/src/feature/localquery.nim @@ -4,16 +4,28 @@ import "../wrapper/alpm" proc handleQueryOrphans*(args: seq[Argument], config: Config): int = - let (installed, orphans, _) = withAlpmConfig(config, false, handle, dbs, errors): + let (installed, orphans, _, alternatives) = withAlpmConfig(config, false, handle, dbs, errors): for e in errors: printError(config.color, e) queryUnrequired(handle, true, false, initSet[string]()) - let targets = args.targets.map(t => (if t[0 .. 5] == "local/": t[6 .. ^1] else: t)) + let targets = args.packageTargets(false) + + proc isOrphanOrNotFound(reference: PackageReference): bool = + for r in installed: + if reference.isProvidedBy(r, true): + return reference.name in orphans + for name, references in alternatives: + for r in references: + let hasConstraint = r.constraint.isSome and not r.constraint.unsafeGet.impliedVersion + if (not hasConstraint and reference.constraint.isNone and r.name == reference.name) or + (hasConstraint and reference.isProvidedBy(r, true)): + return name in orphans + return true # Provide similar output for not installed packages - let unknownTargets = targets.toSet - installed let results = if targets.len > 0: - targets.filter(t => t in orphans or t in unknownTargets) + targets.filter(t => (t.repo.isNone or t.repo == some("local")) and + t.reference.isOrphanOrNotFound).map(t => $t) else: toSeq(orphans.items).sorted(cmp) diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 6f23eee..4bb3837 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -860,7 +860,7 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int, nodep clearPaths(paths) confirmAndResolveCode else: - let (_, initialUnrequired, initialUnrequiredWithoutOptional) = + let (_, initialUnrequired, initialUnrequiredWithoutOptional, _) = withAlpmConfig(config, false, handle, dbs, errors): queryUnrequired(handle, true, true, keepNames) @@ -919,7 +919,7 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int, nodep clearPaths(paths) let newKeepNames = keepNames.map(n => installedAs.opt(n).get(n)) - let (_, finalUnrequired, finalUnrequiredWithoutOptional) = + let (_, finalUnrequired, finalUnrequiredWithoutOptional, _) = withAlpmConfig(config, false, handle, dbs, errors): queryUnrequired(handle, true, true, newKeepNames) @@ -1265,8 +1265,8 @@ proc resolveBuildTargets(config: Config, targets: seq[PackageTarget], printMode, needed, upgradeCount) for e in aperrors: printError(config.color, e) - let upToDateNeededTable = upToDateNeeded.map(i => (i.name, - (i.name, none(string), some((ConstraintOperation.eq, i.version))))).toTable + let upToDateNeededTable: Table[string, PackageReference] = upToDateNeeded.map(i => (i.name, + (i.name, none(string), some((ConstraintOperation.eq, i.version, false))))).toTable let notFoundTargets = filterNotFoundSyncTargets(syncTargets, aurPkgInfos, upToDateNeededTable) -- cgit v1.2.3-70-g09d2