aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config.nim5
-rw-r--r--src/feature/localquery.nim3
-rw-r--r--src/feature/syncinfo.nim3
-rw-r--r--src/feature/syncinstall.nim20
-rw-r--r--src/feature/syncsearch.nim2
-rw-r--r--src/feature/syncsource.nim3
6 files changed, 17 insertions, 19 deletions
diff --git a/src/config.nim b/src/config.nim
index f0c8710..2aa9974 100644
--- a/src/config.nim
+++ b/src/config.nim
@@ -164,3 +164,8 @@ proc obtainConfig*(config: PacmanConfig): Config =
aurComments: aurComments, checkIgnored: checkIgnored, printAurNotFound: printAurNotFound,
sudoExec: sudoExec, viewNoDefault: viewNoDefault, preserveBuilt: preserveBuilt,
preBuildCommand: preBuildCommand)
+
+template withAlpmConfig*(config: Config, passDbs: bool,
+ handle: untyped, alpmDbs: untyped, errors: untyped, body: untyped): untyped =
+ withAlpm(config.root, config.db, if passDbs: config.dbs else: @[], config.arch,
+ handle, alpmDbs, errors, body)
diff --git a/src/feature/localquery.nim b/src/feature/localquery.nim
index ccc1311..f8436cd 100644
--- a/src/feature/localquery.nim
+++ b/src/feature/localquery.nim
@@ -4,8 +4,7 @@ import
"../wrapper/alpm"
proc handleQueryOrphans*(args: seq[Argument], config: Config): int =
- let (installed, orphans, _) = withAlpm(config.root, config.db, newSeq[string](),
- config.arch, handle, dbs, errors):
+ let (installed, orphans, _) = withAlpmConfig(config, false, handle, dbs, errors):
for e in errors: printError(config.color, e)
queryUnrequired(handle, true, false, initSet[string]())
diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim
index b0765f4..fc1510b 100644
--- a/src/feature/syncinfo.nim
+++ b/src/feature/syncinfo.nim
@@ -103,8 +103,7 @@ proc handleSyncInfo*(args: seq[Argument], config: Config): int =
let (_, callArgs) = checkAndRefresh(config.color, args)
let targets = args.packageTargets(false)
- let (syncTargets, checkAurNames) = withAlpm(config.root, config.db,
- config.dbs, config.arch, handle, dbs, errors):
+ let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors):
for e in errors: printError(config.color, e)
findSyncTargets(handle, dbs, targets, false, false)
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index 269777a..6f23eee 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -653,8 +653,7 @@ proc resolveDependencies(config: Config, pkgInfos: seq[PackageInfo],
if directSome:
printColon(config.color, tr"Resolving build targets...")
echo(trp("resolving dependencies...\n"))
- let (satisfied, unsatisfied, paths) = withAlpm(config.root, config.db,
- config.dbs, config.arch, handle, dbs, errors):
+ let (satisfied, unsatisfied, paths) = withAlpmConfig(config, true, handle, dbs, errors):
findDependencies(config, handle, dbs, pkgInfos, additionalPkgInfos,
nodepsCount, assumeInstalled, printMode, noaur)
@@ -834,8 +833,7 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int, nodep
let assumeInstalled = args.assumeInstalled
let skipDeps = assumeInstalled.len > 0 or nodepsCount > 0
- let removedNames = withAlpm(config.root, config.db,
- config.dbs, config.arch, handle, dbs, errors):
+ let removedNames = withAlpmConfig(config, true, handle, dbs, errors):
for e in errors: printError(config.color, e)
let newInstalledNames = lc[$p.name | (p <- handle.local.packages), string].toSet
installed.map(i => i.name).filter(n => not (n in newInstalledNames)).toSet
@@ -862,8 +860,8 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int, nodep
clearPaths(paths)
confirmAndResolveCode
else:
- let (_, initialUnrequired, initialUnrequiredWithoutOptional) = withAlpm(config.root,
- config.db, newSeq[string](), config.arch, handle, dbs, errors):
+ let (_, initialUnrequired, initialUnrequiredWithoutOptional) =
+ withAlpmConfig(config, false, handle, dbs, errors):
queryUnrequired(handle, true, true, keepNames)
let (additionalCode, additionalSome) = if additionalPacmanTargets.len > 0: (block:
@@ -884,8 +882,7 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int, nodep
if basePackages.len > 0:
# check all pacman dependencies were installed
let unsatisfied = if nodepsCount <= 1:
- withAlpm(config.root, config.db,
- config.dbs, config.arch, handle, dbs, errors):
+ withAlpmConfig(config, true, handle, dbs, errors):
for e in errors: printError(config.color, e)
proc checkSatisfied(reference: PackageReference): bool =
@@ -922,8 +919,8 @@ 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) = withAlpm(config.root,
- config.db, newSeq[string](), config.arch, handle, dbs, errors):
+ let (_, finalUnrequired, finalUnrequiredWithoutOptional) =
+ withAlpmConfig(config, false, handle, dbs, errors):
queryUnrequired(handle, true, true, newKeepNames)
let unrequired = finalUnrequired - initialUnrequired
@@ -1194,8 +1191,7 @@ proc obtainPacmanBuildTargets(config: Config, pacmanTargets: seq[FullPackageTarg
proc findSyncTargetsWithInstalled(config: Config, targets: seq[PackageTarget], upgradeCount: int,
noaur: bool, build: bool): (seq[SyncPackageTarget], seq[string], seq[Installed]) =
- withAlpm(config.root, config.db,
- config.dbs, config.arch, handle, dbs, errors):
+ withAlpmConfig(config, true, handle, dbs, errors):
for e in errors: printError(config.color, e)
let (syncTargets, checkAurNames) = findSyncTargets(handle, dbs, targets,
diff --git a/src/feature/syncsearch.nim b/src/feature/syncsearch.nim
index 178a839..4d0eb50 100644
--- a/src/feature/syncsearch.nim
+++ b/src/feature/syncsearch.nim
@@ -18,7 +18,7 @@ proc handleSyncSearch*(args: seq[Argument], config: Config): int =
if quiet:
aurPackages.map(pkg => (pkg, none(string)))
elif aurPackages.len > 0:
- withAlpm(config.root, config.db, newSeq[string](), config.arch, handle, dbs, errors):
+ withAlpmConfig(config, false, handle, dbs, errors):
for e in errors: printError(config.color, e)
aurPackages.map(proc (rpcInfo: RpcPackageInfo): Package =
diff --git a/src/feature/syncsource.nim b/src/feature/syncsource.nim
index 2bc88ee..8096f02 100644
--- a/src/feature/syncsource.nim
+++ b/src/feature/syncsource.nim
@@ -162,8 +162,7 @@ proc handleSyncSource*(args: seq[Argument], config: Config): int =
printError(config.color, trp("no targets specified (use -h for help)\n"))
1
else:
- let (syncTargets, checkAurNames) = withAlpm(config.root, config.db,
- config.dbs, config.arch, handle, dbs, errors):
+ let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors):
for e in errors: printError(config.color, e)
findSyncTargets(handle, dbs, targets, false, false)