aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkitsunyan2019-12-20 04:35:07 +0000
committerkitsunyan2019-12-20 04:35:07 +0000
commit90d4c4be3bc15b2f594a0046c07b6f8654659ad5 (patch)
tree89a79ffa58b086e5211473bb8633f5344e39000f
parenta25e544b717edab821779b4e7d978e8bf24debcb (diff)
Add Nim 1.0 support
-rw-r--r--Makefile5
-rw-r--r--lib/bisect.nim5
-rw-r--r--lib/install.nim5
-rw-r--r--lib/tools.nim5
-rw-r--r--src/args.nim2
-rw-r--r--src/aur.nim2
-rw-r--r--src/common.nim2
-rw-r--r--src/config.nim2
-rw-r--r--src/feature/localquery.nim2
-rw-r--r--src/feature/syncclean.nim5
-rw-r--r--src/feature/syncinfo.nim2
-rw-r--r--src/feature/syncinstall.nim2
-rw-r--r--src/feature/syncsearch.nim2
-rw-r--r--src/feature/syncsource.nim4
-rw-r--r--src/format.nim10
-rw-r--r--src/lists.nim2
-rw-r--r--src/main.nim2
-rw-r--r--src/package.nim8
-rw-r--r--src/pacman.nim4
-rw-r--r--src/utils.nim10
20 files changed, 40 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index a4ace3c..a390d25 100644
--- a/Makefile
+++ b/Makefile
@@ -27,10 +27,7 @@ DIST = \
completion/zsh-git.patch \
doc/asciidoc.conf \
${MAN_PAGES:=.txt} \
- lib/*.nim \
- src/*.nim \
- src/feature/*.nim \
- src/wrapper/*.nim
+ $(shell find src lib -type f -name '*.nim')
EXTRA_DIST = \
${MAN_PAGES:=.in}
diff --git a/lib/bisect.nim b/lib/bisect.nim
index ea4063c..3dad8b2 100644
--- a/lib/bisect.nim
+++ b/lib/bisect.nim
@@ -1,4 +1,5 @@
-import future, osproc, strutils
+import
+ osproc, strutils
{.passL: "-lalpm".}
@@ -6,7 +7,7 @@ proc vercmp(a: cstring, b: cstring): cint
{.cdecl, importc: "alpm_pkg_vercmp".}
proc getSourceVersion(relativePath: string): seq[string] =
- let lines = execProcess("/bin/bash", ["-c",
+ let lines = execProcess("/bin/bash", "", ["-c",
"""source "$1/PKGBUILD" && echo "$epoch" && echo "$pkgver" && echo "$pkgrel"""",
"bash", relativePath], options = {}).split("\n")
if lines.len == 4:
diff --git a/lib/install.nim b/lib/install.nim
index 03bebd5..5130acf 100644
--- a/lib/install.nim
+++ b/lib/install.nim
@@ -1,4 +1,5 @@
-import future, os, posix, sequtils, strutils
+import
+ os, posix, sequtils, strutils, sugar
proc splitCommands(params: seq[string], index: int, res: seq[seq[string]]): seq[seq[string]] =
if index < params.len:
@@ -53,7 +54,7 @@ proc handleInstall*(params: seq[string]): int =
let packages = params[databaseIndex .. ^1]
if packages.len /% 3 * 3 != packages.len:
- raise newException(SystemError, "invalid arguments")
+ raise newException(CatchableError, "invalid arguments")
let install: seq[tuple[name: string, file: string, mode: string]] = packages
.distribute(packages.len /% 3)
diff --git a/lib/tools.nim b/lib/tools.nim
index 82cafff..e6c2b15 100644
--- a/lib/tools.nim
+++ b/lib/tools.nim
@@ -1,5 +1,6 @@
-import os, ospaths
-import bisect, install
+import
+ os,
+ bisect, install
let fileName = paramStr(0).splitFile().name
let appName = getAppFilename().splitFile().name
diff --git a/src/args.nim b/src/args.nim
index 5a3bd04..5018b12 100644
--- a/src/args.nim
+++ b/src/args.nim
@@ -1,5 +1,5 @@
import
- future, options, os, posix, sequtils, sets, strutils,
+ options, os, posix, sequtils, sets, strutils, sugar,
utils
type
diff --git a/src/aur.nim b/src/aur.nim
index f4d6c91..781029c 100644
--- a/src/aur.nim
+++ b/src/aur.nim
@@ -1,5 +1,5 @@
import
- future, json, lists, options, re, sequtils, sets, strutils, tables,
+ json, lists, options, re, sequtils, sets, strutils, sugar, tables,
package, utils,
"wrapper/curl"
diff --git a/src/common.nim b/src/common.nim
index 8be51f8..6b436b4 100644
--- a/src/common.nim
+++ b/src/common.nim
@@ -1,5 +1,5 @@
import
- future, options, os, osproc, posix, sequtils, sets, strutils, tables,
+ options, os, osproc, posix, sequtils, sets, strutils, sugar, tables,
args, config, format, lists, package, pacman, utils,
"wrapper/alpm"
diff --git a/src/config.nim b/src/config.nim
index ade174f..d9caf5e 100644
--- a/src/config.nim
+++ b/src/config.nim
@@ -1,5 +1,5 @@
import
- future, options, posix, re, sequtils, sets, strutils, tables,
+ options, posix, re, sequtils, sets, strutils, sugar, tables,
utils
type
diff --git a/src/feature/localquery.nim b/src/feature/localquery.nim
index 4a21fa9..1d58bdc 100644
--- a/src/feature/localquery.nim
+++ b/src/feature/localquery.nim
@@ -1,5 +1,5 @@
import
- algorithm, future, options, sequtils, sets, strutils, tables,
+ algorithm, options, sequtils, sets, strutils, sugar, tables,
"../args", "../common", "../config", "../format", "../package", "../pacman", "../utils",
"../wrapper/alpm"
diff --git a/src/feature/syncclean.nim b/src/feature/syncclean.nim
index 2e57908..6b1f853 100644
--- a/src/feature/syncclean.nim
+++ b/src/feature/syncclean.nim
@@ -1,7 +1,6 @@
import
- future, options, os, posix, sequtils, strutils, tables,
- "../args", "../aur", "../common", "../config", "../format", "../lists",
- "../package", "../pacman", "../utils",
+ options, os, posix, strutils,
+ "../args", "../common", "../config", "../format", "../pacman", "../utils",
"../wrapper/alpm"
proc handleSyncClean*(args: seq[Argument], config: Config): int =
diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim
index 9bee287..4f758fe 100644
--- a/src/feature/syncinfo.nim
+++ b/src/feature/syncinfo.nim
@@ -1,5 +1,5 @@
import
- future, options, posix, sequtils, strutils, tables, times,
+ options, posix, sequtils, strutils, sugar, tables,
"../args", "../aur", "../common", "../config", "../format", "../package",
"../pacman", "../utils",
"../wrapper/alpm"
diff --git a/src/feature/syncinstall.nim b/src/feature/syncinstall.nim
index 1f079ee..fef4f82 100644
--- a/src/feature/syncinstall.nim
+++ b/src/feature/syncinstall.nim
@@ -1,5 +1,5 @@
import
- algorithm, future, options, os, posix, sequtils, sets, strutils, tables,
+ algorithm, options, os, posix, sequtils, sets, strutils, sugar, tables,
"../args", "../aur", "../config", "../common", "../format", "../lists", "../package",
"../pacman", "../utils",
"../wrapper/alpm"
diff --git a/src/feature/syncsearch.nim b/src/feature/syncsearch.nim
index 3d4cd0f..b20109f 100644
--- a/src/feature/syncsearch.nim
+++ b/src/feature/syncsearch.nim
@@ -1,5 +1,5 @@
import
- algorithm, future, options, sequtils, strutils,
+ algorithm, options, sequtils, strutils, sugar,
"../args", "../aur", "../config", "../common", "../format", "../package",
"../pacman", "../utils",
"../wrapper/alpm"
diff --git a/src/feature/syncsource.nim b/src/feature/syncsource.nim
index b080aff..c050e6a 100644
--- a/src/feature/syncsource.nim
+++ b/src/feature/syncsource.nim
@@ -1,5 +1,5 @@
import
- future, options, os, posix, sequtils, strutils, tables,
+ options, os, posix, sequtils, strutils, sugar, tables,
"../args", "../aur", "../common", "../config", "../format", "../lists",
"../package", "../pacman", "../utils",
"../wrapper/alpm"
@@ -145,7 +145,7 @@ proc cloneAndCopy(config: Config, quiet: bool, fullTargets: seq[FullPackageTarge
removeDirQuiet(result.path)
discard rmdir(config.tmpRootCurrent)
- if rerrors != nil and cerrors != nil:
+ if rerrors.len > 0 or cerrors != nil:
1
else:
0
diff --git a/src/format.nim b/src/format.nim
index f20eaf7..2ac39dc 100644
--- a/src/format.nim
+++ b/src/format.nim
@@ -1,5 +1,5 @@
import
- future, macros, options, posix, sequtils, strutils, times, unicode,
+ macros, options, posix, sequtils, strutils, sugar, times, unicode,
utils
type
@@ -94,8 +94,8 @@ proc splitLines(text: string, lineSize: int, lines: seq[string] = @[]): seq[stri
if index < 0:
lines & text
else:
- text[index .. ^1].strip.splitLines(lineSize,
- lines & text[0 .. index - 1].strip)
+ strutils.strip(text[index .. ^1]).splitLines(lineSize,
+ lines & strutils.strip(text[0 .. index - 1]))
proc printPackageInfo*(minPadding: int, color: bool, lines: varargs[PackageLineFormat]) =
let width = getWindowSize().width
@@ -108,9 +108,9 @@ proc printPackageInfo*(minPadding: int, color: bool, lines: varargs[PackageLineF
if values.len == 0:
@[]
elif forceBreak:
- lc[x | (y <- values.map(s => s.strip.splitLines(lineSize)), x <- y), string]
+ lc[x | (y <- values.map(s => strutils.strip(s).splitLines(lineSize)), x <- y), string]
else:
- values.map(v => v.strip).foldl(a & " " & b).splitLines(lineSize)
+ values.map(v => strutils.strip(v)).foldl(a & " " & b).splitLines(lineSize)
proc formatText(values: seq[string], forceBreak: bool): string =
let textSeq = formatTextLines(values, forceBreak)
diff --git a/src/lists.nim b/src/lists.nim
index cf1b0c5..b62aa3c 100644
--- a/src/lists.nim
+++ b/src/lists.nim
@@ -42,7 +42,7 @@ static:
template testList[T](list: List[T], testSeq: openArray[T]) =
block:
let s = toSeq(list.items)
- if s != @testSeq: raise newException(SystemError, "list: " & $s)
+ if s != @testSeq: raise newException(CatchableError, "list: " & $s)
let l1 = list[int]()
testList(l1, [])
diff --git a/src/main.nim b/src/main.nim
index 9508b33..92e8887 100644
--- a/src/main.nim
+++ b/src/main.nim
@@ -1,5 +1,5 @@
import
- future, options, os, posix, re, sequtils, strutils,
+ options, os, posix, re, sequtils, strutils, sugar,
args, config, format, pacman, utils
import
diff --git a/src/package.nim b/src/package.nim
index 0534234..5f31ede 100644
--- a/src/package.nim
+++ b/src/package.nim
@@ -1,5 +1,5 @@
import
- future, options, os, re, sequtils, sets, strutils, tables, utils,
+ options, os, re, sequtils, sets, strutils, sugar, tables, utils,
"wrapper/alpm"
type
@@ -98,7 +98,7 @@ static:
let osValue = os
let repoValue = repo
if packageRepos.filter(pr => osValue in pr.os and repoValue in pr.repo).len >= 2:
- raise newException(SystemError,
+ raise newException(CatchableError,
"only single matching repo available: " & os & ":" & repo)
# test unique url <> bareName links
@@ -111,9 +111,9 @@ static:
for x1, x2 in m1:
try:
if m2[x2] != x1:
- raise newException(SystemError, "")
+ raise newException(CatchableError, "")
except:
- raise newException(SystemError, "Invalid url <> bareName links")
+ raise newException(CatchableError, "Invalid url <> bareName links")
testBareNamesAndUrls(bareNameToUrl, urlToBareName)
testBareNamesAndUrls(urlToBareName, bareNameToUrl)
diff --git a/src/pacman.nim b/src/pacman.nim
index 9ee692d..b58482c 100644
--- a/src/pacman.nim
+++ b/src/pacman.nim
@@ -1,5 +1,5 @@
import
- future, macros, options, os, posix, re, sequtils, sets, strutils, tables,
+ macros, options, posix, sequtils, sets, strutils, sugar, tables,
args, config, utils
type
@@ -251,7 +251,7 @@ static:
# conflicting options test
for name, pairs in allConflictingOptions.obtainConflictsPairs:
if pairs.len != 1:
- raise newException(SystemError,
+ raise newException(CatchableError,
"invalid conflicts definition: " & name & " " & $pairs)
proc checkConflicts*(args: seq[Argument],
diff --git a/src/utils.nim b/src/utils.nim
index 748e1e8..8ca68d4 100644
--- a/src/utils.nim
+++ b/src/utils.nim
@@ -1,5 +1,5 @@
import
- future, hashes, options, os, osproc, posix, sequtils, strutils, tables
+ hashes, options, os, posix, sequtils, strutils, sugar, tables
type
HaltError* = object of Exception
@@ -219,12 +219,12 @@ proc getUser(uid: int): User =
var pw = getpwent()
if pw == nil:
endpwent()
- raise newException(SystemError, "")
+ raise newException(CatchableError, "")
if pw.pw_uid.int == uid:
var groups: array[100, cint]
var ngroups: cint = 100
if getgrouplist(pw.pw_name, pw.pw_gid, addr(groups[0]), ngroups) < 0:
- raise newException(SystemError, "")
+ raise newException(CatchableError, "")
else:
let groupsSeq = groups[0 .. ngroups - 1].map(x => x.int)
let res = ($pw.pw_name, pw.pw_uid.int, pw.pw_gid.int, groupsSeq,
@@ -287,7 +287,7 @@ proc dropPrivileges*(): bool =
proc checkExec(file: string): bool =
var statv: Stat
- stat(file, statv) == 0 and (statv.st_mode and S_IXUSR) == S_IXUSR
+ stat(file, statv) == 0 and (statv.st_mode.cint and S_IXUSR) == S_IXUSR
let sudoPrefix*: seq[string] = if checkExec(sudoCmd):
@[sudoCmd]
@@ -343,7 +343,7 @@ proc bashEscape*(s: string): string =
elif c == "\n"[0]:
result &= "$'\\n'"
elif c.cuint < 0x20.cuint or c.cuint > 0x80.cuint:
- result &= "$'\\0x" & c.toHex & "'"
+ result &= "$'\\0x" & c.uint8.toHex & "'"
else:
result &= c