aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkitsunyan2018-06-02 02:40:23 +0000
committerkitsunyan2018-06-02 02:40:23 +0000
commit3edef649597b7669bd67b1e42680ac25068debc7 (patch)
treea92b1ddfa86048e8167c1c9ec8ee7c9cbc33a0dd /src
parent5e2d49cdd52c8b9805136ba44cb66e8b5d4840fb (diff)
Update .SRCINFO parser
Some arrays may be provided by both pkgbase and pkgname. The following rules are applied now: 1. When pkgname has array items, array items from pkgbase are ignored. If pkgname provides only empty items (e.g. "group = "), that means array was erased for this pkgname in PKGBUILD. 2. The following arrays are extracted from pkgbase only: validpgpkeys, makedepends, checkdepends. 3. If pkgname's depends array is less that pkgbase's depends array, all missing items are considered as makedepends. For instance, pkgbase:depends=(p1 p2), pkgname:depends=(p1), then p2 becomes make dependency for pkgname.
Diffstat (limited to 'src')
-rw-r--r--src/package.nim49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/package.nim b/src/package.nim
index 1171374..bc55c3a 100644
--- a/src/package.nim
+++ b/src/package.nim
@@ -259,15 +259,15 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int
proc collectFromPairs(pairs: seq[SrcInfoPair], keyName: string): seq[string] =
lc[x.value | (x <- pairs, x.key == keyName), string]
- proc collect(keyName: string): seq[string] =
- let res = collectFromPairs(nameSeq[], keyName)
+ proc collect(baseOnly: bool, keyName: string): seq[string] =
+ let res = if baseOnly: @[] else: collectFromPairs(nameSeq[], keyName)
if res.len == 0:
- collectFromPairs(baseSeq[], keyName)
+ collectFromPairs(baseSeq[], keyName).filter(x => x.len > 0)
else:
- res
+ res.filter(x => x.len > 0)
- proc collectArch(keyName: string): seq[PackageReference] =
- (collect(keyName) & collect(keyName & "_" & arch))
+ proc collectArch(baseOnly: bool, keyName: string): seq[PackageReference] =
+ (collect(baseOnly, keyName) & collect(baseOnly, keyName & "_" & arch))
.map(n => parsePackageReference(n, true))
.filter(c => c.name.len > 0)
@@ -277,26 +277,29 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int
let base = lc[x.value | (x <- baseSeq[], x.key == "pkgbase"), string].optLast
- let version = collect("pkgver").optLast
- let release = collect("pkgrel").optLast
- let epoch = collect("epoch").optLast
+ let version = collect(true, "pkgver").optLast
+ let release = collect(true, "pkgrel").optLast
+ let epoch = collect(true, "epoch").optLast
let versionFull = lc[(v & "-" & r) | (v <- version, r <- release), string].optLast
.map(v => epoch.map(e => e & ":" & v).get(v))
- let description = collect("pkgdesc").optLast
- let archs = collect("arch").filter(a => a != "any")
- 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)
- let checkDepends = collectArch("checkdepends").filterReferences(depends & makeDepends)
- let optional = collectArch("optdepends")
- let provides = collectArch("provides")
- let conflicts = collectArch("conflicts")
- let replaces = collectArch("replaces")
+ let description = collect(false, "pkgdesc").optLast
+ let archs = collect(false, "arch").filter(a => a != "any")
+ let url = collect(false, "url").optLast
+ let licenses = collect(false, "license")
+ let groups = collect(false, "groups")
+ let pgpKeys = collect(true, "validpgpkeys")
+
+ let baseDepends = collectArch(true, "depends")
+ let depends = collectArch(false, "depends")
+ let makeDepends = (baseDepends & collectArch(true, "makedepends"))
+ .deduplicate.filterReferences(depends)
+ let checkDepends = collectArch(true, "checkdepends")
+ .filterReferences(depends & makeDepends)
+ let optional = collectArch(false, "optdepends")
+ let provides = collectArch(false, "provides")
+ let conflicts = collectArch(false, "conflicts")
+ let replaces = collectArch(false, "replaces")
let info = rpcInfos.filter(i => i.name == name).optLast