aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitsunyan2018-03-25 00:55:18 +0000
committerkitsunyan2018-03-25 00:55:18 +0000
commit08d323988fb8b85e9864bc765176a6c425b4f7e5 (patch)
tree575843db452c01f0cc749e8fc7e5adb3050bb373
parent4f21aa7d4d1923358df8244622f1a4b6209e0459 (diff)
Don't check AUR for replaceable packages
-rw-r--r--src/feature/syncinstall.nim39
-rw-r--r--src/wrapper/alpm.nim3
2 files changed, 31 insertions, 11 deletions
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index 1506216..b393332 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -8,8 +8,7 @@ type
Installed = tuple[
name: string,
version: string,
- groups: seq[string],
- foreign: bool
+ groups: seq[string]
]
SatisfyResult = tuple[
@@ -844,33 +843,51 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
let targets = args.packageTargets
- let (syncTargets, checkAur, installed) = withAlpm(config.root, config.db,
+ let (syncTargets, checkAur, installed, foreignUpgrade) = withAlpm(config.root, config.db,
config.dbs, config.arch, handle, dbs, errors):
for e in errors: printError(config.color, e)
let (syncTargets, checkAur) = findSyncTargets(handle, dbs, targets,
not build, not build)
- let installed = lc[($p.name, $p.version, p.groupsSeq,
- dbs.filter(d => d[p.name] != nil).len == 0) |
+ let installed = lc[($p.name, $p.version, p.groupsSeq) |
(p <- handle.local.packages), Installed]
- (syncTargets, checkAur, installed)
+ let foreignUpgrade = if upgradeCount > 0: (block:
+ proc checkForeignAndIrreplaceable(name: string): bool =
+ if dbs.filter(d => d[name] != nil).len > 0:
+ return false
+ else:
+ for db in dbs:
+ for pkg in db.packages:
+ for replaces in pkg.replaces:
+ if replaces.name == name:
+ return false
+ return true
+
+ installed
+ .map(i => i.name)
+ .filter(checkForeignAndIrreplaceable)
+ .toSet)
+ else:
+ initSet[string]()
+
+ (syncTargets, checkAur, installed, foreignUpgrade)
- let realCheckAur = if noaur:
+ let checkAurFull = if noaur:
@[]
elif upgradeCount > 0:
installed
- .filter(i => i.foreign and
+ .filter(i => i.name in foreignUpgrade and
(config.checkIgnored or not config.ignored(i.name, i.groups)))
.map(i => i.name) & checkAur
else:
checkAur
withAur():
- if realCheckAur.len > 0 and printFormat.isNone:
+ if checkAurFull.len > 0 and printFormat.isNone:
printColon(config.color, tr"Checking AUR database...")
- let (rpcInfos, rerrors) = getRpcPackageInfo(realCheckAur)
+ let (rpcInfos, rerrors) = getRpcPackageInfo(checkAurFull)
for e in rerrors: printError(config.color, e)
let (rpcInfoTable, rpcNotFoundTargets) = filterNotFoundSyncTargets(syncTargets, rpcInfos)
@@ -881,7 +898,7 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
else:
if upgradeCount > 0 and not noaur and printFormat.isNone and config.printAurNotFound:
for inst in installed:
- if inst.foreign and not config.ignored(inst.name, inst.groups) and
+ if inst.name in foreignUpgrade and not config.ignored(inst.name, inst.groups) and
not rpcInfoTable.hasKey(inst.name):
printWarning(config.color, tr"$# was not found in AUR" % [inst.name])
diff --git a/src/wrapper/alpm.nim b/src/wrapper/alpm.nim
index 00b5b86..daa364b 100644
--- a/src/wrapper/alpm.nim
+++ b/src/wrapper/alpm.nim
@@ -100,6 +100,9 @@ proc optional*(pkg: ptr AlpmPackage): ptr AlpmList[ptr AlpmDependency]
proc provides*(pkg: ptr AlpmPackage): ptr AlpmList[ptr AlpmDependency]
{.cdecl, importc: "alpm_pkg_get_provides".}
+proc replaces*(pkg: ptr AlpmPackage): ptr AlpmList[ptr AlpmDependency]
+ {.cdecl, importc: "alpm_pkg_get_replaces".}
+
proc cfree*(data: pointer)
{.cdecl, importc: "free", header: "<stdlib.h>".}