aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/feature/syncinstall.nim46
-rw-r--r--src/main.nim9
2 files changed, 32 insertions, 23 deletions
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index 0a1b677..41b54cd 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -885,11 +885,12 @@ proc filterIgnoresAndConflicts(config: Config, pkgInfos: seq[PackageInfo],
(nonConflicingPkgInfos, acceptedPkgInfos)
proc checkNeeded(installed: Table[string, Installed],
- name: string, version: string): tuple[needed: bool, vercmp: int] =
+ name: string, version: string, downgrade: bool): tuple[needed: bool, vercmp: int] =
if installed.hasKey(name):
let i = installed[name]
let vercmp = vercmp(version, i.version)
- (vercmp > 0, vercmp.int)
+ let needed = if downgrade: vercmp != 0 else: vercmp > 0
+ (needed, vercmp.int)
else:
(true, 0)
@@ -898,7 +899,8 @@ proc obtainAurPackageInfos(config: Config, rpcInfos: seq[RpcPackageInfo],
installed: Table[string, Installed], print: bool, needed: bool,
upgradeCount: int): (seq[PackageInfo], seq[Installed], seq[LocalIsNewer], seq[string]) =
let targetRpcInfoPairs: seq[tuple[rpcInfo: RpcPackageInfo, upgradeable: bool]] =
- targets.map(t => t.pkgInfo.get).map(i => (i, installed.checkNeeded(i.name, i.version).needed))
+ targets.map(t => t.pkgInfo.get).map(i => (i, installed
+ .checkNeeded(i.name, i.version, true).needed))
let upToDateNeeded: seq[Installed] = if needed:
targetRpcInfoPairs.map(pair => (block:
@@ -918,16 +920,16 @@ proc obtainAurPackageInfos(config: Config, rpcInfos: seq[RpcPackageInfo],
let upgradeStructs: seq[tuple[rpcInfo: RpcPackageInfo, needed: bool,
localIsNewer: Option[LocalIsNewer]]] = installedUpgradeRpcInfos
.map(i => (block:
- let res = installed.checkNeeded(i.name, i.version)
+ let res = installed.checkNeeded(i.name, i.version, upgradeCount >= 2)
let gitPackage = i.name.len > 4 and i.name[i.name.len - 4 .. i.name.len - 1] == "-git"
- let localIsNewer = if gitPackage:
- # Don't warn about newer local git packages
- none(LocalIsNewer)
+ let (newNeeded, localIsNewer) = if gitPackage:
+ # Don't warn about newer local git packages and don't downgrade them
+ (installed.checkNeeded(i.name, i.version, false).needed, none(LocalIsNewer))
elif not res.needed and res.vercmp < 0:
- some((i.name, installed[i.name].version, i.version))
+ (res.needed, some((i.name, installed[i.name].version, i.version)))
else:
- none(LocalIsNewer)
- (i, res.needed, localIsNewer)))
+ (res.needed, none(LocalIsNewer))
+ (i, newNeeded, localIsNewer)))
let targetRpcInfos = targetRpcInfoPairs
.filter(i => not needed or i.upgradeable).map(i => i.rpcInfo)
@@ -1061,7 +1063,7 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
let neededPacmanTargets = if printFormat.isNone and build and needed:
pacmanTargets.filter(target => (block:
let version = target.foundInfo.get.pkg.get.version
- if installedTable.checkNeeded(target.name, version).needed:
+ if installedTable.checkNeeded(target.name, version, true).needed:
true
else:
printWarning(config.color, tra("%s-%s is up to date -- skipping\n") %
@@ -1102,12 +1104,26 @@ proc handleSyncInstall*(args: seq[Argument], config: Config): int =
if not (pkgInfo.name in acceptedSet):
if not (pkgInfo.name in targetsSet) and upgradeCount > 0 and
installedTable.hasKey(pkgInfo.name):
- printWarning(config.color, tra("%s: ignoring package upgrade (%s => %s)\n") %
- [pkgInfo.name, installedTable[pkgInfo.name].version, pkgInfo.version])
+ let installedVersion = installedTable[pkgInfo.name].version
+ let newVersion = pkgInfo.version
+ if vercmp(newVersion, installedVersion) < 0:
+ printWarning(config.color, tra("%s: ignoring package downgrade (%s => %s)\n") %
+ [pkgInfo.name, installedVersion, newVersion])
+ else:
+ printWarning(config.color, tra("%s: ignoring package upgrade (%s => %s)\n") %
+ [pkgInfo.name, installedVersion, newVersion])
else:
printWarning(config.color, trp("skipping target: %s\n") % [pkgInfo.name])
- elif pkgInfo.repo == "aur" and pkgInfo.maintainer.isNone:
- printWarning(config.color, tr"$# is orphaned" % [pkgInfo.name])
+ elif pkgInfo.repo == "aur":
+ if pkgInfo.maintainer.isNone:
+ printWarning(config.color, tr"$# is orphaned" % [pkgInfo.name])
+ if installedTable.hasKey(pkgInfo.name):
+ let installedVersion = installedTable[pkgInfo.name].version
+ let newVersion = pkgInfo.version
+ if vercmp(newVersion, installedVersion) < 0:
+ printWarning(config.color,
+ tra("%s: downgrading from version %s to version %s\n") %
+ [pkgInfo.name, installedVersion, newVersion])
let buildAndAurTargetSet = finalPkgInfos.map(i => i.name).toSet
let fullPkgInfos = finalPkgInfos & lc[i | (s <- satisfied.values,
diff --git a/src/main.nim b/src/main.nim
index be45329..58cb47e 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -90,22 +90,18 @@ proc handleSync(args: seq[Argument], config: Config): int =
execResult(collectedArgs)
else:
let isNonDefaultRoot = not config.isRootDefault
- let isDowngrade = args.count((some("u"), "sysupgrade")) >= 2
let isSkipDeps = args.check((some("d"), "nodeps"))
let isRootNoDrop = currentUser.uid == 0 and not canDropPrivileges()
let build = args.check((none(string), "build"))
let noaur = args.check((none(string), "noaur"))
- let noBuild = isNonDefaultRoot or isDowngrade or isSkipDeps or isRootNoDrop
+ let noBuild = isNonDefaultRoot or isSkipDeps or isRootNoDrop
if build and noBuild:
if isNonDefaultRoot:
printError(config.color, tr"non-default root path is specified" & " -- " &
tr"building is not allowed")
- elif isDowngrade:
- printError(config.color, tr"downgrades are enabled" & " -- " &
- tr"building is not allowed")
elif isSkipDeps:
printError(config.color, tr"dependency check is skipped" & " -- " &
tr"building is not allowed")
@@ -120,9 +116,6 @@ proc handleSync(args: seq[Argument], config: Config): int =
if isNonDefaultRoot:
printWarning(config.color, tr"non-default root path is specified" & " -- " &
tr"'$#' is assumed" % ["--noaur"])
- elif isDowngrade:
- printWarning(config.color, tr"downgrades are enabled" & " -- " &
- tr"'$#' is assumed" % ["--noaur"])
elif isSkipDeps:
printWarning(config.color, tr"dependency check is skipped" & " -- " &
tr"'$#' is assumed" % ["--noaur"])