aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common.nim9
-rw-r--r--src/feature/syncinstall.nim60
-rw-r--r--src/package.nim4
-rw-r--r--src/utils.nim1
4 files changed, 65 insertions, 9 deletions
diff --git a/src/common.nim b/src/common.nim
index 23ef7f3..779dacb 100644
--- a/src/common.nim
+++ b/src/common.nim
@@ -237,6 +237,15 @@ proc obtainSrcInfo*(path: string): string =
execProcess(bashCmd, ["-c", """cd "$2" && "$1" --printsrcinfo""",
"bash", makePkgCmd, path], options = {})
+proc reloadPkgInfos*(config: Config, path: string, pkgInfos: seq[PackageInfo]): seq[PackageInfo] =
+ let srcInfo = obtainSrcInfo(path)
+ let res = parseSrcInfo(pkgInfos[0].repo, srcInfo, config.arch,
+ pkgInfos[0].gitUrl, pkgInfos[0].gitBranch, pkgInfos[0].gitCommit, pkgInfos[0].gitPath)
+ if res.len > 0:
+ res
+ else:
+ pkgInfos
+
proc obtainBuildPkgInfos*(config: Config,
pacmanTargets: seq[FullPackageTarget[RpcPackageInfo]]): (seq[PackageInfo], seq[string]) =
type
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index 23c8a37..e0dd2a2 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -346,9 +346,7 @@ proc buildLoop(config: Config, pkgInfos: seq[PackageInfo], noconfirm: bool,
printError(config.color, tr"failed to build '$#'" % [base])
(none(BuildResult), buildCode)
else:
- let srcInfo = obtainSrcInfo(buildPath)
- let resultPkgInfos = parseSrcInfo(pkgInfos[0].repo, srcInfo, config.arch,
- pkgInfos[0].gitUrl, pkgInfos[0].gitBranch, pkgInfos[0].gitCommit, some(buildPath))
+ let resultPkgInfos = reloadPkgInfos(config, buildPath, pkgInfos)
type ResultInfo = tuple[name: string, baseIndex: int, pkgInfo: Option[PackageInfo]]
@@ -541,7 +539,7 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int,
if cloneCode != 0:
(paths, cloneCode)
else:
- proc checkNext(index: int, skipEdit: bool): int =
+ proc checkNext(index: int, skipEdit: bool, skipKeys: bool): int =
if index < flatBasePackages.len:
let pkgInfos = flatBasePackages[index]
let base = pkgInfos[0].base
@@ -557,20 +555,66 @@ proc handleInstall(args: seq[Argument], config: Config, upgradeCount: int,
let commentsReversed = toSeq(comments.reversed)
printComments(config.color, pkgInfos[0].maintainer, commentsReversed)
- let res = if skipEdit:
+ let editRes = if skipEdit:
'n'
else: (block:
let defaultYes = aur and not config.viewNoDefault
editLoop(config, base, repoPath, pkgInfos[0].gitPath, defaultYes, noconfirm))
- if res == 'a':
+ if editRes == 'a':
1
else:
- checkNext(index + 1, skipEdit or res == 's')
+ let resultPkgInfos = reloadPkgInfos(config,
+ repoPath & "/" & pkgInfos[0].gitPath.get("."), pkgInfos)
+ let pgpKeys = lc[x | (p <- resultPkgInfos, x <- p.pgpKeys), string].deduplicate
+
+ proc keysLoop(index: int, skipKeys: bool): char =
+ if index >= pgpKeys.len:
+ 'n'
+ elif forkWait(() => (block:
+ discard close(0)
+ discard open("/dev/null")
+ discard close(1)
+ discard open("/dev/null")
+ discard close(2)
+ discard open("/dev/null")
+ execResult(gpgCmd, "--list-keys", pgpKeys[index]))) == 0:
+ keysLoop(index + 1, skipKeys)
+ else:
+ let res = if skipKeys:
+ 'y'
+ else:
+ printColonUserChoice(config.color,
+ tr"Import PGP key $#?" % [pgpKeys[index]], ['y', 'n', 'c', 'a', '?'],
+ 'y', '?', noconfirm, 'y')
+
+ let newSkipKeys = skipKeys or res == 'c'
+
+ if res == '?':
+ printUserInputHelp(('c', tr"import all keys"),
+ ('a', tr"abort operation"))
+ keysLoop(index, newSkipKeys)
+ elif res == 'y' or newSkipKeys:
+ let importCode = forkWait(() => execResult(gpgCmd,
+ "--recv-keys", pgpKeys[index]))
+ if importCode == 0 or newSkipKeys or noconfirm:
+ keysLoop(index + 1, newSkipKeys)
+ else:
+ keysLoop(index, newSkipKeys)
+ elif res == 'n':
+ keysLoop(index + 1, newSkipKeys)
+ else:
+ res
+
+ let keysRes = keysLoop(0, skipKeys)
+ if keysRes == 'a':
+ 1
+ else:
+ checkNext(index + 1, skipEdit or editRes == 's', skipKeys or keysRes == 's')
else:
0
- (paths, checkNext(0, false))
+ (paths, checkNext(0, false, false))
else:
(@[], 1))
else:
diff --git a/src/package.nim b/src/package.nim
index 5683d5f..32bc801 100644
--- a/src/package.nim
+++ b/src/package.nim
@@ -41,6 +41,7 @@ type
url*: Option[string]
licenses*: seq[string]
groups*: seq[string]
+ pgpKeys*: seq[string]
depends*: seq[PackageReference]
makeDepends*: seq[PackageReference]
checkDepends*: seq[PackageReference]
@@ -260,6 +261,7 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int
let url = collect("url").optLast
let licenses = collect("license")
let groups = collect("groups")
+ let pgpKeys = collect("validpgpkeys")
let depends = collectArch("depends")
let makeDepends = collectArch("makedepends").filterReferences(depends)
@@ -273,7 +275,7 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int
lc[PackageInfo(baseIndex: baseIndex, baseCount: baseCount,
repo: repo, base: b, name: name, version: v, description: description,
- archs: archs, url: url, licenses: licenses, groups: groups,
+ archs: archs, url: url, licenses: licenses, groups: groups, pgpKeys: pgpKeys,
depends: depends, makeDepends: makeDepends, checkDepends: checkDepends,
optional: optional, provides: provides, conflicts: conflicts, replaces: replaces,
maintainer: info.map(i => i.maintainer).flatten,
diff --git a/src/utils.nim b/src/utils.nim
index c1146ae..afcb1a3 100644
--- a/src/utils.nim
+++ b/src/utils.nim
@@ -18,6 +18,7 @@ const
suCmd* = "/usr/bin/su"
sudoCmd* = "/usr/bin/sudo"
gitCmd* = "/usr/bin/git"
+ gpgCmd* = "/usr/bin/gpg"
pacmanCmd* = "/usr/bin/pacman"
makepkgCmd* = "/usr/bin/makepkg"