From 0afaa2a8cd7e56f4eabcf6b54e83bcab6be39f42 Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 21:36:19 +0100 Subject: compiles now on current devel (1.3.5) --- src/args.nim | 30 +++++-- src/aur.nim | 58 ++++++++++-- src/common.nim | 79 ++++++++++++---- src/feature/syncinfo.nim | 13 ++- src/feature/syncinstall.nim | 215 ++++++++++++++++++++++++++++++++++++-------- src/feature/syncsource.nim | 7 +- src/format.nim | 16 ++-- src/main.nim | 12 ++- src/package.nim | 112 ++++++++++++++++++----- src/pacman.nim | 106 ++++++++++++++++++---- 10 files changed, 527 insertions(+), 121 deletions(-) diff --git a/src/args.nim b/src/args.nim index fd03ee0..490bd2b 100644 --- a/src/args.nim +++ b/src/args.nim @@ -104,9 +104,14 @@ proc splitArgs*(params: seq[string], let argsResult = toSeq(splitSingle(current[1 .. ^1], optionsWithParameter, next)) let consumedNext = argsResult.map(a => a.consumedNext).foldl(a or b) let newNext = next.filter(n => not consumedNext) - - return (lc[(x.key, x.value, ArgumentType.short) | (x <- argsResult), Argument], - newNext, stdinConsumed, false) + when NimVersion >= "1.2": + let lc = collect(newSeq): + for x in argsResult: + (x.key,x.value,ArgumentType.short) + return (lc, newNext, stdinConsumed, false) + else: + return (lc[(x.key, x.value, ArgumentType.short) | (x <- argsResult), Argument], + newNext, stdinConsumed, false) else: return (@[(current, none(string), ArgumentType.target)], next, stdinConsumed, false) @@ -132,14 +137,20 @@ proc splitArgs*(params: seq[string], else: input - let cycle: ParseCycle = (params.map(some) & none(string)) + let cycle: ParseCycle = (params.mapIt(some(it)) & none(string)) .foldl(buildArgs(a, b), (newSeq[ParseArgument](), false, false)) if cycle.stdinConsumed: discard close(0) discard open("/dev/tty", O_RDONLY) - lc[x | (y <- cycle.args, x <- y.arg), Argument] + when NimVersion >= "1.2": + collect(newSeq): + for y in cycle.args: + for x in y.arg: + x + else: + lc[x | (y <- cycle.args, x <- y.arg), Argument] proc isShort*(arg: Argument): bool = arg.atype == ArgumentType.short proc isLong*(arg: Argument): bool = arg.atype == ArgumentType.long @@ -168,8 +179,13 @@ iterator items*(op: OptionPair): OptionKey = proc filter*(args: seq[Argument], removeMatches: bool, keepTargets: bool, pairs: varargs[OptionPair]): seq[Argument] = let pairsSeq = @pairs - let argsSet = lc[x | (y <- pairsSeq, x <- y), OptionKey].toHashSet - + when NimVersion >= "1.2": + let argsSet = collect(initHashSet): + for y in pairsSeq: + for x in y: + {x} + else: + let argsSet = lc[x | (y <- pairsSeq, x <- y), OptionKey].toHashSet args.filter(arg => (arg.isShort and (removeMatches xor (arg.key, false) in argsSet)) or (arg.isLong and (removeMatches xor (arg.key, true) in argsSet)) or (arg.isTarget and keepTargets)) diff --git a/src/aur.nim b/src/aur.nim index 399183c..a8be70b 100644 --- a/src/aur.nim +++ b/src/aur.nim @@ -70,9 +70,22 @@ proc getRpcPackageInfos*(pkgs: seq[string], repo: string, useTimeout: bool): .foldl(a & "&arg[]=" & b) performString(url, useTimeout))) - let table = lc[(x.name, x) | (z <- responses, y <- parseJson(z)["results"], - x <- parseRpcPackageInfo(y, repo)), (string, RpcPackageInfo)].toTable - (lc[x | (p <- pkgs, x <- table.opt(p)), RpcPackageInfo], none(string)) + when NimVersion >= "1.2": + let table = collect(initTable): + for z in responses: + for y in parseJson(z)["results"]: + for x in parseRpcPackageInfo(y,repo): + {x.name:x} + block: + let tmp = collect(newSeq): + for p in pkgs: + for x in table.opt(p): + x + (tmp,none(string)) + else: + let table = lc[(x.name, x) | (z <- responses, y <- parseJson(z)["results"], + x <- parseRpcPackageInfo(y, repo)), (string, RpcPackageInfo)].toTable + (lc[x | (p <- pkgs, x <- table.opt(p)), RpcPackageInfo], none(string)) except CurlError: (@[], some(getCurrentException().msg)) except JsonParsingError: @@ -95,7 +108,14 @@ proc getAurPackageInfos*(pkgs: seq[string], repo: string, arch: string, useTimeo error: Option[string] ] - let deduplicated = lc[x.base | (x <- rpcInfos), string].deduplicate + when NimVersion >= "1.2": + let deduplicated = block: + let tmp = collect(newSeq): + for x in rpcInfos: + x.base + tmp.deduplicate + else: + let deduplicated = lc[x.base | (x <- rpcInfos), string].deduplicate proc obtainAndParse(base: string, index: int): ParseResult = let (srcInfo, operror) = obtainPkgBaseSrcInfo(base, useTimeout) @@ -108,11 +128,27 @@ proc getAurPackageInfos*(pkgs: seq[string], repo: string, arch: string, useTimeo (pkgInfos, none(string)) let parsed = deduplicated.foldl(a & obtainAndParse(b, a.len), newSeq[ParseResult]()) - let infos = lc[x | (y <- parsed, x <- y.infos), PackageInfo] - let errors = lc[x | (y <- parsed, x <- y.error), string] + when NimVersion >= "1.2": + let infos = collect(newSeq): + for y in parsed: + for x in y.infos: + x + let errors = collect(newSeq): + for y in parsed: + for x in y.error: + x + else: + let infos = lc[x | (y <- parsed, x <- y.infos), PackageInfo] + let errors = lc[x | (y <- parsed, x <- y.error), string] let table = infos.map(i => (i.rpc.name, i)).toTable - let pkgInfos = lc[x | (p <- pkgs, x <- table.opt(p)), PackageInfo] + when NimVersion >= "1.2": + let pkgInfos = collect(newSeq): + for p in pkgs: + for x in table.opt(p): + x + else: + let pkgInfos = lc[x | (p <- pkgs, x <- table.opt(p)), PackageInfo] let names = rpcInfos.map(i => i.name).toHashSet let additionalPkgInfos = infos.filter(i => not (i.rpc.name in names)) @@ -132,7 +168,13 @@ proc findAurPackages*(query: seq[string], repo: string, useTimeout: bool): let response = performString(url, useTimeout) let results = parseJson(response)["results"] - let rpcInfos = lc[x | (y <- results, x <- parseRpcPackageInfo(y, repo)), RpcPackageInfo] + when NimVersion >= "1.2": + let rpcInfos = collect(newSeq): + for y in results: + for x in parseRpcPackageInfo(y,repo): + x + else: + let rpcInfos = lc[x | (y <- results, x <- parseRpcPackageInfo(y, repo)), RpcPackageInfo] let filteredRpcInfos = if query.len > 1: (block: let queryLow = query[1 .. ^1].map(q => q.toLowerAscii) diff --git a/src/common.nim b/src/common.nim index 8db3a79..58d4d08 100644 --- a/src/common.nim +++ b/src/common.nim @@ -153,8 +153,17 @@ proc findSyncTargets*(handle: ptr AlpmHandle, dbs: seq[ptr AlpmDatabase], return @[] else: if allowGroups and target.reference.constraint.isNone: - let groupRepo = lc[d | (d <- dbs, g <- d.groups, - $g.name == target.reference.name), ptr AlpmDatabase].optFirst + when NimVersion >= "1.2": + let groupRepo = block: + let tmp = collect(newSeq): + for d in dbs: + for g in d.groups: + if $g.name == target.reference.name: + d + tmp.optFirst + else: + let groupRepo = lc[d | (d <- dbs, g <- d.groups, + $g.name == target.reference.name), ptr AlpmDatabase].optFirst if groupRepo.isSome: return @[($groupRepo.unsafeGet.name, none(SyncFoundPackageInfo))] @@ -240,18 +249,36 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona (installed, explicit.toHashSet + assumeExplicit, dependsTable, alternatives) - let providedBy = lc[(y, x.key) | (x <- alternatives.namedPairs, y <- x.value), - tuple[reference: PackageReference, name: string]] + when NimVersion >= "1.2": + let providedBy = collect(newSeq): + for x in alternatives.namedPairs: + for y in x.value: + (reference:y,name:x.key) + else: + let providedBy = lc[(y, x.key) | (x <- alternatives.namedPairs, y <- x.value), + tuple[reference: PackageReference, name: string]] proc findRequired(withOptional: bool, results: HashSet[string], check: HashSet[string]): HashSet[string] = let full = results + check - let direct = lc[x.reference | (y <- dependsTable.namedPairs, y.key in check, - x <- y.value, withOptional or not x.optional), PackageReference] - - let indirect = lc[x.name | (y <- direct, x <- providedBy, - y.isProvidedBy(x.reference, true)), string].toHashSet + when NimVersion >= "1.2": + let direct = collect(newSeq): + for y in dependsTable.namedPairs: + if y.key in check: + for x in y.value: + if withOptional or not x.optional: + x.reference + let indirect = collect(initHashSet): + for y in direct: + for x in providedBy: + if y.isProvidedBy(x.reference, true): + {x.name} + else: + let direct = lc[x.reference | (y <- dependsTable.namedPairs, y.key in check, + x <- y.value, withOptional or not x.optional), PackageReference] + let indirect = lc[x.name | (y <- direct, x <- providedBy, + y.isProvidedBy(x.reference, true)), string].toHashSet let checkNext = (direct.map(p => p.name).toHashSet + indirect) - full if checkNext.len > 0: findRequired(withOptional, full, checkNext) else: full @@ -622,13 +649,29 @@ proc obtainBuildPkgInfosInternal(config: Config, bases: seq[LookupBaseGroup], (list[tuple[pkgInfos: seq[PackageInfo], path: Option[string]]](), 0)) let pkgInfosWithPaths = pkgInfosWithPathsReversed.reversed - let pkgInfos = lc[x | (y <- pkgInfosWithPaths, x <- y.pkgInfos), PackageInfo] - let paths = lc[x | (y <- pkgInfosWithPaths, x <- y.path), string] + when NimVersion >= "1.2": + let pkgInfos = collect(newSeq): + for y in pkgInfosWithPaths: + for x in y.pkgInfos: + x + let paths = collect(newSeq): + for y in pkgInfosWithPaths: + for x in y.path: + x + else: + let pkgInfos = lc[x | (y <- pkgInfosWithPaths, x <- y.pkgInfos), PackageInfo] + let paths = lc[x | (y <- pkgInfosWithPaths, x <- y.path), string] let pkgInfosTable = pkgInfos.map(i => (i.rpc.name, i)).toTable - - let foundPkgInfos = lc[x | (y <- pacmanTargetNames, - x <- pkgInfosTable.opt(y)), PackageInfo] + + when NimVersion >= "1.2": + let foundPkgInfos = collect(newSeq): + for y in pacmanTargetNames: + for x in pkgInfosTable.opt(y): + x + else: + let foundPkgInfos = lc[x | (y <- pacmanTargetNames, + x <- pkgInfosTable.opt(y)), PackageInfo] let errorMessages = pacmanTargetNames .filter(n => not pkgInfosTable.hasKey(n)) .map(n => tr"$#: failed to get package info" % [n]) @@ -738,7 +781,13 @@ proc cloneAurReposWithPackageInfos*(config: Config, rpcInfos: seq[RpcPackageInfo let (fullPkgInfos, paths, errors) = cloneNext(0, nil, nil, nil) let pkgInfosTable = fullPkgInfos.map(i => (i.rpc.name, i)).toTable - let resultPkgInfos = lc[x | (y <- rpcInfos, x <- pkgInfosTable.opt(y.name)), PackageInfo] + when NimVersion >= "1.2": + let resultPkgInfos = collect(newSeq): + for y in rpcInfos: + for x in pkgInfosTable.opt(y.name): + x + else: + let resultPkgInfos = lc[x | (y <- rpcInfos, x <- pkgInfosTable.opt(y.name)), PackageInfo] let names = rpcInfos.map(i => i.name).toHashSet let additionalPkgInfos = fullPkgInfos.filter(i => not (i.rpc.name in names)) diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim index 4f758fe..9dd1331 100644 --- a/src/feature/syncinfo.nim +++ b/src/feature/syncinfo.nim @@ -131,7 +131,14 @@ proc handleSyncInfo*(args: seq[Argument], config: Config): int = let padding = pacmanInfoStrings.map(s => s.trp).computeMaxLength let pkgInfosTable = pkgInfos.map(i => (i.rpc.toPackageReference, i)).toTable - let codes = code & lc[handleTarget(config, padding, finalArgs, x, - x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) | - (x <- fullTargets), int] + when NimVersion >= "1.2": + let codes = block: + let tmp = collect(newSeq): + for x in fullTargets: + handleTarget(config, padding, finalArgs, x, x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) + code & tmp + else: + let codes = code & lc[handleTarget(config, padding, finalArgs, x, + x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) | + (x <- fullTargets), int] codes.filter(c => c != 0).optFirst.get(0) diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 7aba043..36115cc 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -66,7 +66,14 @@ proc isVcs(name: string): bool = proc orderInstallation(ordered: seq[seq[seq[PackageInfo]]], grouped: seq[seq[PackageInfo]], satisfied: Table[PackageReference, SatisfyResult]): seq[seq[seq[PackageInfo]]] = - let orderedNamesSet = lc[c.rpc.name | (a <- ordered, b <- a, c <- b), string].toHashSet + when NimVersion >= "1.2": + let orderedNamesSet = collect(initHashSet): + for a in ordered: + for b in a: + for c in b: + {c.rpc.name} + else: + let orderedNamesSet = lc[c.rpc.name | (a <- ordered, b <- a, c <- b), string].toHashSet proc hasBuildDependency(pkgInfos: seq[PackageInfo]): bool = for pkgInfo in pkgInfos: @@ -241,8 +248,18 @@ proc findDependencies(config: Config, handle: ptr AlpmHandle, dbs: seq[ptr AlpmD success.map(r => (r.reference, r.result.unsafeGet)) & aurSuccess.map(r => (r.reference, r.result.unsafeGet))).toTable - let newUnsatisfied = lc[x | (y <- aurSuccess, r <- y.result, i <- r.buildPkgInfo, - x <- i.allDepends), PackageReference].deduplicate + when NimVersion >= "1.2": + let newUnsatisfied = block: + let tmp = collect(newSeq): + for y in aurSuccess: + for r in y.result: + for i in r.buildPkgInfo: + for x in i.allDepends: + x + tmp.deduplicate + else: + let newUnsatisfied = lc[x | (y <- aurSuccess, r <- y.result, i <- r.buildPkgInfo, + x <- i.allDepends), PackageReference].deduplicate let newTotalAurFail = (totalAurFail & aurFail).deduplicate let newTotalUnsatisfied = (newUnsatisfied & newTotalAurFail).deduplicate @@ -261,7 +278,15 @@ proc findDependencies(config: Config, handle: ptr AlpmHandle, (Table[PackageReference, SatisfyResult], seq[PackageReference], seq[string]) = let satisfied = pkgInfos.map(p => ((p.rpc.name, none(string), none(VersionConstraint)), (false, p.rpc.name, some(p)))).toTable - let unsatisfied = lc[x | (i <- pkgInfos, x <- i.allDepends), PackageReference].deduplicate + when NimVersion >= "1.2": + let unsatisfied = block: + let tmp = collect(newSeq): + for i in pkgInfos: + for x in i.allDepends: + x + tmp.deduplicate + else: + let unsatisfied = lc[x | (i <- pkgInfos, x <- i.allDepends), PackageReference].deduplicate findDependencies(config, handle, dbs, satisfied, unsatisfied, @[], additionalPkgInfos, @[], nodepsCount, assumeInstalled, printMode, noaur) @@ -473,7 +498,13 @@ proc buildLoop(config: Config, pkgInfos: seq[PackageInfo], skipDeps: bool, else: resultByNames - let failedNames = lc[x.name | (x <- resultByIndices, x.pkgInfo.isNone), string] + when NimVersion >= "1.2": + let failedNames = collect(newSeq): + for x in resultByIndices: + if x.pkgInfo.isNone: + x.name + else: + let failedNames = lc[x.name | (x <- resultByIndices, x.pkgInfo.isNone), string] if failedNames.len > 0: for name in failedNames: @@ -563,11 +594,24 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], let arch = if pkgInfo.archs.len > 0: config.common.arch else: "any" config.tmpRootInitial & "/" & pkgInfo.rpc.name & "-" & pkgInfo.rpc.version & "-" & arch & ext - let allFiles = lc[(r.name, formatArchiveFile(r.pkgInfo, br.ext)) | - (br <- buildResults, r <- br.replacePkgInfos), tuple[name: Option[string], file: string]] + when NimVersion >= "1.2": + let allFiles = collect(newSeq): + for br in buildResults: + for r in br.replacePkgInfos: + (name:r.name, file:formatArchiveFile(r.pkgInfo, br.ext)) + else: + let allFiles = lc[(r.name, formatArchiveFile(r.pkgInfo, br.ext)) | + (br <- buildResults, r <- br.replacePkgInfos), tuple[name: Option[string], file: string]] let filesTable = allFiles.filter(f => f.name.isSome).map(f => (f.name.unsafeGet, f.file)).toTable - let install = lc[(i.rpc.name, x) | (g <- basePackages, i <- g, x <- filesTable.opt(i.rpc.name)), - tuple[name: string, file: string]] + when NimVersion >= "1.2": + let install = collect(newSeq): + for g in basePackages: + for i in g: + for x in filesTable.opt(i.rpc.name): + (name:i.rpc.name,file:x) + else: + let install = lc[(i.rpc.name, x) | (g <- basePackages, i <- g, x <- filesTable.opt(i.rpc.name)), + tuple[name: string, file: string]] proc handleTmpRoot(clear: bool) = let installFiles = install.map(p => p.file) @@ -628,11 +672,24 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], let pacmanDatabaseParams = pacmanCmd & pacmanParams(config.color, commonArgs.keepOnlyOptions(commonOptions) & ("D", none(string), ArgumentType.short)) - let installParams = sudoPrefix & (pkgLibDir & "/install") & - cacheDir & $cacheUser & $cacheGroup & - $pacmanUpgradeParams.len & pacmanUpgradeParams & - $pacmanDatabaseParams.len & pacmanDatabaseParams & - lc[x | (i <- installWithReason, x <- [i.name, i.file, i.mode]), string] + when NimVersion >= "1.2": + + let installParams = block: + let tmp = collect(newSeq): + for i in installWithReason: + for x in [i.name,i.file,i.mode]: + x + sudoPrefix & (pkgLibDir & "/install") & + cacheDir & $cacheUser & $cacheGroup & + $pacmanUpgradeParams.len & pacmanUpgradeParams & + $pacmanDatabaseParams.len & pacmanDatabaseParams & + tmp + else: + let installParams = sudoPrefix & (pkgLibDir & "/install") & + cacheDir & $cacheUser & $cacheGroup & + $pacmanUpgradeParams.len & pacmanUpgradeParams & + $pacmanDatabaseParams.len & pacmanDatabaseParams & + lc[x | (i <- installWithReason, x <- [i.name, i.file, i.mode]), string] let code = forkWait(() => execResult(installParams)) if code != 0: @@ -662,8 +719,15 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], run(gitCmd, "-C", bareRepoPath, "tag", tag) handleTmpRoot(true) - let installedAs = lc[(r.name.unsafeGet, r.pkgInfo.rpc.name) | (br <- buildResults, - r <- br.replacePkgInfos, r.name.isSome), (string, string)] + when NimVersion >= "1.2": + let installedAs = collect(newSeq): + for br in buildResults: + for r in br.replacePkgInfos: + if r.name.isSome: + (r.name.unsafeGet, r.pkgInfo.rpc.name) + else: + let installedAs = lc[(r.name.unsafeGet, r.pkgInfo.rpc.name) | (br <- buildResults, + r <- br.replacePkgInfos, r.name.isSome), (string, string)] (installedAs, 0) proc deduplicatePkgInfos(pkgInfos: seq[PackageInfo], @@ -695,12 +759,25 @@ proc resolveDependencies(config: Config, pkgInfos: seq[PackageInfo], newSeq[seq[seq[PackageInfo]]](), newSeq[string]()) else: let buildAndAurNamesSet = pkgInfos.map(i => i.rpc.name).toHashSet - let fullPkgInfos = (pkgInfos & lc[i | (s <- satisfied.values, - i <- s.buildPkgInfo, not (i.rpc.name in buildAndAurNamesSet)), PackageInfo]) - .deduplicatePkgInfos(config, false) + when NimVersion >= "1.2": + let fullPkgInfos = block: + let tmp = collect(newSeq): + for s in satisfied.values: + for i in s.buildPkgInfo: + if not (i.rpc.name in buildAndAurNamesSet): + i + (pkgInfos & tmp).deduplicatePkgInfos(config,false) + let additionalPacmanTargets = collect(newSeq): + for x in satisfied.values: + if not x.installed and x.buildPkgInfo.isNone: + x.name + else: + let fullPkgInfos = (pkgInfos & lc[i | (s <- satisfied.values, + i <- s.buildPkgInfo, not (i.rpc.name in buildAndAurNamesSet)), PackageInfo]) + .deduplicatePkgInfos(config, false) - let additionalPacmanTargets = lc[x.name | (x <- satisfied.values, - not x.installed and x.buildPkgInfo.isNone), string] + let additionalPacmanTargets = lc[x.name | (x <- satisfied.values, + not x.installed and x.buildPkgInfo.isNone), string] let orderedPkgInfos = orderInstallation(fullPkgInfos, satisfied) (true, satisfied, additionalPacmanTargets, orderedPkgInfos, paths) @@ -709,16 +786,31 @@ proc confirmViewAndImportKeys(config: Config, basePackages: seq[seq[seq[PackageI installed: seq[Installed], noconfirm: bool): int = if basePackages.len > 0: (block: let installedVersions = installed.map(i => (i.name, i.version)).toTable - - printPackages(config.color, config.common.verbosePkgLists, - lc[(i.rpc.name, i.rpc.repo, installedVersions.opt(i.rpc.name), i.rpc.version) | - (g <- basePackages, b <- g, i <- b), PackageInstallFormat] - .sorted((a, b) => cmp(a.name, b.name))) + when NimVersion >= "1.2": + block: + let tmp = collect(newSeq): + for g in basePackages: + for b in g: + for i in b: + (i.rpc.name,i.rpc.repo,installedVersions.opt(i.rpc.name),i.rpc.version).PackageInstallFormat + printPackages(config.color, config.common.verbosePkgLists, + tmp.sorted((a,b) => cmp(a.name, b.name))) + else: + printPackages(config.color, config.common.verbosePkgLists, + lc[(i.rpc.name, i.rpc.repo, installedVersions.opt(i.rpc.name), i.rpc.version) | + (g <- basePackages, b <- g, i <- b), PackageInstallFormat] + .sorted((a, b) => cmp(a.name, b.name))) let input = printColonUserChoice(config.color, tr"Proceed with building?", ['y', 'n'], 'y', 'n', noconfirm, 'y') if input == 'y': - let flatBasePackages = lc[x | (a <- basePackages, x <- a), seq[PackageInfo]] + when NimVersion >= "1.2": + let flatBasePackages = collect(newSeq): + for a in basePackages: + for x in a: + x + else: + let flatBasePackages = lc[x | (a <- basePackages, x <- a), seq[PackageInfo]] proc checkNext(index: int, skipEdit: bool, skipKeys: bool): int = if index < flatBasePackages.len: @@ -749,7 +841,15 @@ proc confirmViewAndImportKeys(config: Config, basePackages: seq[seq[seq[PackageI else: let resultPkgInfos = reloadPkgInfos(config, repoPath & "/" & pkgInfos[0].rpc.gitSubdir.get("."), pkgInfos) - let pgpKeys = lc[x | (p <- resultPkgInfos, x <- p.pgpKeys), string].deduplicate + when NimVersion >= "1.2": + let pgpKeys = block: + let tmp = collect(newSeq): + for p in resultPkgInfos: + for x in p.pgpKeys: + x + tmp.deduplicate + else: + let pgpKeys = lc[x | (p <- resultPkgInfos, x <- p.pgpKeys), string].deduplicate proc keysLoop(index: int, skipKeys: bool): char = if index >= pgpKeys.len: @@ -890,8 +990,14 @@ proc filterIgnoresAndConflicts(config: Config, pkgInfos: seq[PackageInfo], targetNamesSet: HashSet[string], installed: Table[string, Installed], printMode: bool, noconfirm: bool): (seq[PackageInfo], seq[PackageInfo]) = let acceptedPkgInfos = pkgInfos.filter(pkgInfo => (block: - let instGroups = lc[x | (i <- installed.opt(pkgInfo.rpc.name), - x <- i.groups), string] + when NimVersion >= "1.2": + let instGroups = collect(newSeq): + for i in installed.opt(pkgInfo.rpc.name): + for x in i.groups: + x + else: + let instGroups = lc[x | (i <- installed.opt(pkgInfo.rpc.name), + x <- i.groups), string] if config.ignored(pkgInfo.rpc.name, (instGroups & pkgInfo.groups).deduplicate): if pkgInfo.rpc.name in targetNamesSet: @@ -908,10 +1014,25 @@ proc filterIgnoresAndConflicts(config: Config, pkgInfos: seq[PackageInfo], true)) let nonConflicingPkgInfos = acceptedPkgInfos.foldl(block: - let conflictsWith = lc[p | (p <- a, p.rpc.name != b.rpc.name and - (lc[0 | (c <- b.conflicts, c.isProvidedBy(p.rpc.toPackageReference, true)), int].len > 0 or - lc[0 | (c <- p.conflicts, c.isProvidedBy(b.rpc.toPackageReference, true)), int].len > 0)), - PackageInfo] + when NimVersion >= "1.2": + let conflictsWith = collect(newSeq): + for p in a: + if (p.rpc.name != b.rpc.name and (block:collect(newSeq): + for c in b.conflicts: + if c.isProvidedBy(p.rpc.toPackageReference, true): + 0 + ).len>0 or (block:collect(newSeq): + for c in p.conflicts: + if c.isProvidedBy(p.rpc.toPackageReference, true): + 0 + ).len>0 + ): + p + else: + let conflictsWith = lc[p | (p <- a, p.rpc.name != b.rpc.name and + (lc[0 | (c <- b.conflicts, c.isProvidedBy(p.rpc.toPackageReference, true)), int].len > 0 or + lc[0 | (c <- p.conflicts, c.isProvidedBy(b.rpc.toPackageReference, true)), int].len > 0)), + PackageInfo] if not printMode and conflictsWith.len > 0: for conflict in conflictsWith: printWarning(config.color, @@ -1043,7 +1164,12 @@ proc obtainInstalledWithAur(config: Config): (seq[Installed], seq[string]) = ($package.name, $package.version, package.groupsSeq, package.reason == AlpmReason.explicit, foreign) - let installed = lc[createInstalled(p) | (p <- handle.local.packages), Installed] + when NimVersion >= "1.2": + let installed = collect(newSeq): + for p in handle.local.packages: + createInstalled(p) + else: + let installed = lc[createInstalled(p) | (p <- handle.local.packages), Installed] let checkAurUpgradeNames = installed .filter(i => i.foreign and (config.checkIgnored or not config.ignored(i.name, i.groups))) .map(i => i.name) @@ -1076,7 +1202,13 @@ proc resolveBuildTargets(config: Config, syncTargets: seq[SyncPackageTarget], let installedTable = installed.map(i => (i.name, i)).toTable let rpcAurTargets = fullTargets.filter(f => f.isAurTargetFull(config.aurRepo)) - let targetRpcInfos = lc[x | (t <- rpcAurTargets, x <- t.rpcInfo), RpcPackageInfo] + when NimVersion >= "1.2": + let targetRpcInfos = collect(newSeq): + for t in rpcAurTargets: + for x in t.rpcInfo: + x + else: + let targetRpcInfos = lc[x | (t <- rpcAurTargets, x <- t.rpcInfo), RpcPackageInfo] let targetRpcInfoNames = targetRpcInfos.map(i => i.name).toHashSet let rpcInfos = targetRpcInfos & upgradeRpcInfos.filter(i => not (i.name in targetRpcInfoNames)) @@ -1224,8 +1356,15 @@ proc handleInstall(args: seq[Argument], config: Config, syncTargets: seq[SyncPac return true return false - lc[x.key | (x <- satisfied.namedPairs, not x.value.installed and - x.value.buildPkgInfo.isNone and not x.key.checkSatisfied), PackageReference] + when NimVersion >= "1.2": + collect(newSeq): + for x in satisfied.namedPairs: + if not x.value.installed and x.value.buildPkgInfo.isNone and + not x.key.checkSatisfied: + x.key + else: + lc[x.key | (x <- satisfied.namedPairs, not x.value.installed and + x.value.buildPkgInfo.isNone and not x.key.checkSatisfied), PackageReference] else: @[] diff --git a/src/feature/syncsource.nim b/src/feature/syncsource.nim index c050e6a..f966085 100644 --- a/src/feature/syncsource.nim +++ b/src/feature/syncsource.nim @@ -129,10 +129,11 @@ proc cloneAndCopy(config: Config, quiet: bool, fullTargets: seq[FullPackageTarge a & (pkg.base, pkg.version, b.sync.target.destination.get(pkg.base), none(string), git), newSeq[BaseTarget]()) - let (update, terminate) = if quiet: - (proc (a: int, b: int) {.closure.} = discard, proc () {.closure.} = discard) - else: + let (update, terminate) = if not quiet: printProgressShare(config.common.progressBar, tr"cloning repositories") + else: + (proc (i0: int, i1: int) {.sideEffect,closure.} = discard, proc () {.sideEffect,closure.} = discard) + let (results, rerrors) = cloneRepositories(config, baseTargets, update) terminate() diff --git a/src/format.nim b/src/format.nim index 2ac39dc..3ed7b58 100644 --- a/src/format.nim +++ b/src/format.nim @@ -108,7 +108,13 @@ proc printPackageInfo*(minPadding: int, color: bool, lines: varargs[PackageLineF if values.len == 0: @[] elif forceBreak: - lc[x | (y <- values.map(s => strutils.strip(s).splitLines(lineSize)), x <- y), string] + when NimVersion > "1.2": + collect(newSeq): + for y in values.map(s => strutils.strip(s).splitLines(lineSize)): + for x in y: + x + else: + lc[x | (y <- values.map(s => strutils.strip(s).splitLines(lineSize)), x <- y), string] else: values.map(v => strutils.strip(v)).foldl(a & " " & b).splitLines(lineSize) @@ -299,7 +305,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, () if not bar or width <= 0: echo(title, "...") - (proc (a: string, c: float) {.closure.} = discard, proc {.closure.} = discard) + (proc (a: string, c: float) {.sideEffect,closure.} = discard, proc {.sideEffect,closure.} = discard) else: let infoLen = max(width * 6 / 10, 50).int let progressLen = width - infoLen @@ -309,7 +315,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, () var lastProgress = 0f var averageSpeed = -1f - proc update(prefix: string, progress: float) {.closure.} = + proc update(prefix: string, progress: float) {.sideEffect,closure.} = let progressTrim = max(min(1, progress + 0.005), 0) let progressStr = $(progressTrim * 100).int & "%" let paddedProgressStr = ' '.repeat(5 - progressStr.len) & progressStr @@ -347,7 +353,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, () ' ', timeLeft, indicator, paddedProgressStr, "\x1b[0K\r") stdout.flushFile() - proc terminate() {.closure.} = + proc terminate() {.sideEffect,closure.} = echo() update(" ", 0) @@ -357,7 +363,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, () proc printProgressShare*(bar: bool, title: string): ((int, int) -> void, () -> void) = let (updateFull, terminate) = printProgressFull(bar, title) - proc update(current: int, total: int) {.closure.} = + proc update(current: int, total: int) {.sideEffect,closure.} = let prefix = if total > 0: "(" & ' '.repeat(($total).len - ($current).len) & $current & "/" & $total & ") " diff --git a/src/main.nim b/src/main.nim index 92e8887..af22bc0 100644 --- a/src/main.nim +++ b/src/main.nim @@ -11,8 +11,16 @@ import "feature/syncsource" proc execSudo*(args: seq[Argument]): int = - execResult(sudoPrefix & getAppFilename() & - lc[x | (y <- args, x <- y.collectArg), string]) + when NimVersion >= "1.2": + execResult(sudoPrefix & getAppFilename() & + (block:collect(newSeq): + for y in args: + for x in y.collectArg: + x + )) + else: + execResult(sudoPrefix & getAppFilename() & + lc[x | (y <- args, x <- y.collectArg), string]) proc passValidation(args: seq[Argument], config: Config, nonRootArgs: openArray[OptionPair], rootArgs: openArray[OptionPair], diff --git a/src/package.nim b/src/package.nim index 5b87184..5e42b0c 100644 --- a/src/package.nim +++ b/src/package.nim @@ -91,8 +91,15 @@ const static: # test only single match available - let osSet = lc[x | (r <- packageRepos, x <- r.os), string].toHashSet - let repoSet = lc[x | (r <- packageRepos, x <- r.repo), string].toHashSet + when NimVersion >= "1.2": + var osSet = initHashSet[string]() + var repoSet = initHashSet[string]() + for r in packageRepos: + osSet.incl(r.os) + repoSet.incl(r.repo) + else: + let osSet = lc[x | (r <- packageRepos, x <- r.os), string].toHashSet + let repoSet = lc[x | (r <- packageRepos, x <- r.repo), string].toHashSet for os in osSet: for repo in repoSet: let osValue = os @@ -102,10 +109,20 @@ static: "only single matching repo available: " & os & ":" & repo) # test unique url <> bareName links - let bareNameToUrl = lc[(x, r.git.url) | - (r <- packageRepos, x <- r.git.bareName), (string, string)].toTable - let urlToBareName = lc[(r.git.url, x) | - (r <- packageRepos, x <- r.git.bareName), (string, string)].toTable + when NimVersion >= "1.2": + let bareNameToUrl = collect(initTable): + for r in packageRepos: + for x in r.git.bareName: + {x:r.git.url} + let urlToBareName = collect(initTable): + for r in packageRepos: + for x in r.git.bareName: + {r.git.url:x} + else: + let bareNameToUrl = lc[(x, r.git.url) | + (r <- packageRepos, x <- r.git.bareName), (string, string)].toTable + let urlToBareName = lc[(r.git.url, x) | + (r <- packageRepos, x <- r.git.bareName), (string, string)].toTable template testBareNamesAndUrls(m1: untyped, m2: untyped) = for x1, x2 in m1: @@ -262,9 +279,15 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int rpcInfos: seq[RpcPackageInfo], baseSeq: ref seq[SrcInfoPair], nameSeq: ref seq[SrcInfoPair], arch: string, gitUrl: string, gitSubdir: Option[string]): Option[PackageInfo] = proc collectFromPairs(pairs: seq[SrcInfoPair], keyName: string): seq[string] = - lc[x.value | (x <- pairs, x.key == keyName), string] + when NimVersion >= "1.2": + collect(newSeq): + for x in pairs: + if x.key == keyName: + x.value + else: + lc[x.value | (x <- pairs, x.key == keyName), string] - proc collect(baseOnly: bool, keyName: string): seq[string] = + proc kcollect(baseOnly: bool, keyName: string): seq[string] = let res = if baseOnly: @[] else: collectFromPairs(nameSeq[], keyName) if res.len == 0: collectFromPairs(baseSeq[], keyName).filter(x => x.len > 0) @@ -272,28 +295,56 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int res.filter(x => x.len > 0) proc collectArch(baseOnly: bool, keyName: string): seq[PackageReference] = - (collect(baseOnly, keyName) & collect(baseOnly, keyName & "_" & arch)) + (kcollect(baseOnly, keyName) & kcollect(baseOnly, keyName & "_" & arch)) .map(n => parsePackageReference(n, true)) .filter(c => c.name.len > 0) proc filterReferences(references: seq[PackageReference], filterWith: seq[PackageReference]): seq[PackageReference] = references.filter(r => filterWith.filter(w => r.isProvidedBy(w, true)).len == 0) + + when NimVersion >= "1.2": +#[ let base = block: + let tmp = newSeq[string]() + for x in baseSeq[]: + if x.key == "pkgbase": + tmp.add(x.value) + tmp.optLast +]# + let base = block: + let tmp = collect(newSeq): + for x in baseSeq[]: + if x.key == "pkgbase": + x.value + tmp.optLast + else: + let base = lc[x.value | (x <- baseSeq[], x.key == "pkgbase"), string].optLast + + let version = kcollect(true, "pkgver").optLast + let release = kcollect(true, "pkgrel").optLast + let epoch = kcollect(true, "epoch").optLast + when NimVersion >= "1.2": + #tmp = newSeq[string]() + #for v in version: + #for r in release: + #tmp.add(v & "-" & r) + #let versionFull = tmp.optLast.map(v => epoch.map(e => e & ":" & v).get(v)) + let versionFull = block: + let tmp = collect(newSeq): + for v in version: + for r in release: + (v & "-" & r) + tmp.optLast.map(v => epoch.map(e => e & ":" & v).get(v)) + else: + let versionFull = lc[(v & "-" & r) | (v <- version, r <- release), string].optLast + .map(v => epoch.map(e => e & ":" & v).get(v)) - let base = lc[x.value | (x <- baseSeq[], x.key == "pkgbase"), string].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(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 description = kcollect(false, "pkgdesc").optLast + let archs = kcollect(false, "arch").filter(a => a != "any") + let url = kcollect(false, "url").optLast + let licenses = kcollect(false, "license") + let groups = kcollect(false, "groups") + let pgpKeys = kcollect(true, "validpgpkeys") let baseDepends = collectArch(true, "depends") let depends = collectArch(false, "depends") @@ -308,7 +359,20 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int let info = rpcInfos.filter(i => i.name == name).optLast - lc[((repo, b, name, v, description, info.map(i => i.maintainer).flatten, + when NimVersion >= "1.2": + block: + let tmp = collect(newSeq): + for b in base: + for v in versionFull: + ((repo, b, name, v, description, info.map(i => i.maintainer).flatten, + info.map(i => i.firstSubmitted).flatten, info.map(i => i.lastModified).flatten, + info.map(i => i.outOfDate).flatten, info.map(i => i.votes).get(0), + info.map(i => i.popularity).get(0), gitUrl, gitSubdir), baseIndex, baseCount, + archs, url, licenses, groups, pgpKeys, depends, makeDepends, checkDepends, + optional, provides, conflicts, replaces) + tmp.optLast + else: + lc[((repo, b, name, v, description, info.map(i => i.maintainer).flatten, info.map(i => i.firstSubmitted).flatten, info.map(i => i.lastModified).flatten, info.map(i => i.outOfDate).flatten, info.map(i => i.votes).get(0), info.map(i => i.popularity).get(0), gitUrl, gitSubdir), baseIndex, baseCount, diff --git a/src/pacman.nim b/src/pacman.nim index 857581f..d1fadb0 100644 --- a/src/pacman.nim +++ b/src/pacman.nim @@ -36,7 +36,13 @@ proc calculateOptionsWithParameter(opts: seq[CommandOption]): seq[OptionKey] {.c else: @[] - lc[x | (y <- opts, x <- commandToSeq(y)), OptionKey] + when NimVersion >= "1.2": + collect(newSeq): + for y in opts: + for x in commandToSeq(y): + x + else: + lc[x | (y <- opts, x <- commandToSeq(y)), OptionKey] proc o(long: string): CommandOption {.compileTime.} = ((none(string), long), false, false, {}) @@ -200,7 +206,13 @@ proc getOperation*(args: seq[Argument]): OperationType = proc filterOptions*(args: seq[Argument], removeMatches: bool, keepTargets: bool, includeOperations: bool, opts: varargs[seq[CommandOption]]): seq[Argument] = let optsSeq = @opts - let optsPairSeq = lc[x.pair | (y <- optsSeq, x <- y), OptionPair] + when NimVersion >= "1.2": + let optsPairSeq = collect(newSeq): + for y in optsSeq: + for x in y: + x.pair + else: + let optsPairSeq = lc[x.pair | (y <- optsSeq, x <- y), OptionPair] let work = if includeOperations: (optsPairSeq & operations.map(o => o.pair)) @@ -234,16 +246,45 @@ proc filterExtensions*(args: seq[Argument], removeMatches: bool, keepTargets: bo opts: varargs[seq[CommandOption]]): seq[Argument] = let optsSeq = @opts let optsFilter = if removeMatches: - lc[x | (y <- optsSeq, x <- y), CommandOption] + when NimVersion >= "1.2": + collect(newSeq): + for y in optsSeq: + for x in y: + x + else: + lc[x | (y <- optsSeq, x <- y), CommandOption] else: (block: - let pairs = lc[x.pair | (y <- optsSeq, x <- y), OptionPair].toHashSet - lc[x | (x <- allOptions, not (x.pair in pairs)), CommandOption]) - - let argsSeq = lc[x.pair | (x <- optsFilter, x.extension), OptionPair] + when NimVersion >= "1.2": + let pairs = collect(initHashSet): + for y in optsSeq: + for x in y: + {x.pair} + collect(newSeq): + for x in allOptions: + if not (x.pair in pairs): + x + else: + let pairs = lc[x.pair | (y <- optsSeq, x <- y), OptionPair].toHashSet + lc[x | (x <- allOptions, not (x.pair in pairs)), CommandOption] + ) + + when NimVersion >= "1.2": + let argsSeq = collect(newSeq): + for x in optsFilter: + if x.extension: + x.pair + else: + let argsSeq = lc[x.pair | (x <- optsFilter, x.extension), OptionPair] args.filter(removeMatches, keepTargets, argsSeq) proc obtainConflictsPairs(conflicts: seq[ConflictingOptions]): Table[string, seq[OptionPair]] = - let all = lc[x | (y <- conflicts, x <- y.left & y.right), string].deduplicate + when NimVersion >= "1.2": + let all = collect(newSeq): + for y in conflicts: + for x in (y.left & y.right): + x + else: + let all = lc[x | (y <- conflicts, x <- y.left & y.right), string].deduplicate all.map(c => (c, allOptions.filter(o => o.pair.long == c) .map(o => o.pair).deduplicate)).toTable @@ -259,14 +300,30 @@ proc checkConflicts*(args: seq[Argument], let table = conflicts.obtainConflictsPairs template full(s: string): OptionPair = table[s][0] - lc[(c.left, w) | (c <- conflicts, args.check(c.left.full), - w <- c.right, args.check(w.full)), (string, string)].optFirst + when NimVersion >= "1.2": + block: + let tmp = collect(newSeq): + for c in conflicts: + if args.check(c.left.full): + for w in c.right: + if args.check(w.full): + (c.left,w) + tmp.optFirst + else: + lc[(c.left, w) | (c <- conflicts, args.check(c.left.full), + w <- c.right, args.check(w.full)), (string, string)].optFirst proc pacmanParams*(color: bool, args: varargs[Argument]): seq[string] = let colorStr = if color: "always" else: "never" let argsSeq = ("color", some(colorStr), ArgumentType.long) & @args.filter(arg => not arg.matchOption(%%%"color")) - lc[x | (y <- argsSeq, x <- y.collectArg), string] + when NimVersion >= "1.2": + collect(newSeq): + for y in argsSeq: + for x in y.collectArg: + x + else: + lc[x | (y <- argsSeq, x <- y.collectArg), string] proc pacmanExecInternal(root: bool, params: varargs[string]): int = let exec = if root: sudoPrefix & pacmanCmd & @params else: pacmanCmd & @params @@ -283,7 +340,14 @@ proc pacmanRun*(root: bool, color: bool, args: varargs[Argument]): int = proc pacmanValidateAndThrow(args: varargs[tuple[arg: Argument, pass: bool]]): void = let argsSeq = @args - let collectedArgs = lc[x | (y <- argsSeq, y.pass, x <- y.arg.collectArg), string] + when NimVersion >= "1.2": + let collectedArgs = collect(newSeq): + for y in argsSeq: + if y.pass: + for x in y.arg.collectArg: + x + else: + let collectedArgs = lc[x | (y <- argsSeq, y.pass, x <- y.arg.collectArg), string] let code = forkWait(() => pacmanExecInternal(false, "-T" & collectedArgs)) if code != 0: raise haltError(code) @@ -346,10 +410,20 @@ proc obtainPacmanConfig*(args: seq[Argument]): PacmanConfig = let debug = args.check(%%%"debug") let progressBar = not args.check(%%%"noprogressbar") - let ignorePkgs = lc[x | (y <- getAll(%%%"ignore"), - x <- y.split(',')), string].toHashSet - let ignoreGroups = lc[x | (y <- getAll(%%%"ignoregroup"), - x <- y.split(',')), string].toHashSet + when NimVersion >= "1.2": + let ignorePkgs = collect(initHashSet): + for y in getAll(%%%"ignore"): + for x in y.split(','): + {x} + let ignoreGroups = collect(initHashSet): + for y in getAll(%%%"ignoregroup"): + for x in y.split(','): + {x} + else: + let ignorePkgs = lc[x | (y <- getAll(%%%"ignore"), + x <- y.split(',')), string].toHashSet + let ignoreGroups = lc[x | (y <- getAll(%%%"ignoregroup"), + x <- y.split(',')), string].toHashSet let hasKeyserver = forkWaitRedirect(() => (block: if dropPrivileges(): -- cgit v1.2.3-70-g09d2 From b47df19c354e6b1c3c438b57eb463bbfaa8fd08d Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 22:15:13 +0100 Subject: compiles on 1.2.6 --- src/common.nim | 18 +++++++++++++++++- src/pacman.nim | 28 +++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/common.nim b/src/common.nim index 58d4d08..a7d59c4 100644 --- a/src/common.nim +++ b/src/common.nim @@ -262,7 +262,7 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona check: HashSet[string]): HashSet[string] = let full = results + check - when NimVersion >= "1.2": + when NimVersion >= "1.3.5": let direct = collect(newSeq): for y in dependsTable.namedPairs: if y.key in check: @@ -274,6 +274,22 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona for x in providedBy: if y.isProvidedBy(x.reference, true): {x.name} + elif NimVersion >= "1.2": + let direct = block: + var tmp = newSeq[PackageReference]() + for y in dependsTable.namedPairs: + if y.key in check: + for x in y.value: + if withOptional or not x.optional: + tmp.add(x.reference) + tmp + let indirect = block: + var tmp = initHashSet[string]() + for y in direct: + for x in providedBy: + if y.isProvidedBy(x.reference, true): + tmp.incl(x.name) + tmp else: let direct = lc[x.reference | (y <- dependsTable.namedPairs, y.key in check, x <- y.value, withOptional or not x.optional), PackageReference] diff --git a/src/pacman.nim b/src/pacman.nim index d1fadb0..1b9d2f9 100644 --- a/src/pacman.nim +++ b/src/pacman.nim @@ -300,15 +300,25 @@ proc checkConflicts*(args: seq[Argument], let table = conflicts.obtainConflictsPairs template full(s: string): OptionPair = table[s][0] - when NimVersion >= "1.2": - block: - let tmp = collect(newSeq): + when NimVersion >= "1.3.5": + (block:collect(newSeq): for c in conflicts: if args.check(c.left.full): for w in c.right: if args.check(w.full): (c.left,w) - tmp.optFirst + ).optFirst + elif NimVersion >= "1.2": + (block: + var tmp = newSeq[(string,string)]() + for c in conflicts: + if args.check(c.left.full): + for w in c.right: + if args.check(w.full): + tmp.add((c.left,w)) + tmp + ).optFirst + else: lc[(c.left, w) | (c <- conflicts, args.check(c.left.full), w <- c.right, args.check(w.full)), (string, string)].optFirst @@ -340,12 +350,20 @@ proc pacmanRun*(root: bool, color: bool, args: varargs[Argument]): int = proc pacmanValidateAndThrow(args: varargs[tuple[arg: Argument, pass: bool]]): void = let argsSeq = @args - when NimVersion >= "1.2": + when NimVersion >= "1.3.5": let collectedArgs = collect(newSeq): for y in argsSeq: if y.pass: for x in y.arg.collectArg: x + elif NimVersion >= "1.2": + let collectedArgs = block: + var tmp = newSeq[string]() + for y in argsSeq: + if y.pass: + for x in y.arg.collectArg: + tmp.add(x) + tmp else: let collectedArgs = lc[x | (y <- argsSeq, y.pass, x <- y.arg.collectArg), string] let code = forkWait(() => pacmanExecInternal(false, "-T" & collectedArgs)) -- cgit v1.2.3-70-g09d2 From 31108f15f5d1e9cc88ff4207658bf5155b184108 Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 22:29:42 +0100 Subject: removed csize_t warnings, required casting a len to csize_t --- src/utils.nim | 6 +++--- src/wrapper/curl.nim | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils.nim b/src/utils.nim index 8ca68d4..6fb0470 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -211,7 +211,7 @@ proc forkWaitRedirect*(call: () -> int): tuple[output: seq[string], code: int] = proc getgrouplist*(user: cstring, group: Gid, groups: ptr cint, ngroups: var cint): cint {.importc, header: "".} -proc setgroups*(size: csize, groups: ptr cint): cint +proc setgroups*(size: csize_t, groups: ptr cint): cint {.importc, header: "".} proc getUser(uid: int): User = @@ -257,8 +257,8 @@ proc dropPrivileges*(): bool = if initialUser.isSome: let user = initialUser.unsafeGet var groups = user.groups.map(x => x.cint) - - if setgroups(user.groups.len, addr(groups[0])) < 0: + + if setgroups(cast[csize_t](user.groups.len), addr(groups[0])) < 0: return false if setgid((Gid) user.gid) != 0: return false diff --git a/src/wrapper/curl.nim b/src/wrapper/curl.nim index 98d6880..79468a9 100644 --- a/src/wrapper/curl.nim +++ b/src/wrapper/curl.nim @@ -58,8 +58,8 @@ proc escape*(instance: ref CurlInstance, s: string): string = else: "" -proc curlWriteMemory(mem: array[csize.high, char], size: csize, nmemb: csize, - userdata: ref CurlInstance): csize {.cdecl.} = +proc curlWriteMemory(mem: array[csize_t.high, char], size: csize_t, nmemb: csize_t, + userdata: ref CurlInstance): csize_t {.cdecl.} = let total = size * nmemb if total > 0: userData.data &= mem[0 .. total - 1] -- cgit v1.2.3-70-g09d2 From 4fad58d7be80d90058cf627a2f9bccbd6016e72b Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 22:42:10 +0100 Subject: removed Exception warnings, changed Exceptions to CatchableErrors --- src/utils.nim | 4 ++-- src/wrapper/curl.nim | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.nim b/src/utils.nim index 6fb0470..e46a8e0 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -2,10 +2,10 @@ import hashes, options, os, posix, sequtils, strutils, sugar, tables type - HaltError* = object of Exception + HaltError* = object of CatchableError code*: int - CommandError* = object of Exception + CommandError* = object of CatchableError color*: Option[bool] error*: bool diff --git a/src/wrapper/curl.nim b/src/wrapper/curl.nim index 79468a9..9abb341 100644 --- a/src/wrapper/curl.nim +++ b/src/wrapper/curl.nim @@ -18,7 +18,7 @@ type url = 10002, writeFunction = 20011 - CurlError* = object of Exception + CurlError* = object of CatchableError {.passL: "-lcurl".} -- cgit v1.2.3-70-g09d2 From 8ca6a6ae081fa6381e79b43d1363e5e5ce00c9ba Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 22:52:42 +0100 Subject: removed deprecated []= warnings --- src/common.nim | 6 +++--- src/config.nim | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/common.nim b/src/common.nim index a7d59c4..6b15b4c 100644 --- a/src/common.nim +++ b/src/common.nim @@ -242,10 +242,10 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona installed.add(pkg.toPackageReference) if pkg.reason == AlpmReason.explicit: explicit &= $pkg.name - dependsTable.add($pkg.name, - depends.map(x => (x, false)) + optional.map(x => (x, true))) + dependsTable[$pkg.name]= + depends.map(x => (x, false)) + optional.map(x => (x, true)) if provides.len > 0: - alternatives.add($pkg.name, provides) + alternatives[$pkg.name]= provides (installed, explicit.toHashSet + assumeExplicit, dependsTable, alternatives) diff --git a/src/config.nim b/src/config.nim index e8be1fc..1afa89a 100644 --- a/src/config.nim +++ b/src/config.nim @@ -81,9 +81,9 @@ proc readConfigFile*(configFile: string): table[currentCategory] = category elif currentCategory.len > 0: if line.match(re"(\w+)\ *=\ *(.*)", matches): - category[].add(matches[0], matches[1]) + category[matches[0]]= matches[1] else: - category[].add(line, "") + category[line]="" false except EOFError: -- cgit v1.2.3-70-g09d2 From b8d35dea8fb61ec177ab898b70404338f2ed477b Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 22:55:59 +0100 Subject: dirExists -> existsDir --- src/common.nim | 6 +++--- src/feature/syncclean.nim | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common.nim b/src/common.nim index 6b15b4c..8dc41c8 100644 --- a/src/common.nim +++ b/src/common.nim @@ -527,7 +527,7 @@ proc cloneBareRepo(config: Config, bareKind: BareKind, bareName: string, if forkWait(() => (block: if not dropPrivileges or dropPrivileges(): - if existsDir(repoPath): + if dirExists(repoPath): let branch = branchOption.get("master") execResult(gitCmd, "-C", repoPath, "fetch", "-q", "--no-tags", "origin", branch & ":" & branch) @@ -724,7 +724,7 @@ proc cloneAurRepo*(config: Config, base: string, gitUrl: string, if message.isSome: (1, message) - elif repoPath.existsDir(): + elif repoPath.dirExists(): (0, none(string)) else: let fullName = bareFullName(BareKind.pkg, base) @@ -733,7 +733,7 @@ proc cloneAurRepo*(config: Config, base: string, gitUrl: string, let cloneBareCode = forkWait(() => (block: if not dropPrivileges or dropPrivileges(): - if existsDir(bareRepoPath): + if dirExists(bareRepoPath): execResult(gitCmd, "-C", bareRepoPath, "fetch", "-q", "--no-tags", "origin", "master:master") else: diff --git a/src/feature/syncclean.nim b/src/feature/syncclean.nim index 6b1f853..ad0c255 100644 --- a/src/feature/syncclean.nim +++ b/src/feature/syncclean.nim @@ -31,7 +31,7 @@ proc handleSyncClean*(args: seq[Argument], config: Config): int = else: echo(tr"removing all package repositories...") - if existsDir(reposCacheDir): + if dirExists(reposCacheDir): withAlpmConfig(config, false, handle, dbs, errors): for e in errors: printError(config.color, e) -- cgit v1.2.3-70-g09d2 From c54e6d24b70f21293612449c7a960e64077c5f89 Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 23:45:21 +0100 Subject: refactored collect blocks --- src/aur.nim | 16 +++++------ src/common.nim | 5 ++-- src/feature/syncinfo.nim | 9 +++---- src/feature/syncinstall.nim | 65 ++++++++++++++++++++------------------------- src/main.nim | 5 ++-- src/package.nim | 46 ++++++++++++-------------------- src/pacman.nim | 8 +++--- 7 files changed, 64 insertions(+), 90 deletions(-) diff --git a/src/aur.nim b/src/aur.nim index a8be70b..542a21c 100644 --- a/src/aur.nim +++ b/src/aur.nim @@ -76,12 +76,11 @@ proc getRpcPackageInfos*(pkgs: seq[string], repo: string, useTimeout: bool): for y in parseJson(z)["results"]: for x in parseRpcPackageInfo(y,repo): {x.name:x} - block: - let tmp = collect(newSeq): - for p in pkgs: - for x in table.opt(p): - x - (tmp,none(string)) + ((block:collect(newSeq): + for p in pkgs: + for x in table.opt(p): + x + ),none(string)) else: let table = lc[(x.name, x) | (z <- responses, y <- parseJson(z)["results"], x <- parseRpcPackageInfo(y, repo)), (string, RpcPackageInfo)].toTable @@ -109,11 +108,10 @@ proc getAurPackageInfos*(pkgs: seq[string], repo: string, arch: string, useTimeo ] when NimVersion >= "1.2": - let deduplicated = block: - let tmp = collect(newSeq): + let deduplicated = deduplicate: + collect(newSeq): for x in rpcInfos: x.base - tmp.deduplicate else: let deduplicated = lc[x.base | (x <- rpcInfos), string].deduplicate diff --git a/src/common.nim b/src/common.nim index 8dc41c8..0f2804b 100644 --- a/src/common.nim +++ b/src/common.nim @@ -154,13 +154,12 @@ proc findSyncTargets*(handle: ptr AlpmHandle, dbs: seq[ptr AlpmDatabase], else: if allowGroups and target.reference.constraint.isNone: when NimVersion >= "1.2": - let groupRepo = block: - let tmp = collect(newSeq): + let groupRepo = optFirst: + collect(newSeq): for d in dbs: for g in d.groups: if $g.name == target.reference.name: d - tmp.optFirst else: let groupRepo = lc[d | (d <- dbs, g <- d.groups, $g.name == target.reference.name), ptr AlpmDatabase].optFirst diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim index 9dd1331..6b2278d 100644 --- a/src/feature/syncinfo.nim +++ b/src/feature/syncinfo.nim @@ -132,11 +132,10 @@ proc handleSyncInfo*(args: seq[Argument], config: Config): int = let pkgInfosTable = pkgInfos.map(i => (i.rpc.toPackageReference, i)).toTable when NimVersion >= "1.2": - let codes = block: - let tmp = collect(newSeq): - for x in fullTargets: - handleTarget(config, padding, finalArgs, x, x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) - code & tmp + let codes = code & (block:collect(newSeq): + for x in fullTargets: + handleTarget(config, padding, finalArgs, x, x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) + ) else: let codes = code & lc[handleTarget(config, padding, finalArgs, x, x.rpcInfo.map(i => pkgInfosTable.opt(i.toPackageReference)).flatten) | diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim index 36115cc..b6347f9 100644 --- a/src/feature/syncinstall.nim +++ b/src/feature/syncinstall.nim @@ -249,14 +249,13 @@ proc findDependencies(config: Config, handle: ptr AlpmHandle, dbs: seq[ptr AlpmD aurSuccess.map(r => (r.reference, r.result.unsafeGet))).toTable when NimVersion >= "1.2": - let newUnsatisfied = block: - let tmp = collect(newSeq): + let newUnsatisfied = deduplicate: + collect(newSeq): for y in aurSuccess: for r in y.result: for i in r.buildPkgInfo: for x in i.allDepends: x - tmp.deduplicate else: let newUnsatisfied = lc[x | (y <- aurSuccess, r <- y.result, i <- r.buildPkgInfo, x <- i.allDepends), PackageReference].deduplicate @@ -279,12 +278,11 @@ proc findDependencies(config: Config, handle: ptr AlpmHandle, let satisfied = pkgInfos.map(p => ((p.rpc.name, none(string), none(VersionConstraint)), (false, p.rpc.name, some(p)))).toTable when NimVersion >= "1.2": - let unsatisfied = block: - let tmp = collect(newSeq): + let unsatisfied = deduplicate: + collect(newSeq): for i in pkgInfos: for x in i.allDepends: x - tmp.deduplicate else: let unsatisfied = lc[x | (i <- pkgInfos, x <- i.allDepends), PackageReference].deduplicate findDependencies(config, handle, dbs, satisfied, unsatisfied, @[], @@ -673,17 +671,15 @@ proc installGroupFromSources(config: Config, commonArgs: seq[Argument], commonArgs.keepOnlyOptions(commonOptions) & ("D", none(string), ArgumentType.short)) when NimVersion >= "1.2": - - let installParams = block: - let tmp = collect(newSeq): - for i in installWithReason: - for x in [i.name,i.file,i.mode]: - x - sudoPrefix & (pkgLibDir & "/install") & + let installParams = sudoPrefix & (pkgLibDir & "/install") & cacheDir & $cacheUser & $cacheGroup & $pacmanUpgradeParams.len & pacmanUpgradeParams & $pacmanDatabaseParams.len & pacmanDatabaseParams & - tmp + (block:collect(newSeq): + for i in installWithReason: + for x in [i.name,i.file,i.mode]: + x + ) else: let installParams = sudoPrefix & (pkgLibDir & "/install") & cacheDir & $cacheUser & $cacheGroup & @@ -760,13 +756,12 @@ proc resolveDependencies(config: Config, pkgInfos: seq[PackageInfo], else: let buildAndAurNamesSet = pkgInfos.map(i => i.rpc.name).toHashSet when NimVersion >= "1.2": - let fullPkgInfos = block: - let tmp = collect(newSeq): - for s in satisfied.values: - for i in s.buildPkgInfo: - if not (i.rpc.name in buildAndAurNamesSet): - i - (pkgInfos & tmp).deduplicatePkgInfos(config,false) + let fullPkgInfos = (pkgInfos & (block:collect(newSeq): + for s in satisfied.values: + for i in s.buildPkgInfo: + if not (i.rpc.name in buildAndAurNamesSet): + i + )).deduplicatePkgInfos(config,false) let additionalPacmanTargets = collect(newSeq): for x in satisfied.values: if not x.installed and x.buildPkgInfo.isNone: @@ -787,14 +782,12 @@ proc confirmViewAndImportKeys(config: Config, basePackages: seq[seq[seq[PackageI if basePackages.len > 0: (block: let installedVersions = installed.map(i => (i.name, i.version)).toTable when NimVersion >= "1.2": - block: - let tmp = collect(newSeq): - for g in basePackages: - for b in g: - for i in b: - (i.rpc.name,i.rpc.repo,installedVersions.opt(i.rpc.name),i.rpc.version).PackageInstallFormat - printPackages(config.color, config.common.verbosePkgLists, - tmp.sorted((a,b) => cmp(a.name, b.name))) + printPackages(config.color, config.common.verbosePkgLists,(block:collect(newSeq): + for g in basePackages: + for b in g: + for i in b: + (i.rpc.name,i.rpc.repo,installedVersions.opt(i.rpc.name),i.rpc.version).PackageInstallFormat + ).sorted((a,b) => cmp(a.name, b.name))) else: printPackages(config.color, config.common.verbosePkgLists, lc[(i.rpc.name, i.rpc.repo, installedVersions.opt(i.rpc.name), i.rpc.version) | @@ -842,12 +835,11 @@ proc confirmViewAndImportKeys(config: Config, basePackages: seq[seq[seq[PackageI let resultPkgInfos = reloadPkgInfos(config, repoPath & "/" & pkgInfos[0].rpc.gitSubdir.get("."), pkgInfos) when NimVersion >= "1.2": - let pgpKeys = block: - let tmp = collect(newSeq): + let pgpKeys = deduplicate: + collect(newSeq): for p in resultPkgInfos: for x in p.pgpKeys: x - tmp.deduplicate else: let pgpKeys = lc[x | (p <- resultPkgInfos, x <- p.pgpKeys), string].deduplicate @@ -1017,16 +1009,17 @@ proc filterIgnoresAndConflicts(config: Config, pkgInfos: seq[PackageInfo], when NimVersion >= "1.2": let conflictsWith = collect(newSeq): for p in a: - if (p.rpc.name != b.rpc.name and (block:collect(newSeq): + if p.rpc.name != b.rpc.name and + (block:collect(newSeq): for c in b.conflicts: if c.isProvidedBy(p.rpc.toPackageReference, true): 0 - ).len>0 or (block:collect(newSeq): + ).len>0 or + (block:collect(newSeq): for c in p.conflicts: if c.isProvidedBy(p.rpc.toPackageReference, true): 0 - ).len>0 - ): + ).len>0: p else: let conflictsWith = lc[p | (p <- a, p.rpc.name != b.rpc.name and diff --git a/src/main.nim b/src/main.nim index af22bc0..458ba72 100644 --- a/src/main.nim +++ b/src/main.nim @@ -12,12 +12,11 @@ import proc execSudo*(args: seq[Argument]): int = when NimVersion >= "1.2": - execResult(sudoPrefix & getAppFilename() & - (block:collect(newSeq): + execResult(sudoPrefix & getAppFilename() & (block:collect(newSeq): for y in args: for x in y.collectArg: x - )) + )) else: execResult(sudoPrefix & getAppFilename() & lc[x | (y <- args, x <- y.collectArg), string]) diff --git a/src/package.nim b/src/package.nim index 5e42b0c..340f359 100644 --- a/src/package.nim +++ b/src/package.nim @@ -92,11 +92,14 @@ const static: # test only single match available when NimVersion >= "1.2": - var osSet = initHashSet[string]() - var repoSet = initHashSet[string]() - for r in packageRepos: - osSet.incl(r.os) - repoSet.incl(r.repo) + let osSet = collect(initHashSet): + for r in packageRepos: + for x in r.os: + {x} + let repoSet = collect(initHashSet): + for r in packageRepos: + for x in r.repo: + {x} else: let osSet = lc[x | (r <- packageRepos, x <- r.os), string].toHashSet let repoSet = lc[x | (r <- packageRepos, x <- r.repo), string].toHashSet @@ -304,19 +307,11 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int references.filter(r => filterWith.filter(w => r.isProvidedBy(w, true)).len == 0) when NimVersion >= "1.2": -#[ let base = block: - let tmp = newSeq[string]() - for x in baseSeq[]: - if x.key == "pkgbase": - tmp.add(x.value) - tmp.optLast -]# - let base = block: - let tmp = collect(newSeq): + let base = optLast: + collect(newSeq): for x in baseSeq[]: if x.key == "pkgbase": x.value - tmp.optLast else: let base = lc[x.value | (x <- baseSeq[], x.key == "pkgbase"), string].optLast @@ -324,17 +319,11 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int let release = kcollect(true, "pkgrel").optLast let epoch = kcollect(true, "epoch").optLast when NimVersion >= "1.2": - #tmp = newSeq[string]() - #for v in version: - #for r in release: - #tmp.add(v & "-" & r) - #let versionFull = tmp.optLast.map(v => epoch.map(e => e & ":" & v).get(v)) - let versionFull = block: - let tmp = collect(newSeq): - for v in version: - for r in release: - (v & "-" & r) - tmp.optLast.map(v => epoch.map(e => e & ":" & v).get(v)) + let versionFull = (block:collect(newSeq): + for v in version: + for r in release: + (v & "-" & r) + ).optLast.map(v => epoch.map(e => e & ":" & v).get(v)) else: let versionFull = lc[(v & "-" & r) | (v <- version, r <- release), string].optLast .map(v => epoch.map(e => e & ":" & v).get(v)) @@ -360,8 +349,8 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int let info = rpcInfos.filter(i => i.name == name).optLast when NimVersion >= "1.2": - block: - let tmp = collect(newSeq): + optLast: + collect(newSeq): for b in base: for v in versionFull: ((repo, b, name, v, description, info.map(i => i.maintainer).flatten, @@ -370,7 +359,6 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int info.map(i => i.popularity).get(0), gitUrl, gitSubdir), baseIndex, baseCount, archs, url, licenses, groups, pgpKeys, depends, makeDepends, checkDepends, optional, provides, conflicts, replaces) - tmp.optLast else: lc[((repo, b, name, v, description, info.map(i => i.maintainer).flatten, info.map(i => i.firstSubmitted).flatten, info.map(i => i.lastModified).flatten, diff --git a/src/pacman.nim b/src/pacman.nim index 1b9d2f9..f9fc978 100644 --- a/src/pacman.nim +++ b/src/pacman.nim @@ -301,15 +301,15 @@ proc checkConflicts*(args: seq[Argument], template full(s: string): OptionPair = table[s][0] when NimVersion >= "1.3.5": - (block:collect(newSeq): + optFirst: + collect(newSeq): for c in conflicts: if args.check(c.left.full): for w in c.right: if args.check(w.full): (c.left,w) - ).optFirst elif NimVersion >= "1.2": - (block: + optFirst: var tmp = newSeq[(string,string)]() for c in conflicts: if args.check(c.left.full): @@ -317,8 +317,6 @@ proc checkConflicts*(args: seq[Argument], if args.check(w.full): tmp.add((c.left,w)) tmp - ).optFirst - else: lc[(c.left, w) | (c <- conflicts, args.check(c.left.full), w <- c.right, args.check(w.full)), (string, string)].optFirst -- cgit v1.2.3-70-g09d2 From 29e12415d4bae7a08fa9f3024d809b5a3be76ba1 Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Tue, 4 Aug 2020 23:51:40 +0100 Subject: refactored collect proc to collectName to not shadow sugar macro --- src/package.nim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/package.nim b/src/package.nim index 340f359..3014cba 100644 --- a/src/package.nim +++ b/src/package.nim @@ -289,8 +289,8 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int x.value else: lc[x.value | (x <- pairs, x.key == keyName), string] - - proc kcollect(baseOnly: bool, keyName: string): seq[string] = + #changed the name as shadows collect macro from sugar + proc collectName(baseOnly: bool, keyName: string): seq[string] = let res = if baseOnly: @[] else: collectFromPairs(nameSeq[], keyName) if res.len == 0: collectFromPairs(baseSeq[], keyName).filter(x => x.len > 0) @@ -298,7 +298,7 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int res.filter(x => x.len > 0) proc collectArch(baseOnly: bool, keyName: string): seq[PackageReference] = - (kcollect(baseOnly, keyName) & kcollect(baseOnly, keyName & "_" & arch)) + (collectName(baseOnly, keyName) & collectName(baseOnly, keyName & "_" & arch)) .map(n => parsePackageReference(n, true)) .filter(c => c.name.len > 0) @@ -315,9 +315,9 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int else: let base = lc[x.value | (x <- baseSeq[], x.key == "pkgbase"), string].optLast - let version = kcollect(true, "pkgver").optLast - let release = kcollect(true, "pkgrel").optLast - let epoch = kcollect(true, "epoch").optLast + let version = collectName(true, "pkgver").optLast + let release = collectName(true, "pkgrel").optLast + let epoch = collectName(true, "epoch").optLast when NimVersion >= "1.2": let versionFull = (block:collect(newSeq): for v in version: @@ -328,12 +328,12 @@ proc parseSrcInfoName(repo: string, name: string, baseIndex: int, baseCount: int let versionFull = lc[(v & "-" & r) | (v <- version, r <- release), string].optLast .map(v => epoch.map(e => e & ":" & v).get(v)) - let description = kcollect(false, "pkgdesc").optLast - let archs = kcollect(false, "arch").filter(a => a != "any") - let url = kcollect(false, "url").optLast - let licenses = kcollect(false, "license") - let groups = kcollect(false, "groups") - let pgpKeys = kcollect(true, "validpgpkeys") + let description = collectName(false, "pkgdesc").optLast + let archs = collectName(false, "arch").filter(a => a != "any") + let url = collectName(false, "url").optLast + let licenses = collectName(false, "license") + let groups = collectName(false, "groups") + let pgpKeys = collectName(true, "validpgpkeys") let baseDepends = collectArch(true, "depends") let depends = collectArch(false, "depends") -- cgit v1.2.3-70-g09d2