summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Regan2020-11-22 16:57:34 -0500
committerJohn Regan2020-11-22 16:57:34 -0500
commit5c488023e70cc85af1e6b831972ec8021b6e57b1 (patch)
treec53678658d1dd8e32832ce4ba5cc32b2fe219b4f
downloadaur-5c488023e70cc85af1e6b831972ec8021b6e57b1.tar.gz
initial commit
-rw-r--r--.SRCINFO37
-rw-r--r--PKGBUILD66
-rw-r--r--pgmoon-lua53-compat.patch201
3 files changed, 304 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..32e4f13e1b5
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,37 @@
+pkgbase = lua-pgmoon
+ pkgver = 1.11.0
+ pkgrel = 1
+ url = https://github.com/leafo/pgmoon
+ arch = any
+ license = MIT
+ source = lua-pgmoon-1.11.0.tar.gz::https://github.com/leafo/pgmoon/archive/v1.11.0.tar.gz
+ source = pgmoon-lua53-compat.patch
+ md5sums = fbfa084ff9947b1d2552357dde2e25c8
+ md5sums = e683cd2c12733563ab192283095fdb79
+
+pkgname = lua-pgmoon
+ pkgdesc = PostgreSQL driver written in pure Lua for Lua 5.4
+ depends = lua-lpeg
+ optdepends = lua-cqueues: asynchronous connectivity
+ optdepends = lua-socket: synchronous connectivity
+
+pkgname = lua51-pgmoon
+ pkgdesc = PostgreSQL driver written in pure Lua for Lua 5.1
+ depends = lua-lpeg
+ depends = lua51-bitop
+ optdepends = lua-cqueues: asynchronous connectivity
+ optdepends = lua-socket: synchronous connectivity
+
+pkgname = lua52-pgmoon
+ pkgdesc = PostgreSQL driver written in pure Lua for Lua 5.2
+ depends = lua-lpeg
+ depends = lua52-bitop
+ optdepends = lua-cqueues: asynchronous connectivity
+ optdepends = lua-socket: synchronous connectivity
+
+pkgname = lua53-pgmoon
+ pkgdesc = PostgreSQL driver written in pure Lua for Lua 5.3
+ depends = lua-lpeg
+ optdepends = lua-cqueues: asynchronous connectivity
+ optdepends = lua-socket: synchronous connectivity
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..3c97e601554
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,66 @@
+# Maintainer: jprjr <john@jrjrtech.com>
+
+pkgname=('lua-pgmoon' 'lua51-pgmoon' 'lua52-pgmoon' 'lua53-pgmoon')
+_pkgbase='pgmoon'
+pkgver=1.11.0
+pkgrel=1
+arch=('any')
+url='https://github.com/leafo/pgmoon'
+license=('MIT')
+source=("$pkgname-$pkgver.tar.gz::https://github.com/leafo/pgmoon/archive/v$pkgver.tar.gz"
+"${_pkgbase}-lua53-compat.patch")
+md5sums=('fbfa084ff9947b1d2552357dde2e25c8'
+'e683cd2c12733563ab192283095fdb79')
+
+prepare() {
+ cd "${_pkgbase}-$pkgver"
+ patch --forward --strip=1 --input="${srcdir}/${_pkgbase}-lua53-compat.patch"
+}
+
+package_lua-pgmoon() {
+ pkgdesc='PostgreSQL driver written in pure Lua for Lua 5.4'
+ depends=('lua-lpeg')
+ optdepends=('lua-cqueues: asynchronous connectivity'
+ 'lua-socket: synchronous connectivity')
+
+ cd "pgmoon-$pkgver"
+ install -Dm644 pgmoon.lua "$pkgdir/usr/share/lua/5.4/pgmoon.lua"
+ install -Dm644 pgmoon/*.lua -t "$pkgdir/usr/share/lua/5.4/pgmoon"
+ install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
+
+package_lua51-pgmoon() {
+ pkgdesc='PostgreSQL driver written in pure Lua for Lua 5.1'
+ depends=('lua-lpeg' 'lua51-bitop')
+ optdepends=('lua-cqueues: asynchronous connectivity'
+ 'lua-socket: synchronous connectivity')
+
+ cd "pgmoon-$pkgver"
+ install -Dm644 pgmoon.lua "$pkgdir/usr/share/lua/5.1/pgmoon.lua"
+ install -Dm644 pgmoon/*.lua -t "$pkgdir/usr/share/lua/5.1/pgmoon"
+ install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
+
+package_lua52-pgmoon() {
+ pkgdesc='PostgreSQL driver written in pure Lua for Lua 5.2'
+ depends=('lua-lpeg' 'lua52-bitop')
+ optdepends=('lua-cqueues: asynchronous connectivity'
+ 'lua-socket: synchronous connectivity')
+
+ cd "pgmoon-$pkgver"
+ install -Dm644 pgmoon.lua "$pkgdir/usr/share/lua/5.2/pgmoon.lua"
+ install -Dm644 pgmoon/*.lua -t "$pkgdir/usr/share/lua/5.2/pgmoon"
+ install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
+
+package_lua53-pgmoon() {
+ pkgdesc='PostgreSQL driver written in pure Lua for Lua 5.3'
+ depends=('lua-lpeg')
+ optdepends=('lua-cqueues: asynchronous connectivity'
+ 'lua-socket: synchronous connectivity')
+
+ cd "pgmoon-$pkgver"
+ install -Dm644 pgmoon.lua "$pkgdir/usr/share/lua/5.3/pgmoon.lua"
+ install -Dm644 pgmoon/*.lua -t "$pkgdir/usr/share/lua/5.3/pgmoon"
+ install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
diff --git a/pgmoon-lua53-compat.patch b/pgmoon-lua53-compat.patch
new file mode 100644
index 00000000000..93db22df41f
--- /dev/null
+++ b/pgmoon-lua53-compat.patch
@@ -0,0 +1,201 @@
+diff --git a/pgmoon-dev-1.rockspec b/pgmoon-dev-1.rockspec
+index 52f505e..f672764 100644
+--- a/pgmoon-dev-1.rockspec
++++ b/pgmoon-dev-1.rockspec
+@@ -15,7 +15,6 @@ description = {
+
+ dependencies = {
+ "lua >= 5.1",
+- "luabitop",
+ "lpeg",
+ }
+
+@@ -24,6 +23,7 @@ build = {
+ modules = {
+ ["pgmoon"] = "pgmoon/init.lua",
+ ["pgmoon.arrays"] = "pgmoon/arrays.lua",
++ ["pgmoon.bit"] = "pgmoon/bit.lua",
+ ["pgmoon.cqueues"] = "pgmoon/cqueues.lua",
+ ["pgmoon.crypto"] = "pgmoon/crypto.lua",
+ ["pgmoon.hstore"] = "pgmoon/hstore.lua",
+diff --git a/pgmoon/bit.lua b/pgmoon/bit.lua
+new file mode 100644
+index 0000000..102f944
+--- /dev/null
++++ b/pgmoon/bit.lua
+@@ -0,0 +1,55 @@
++local rshift, lshift, band, ok, _
++local string_loader
++string_loader = function(str)
++ local sent = false
++ return function()
++ if sent then
++ return nil
++ end
++ sent = true
++ return str
++ end
++end
++ok, band = pcall(load(string_loader([[ return function(a,b)
++ a = a & b
++ if a > 0x7FFFFFFF then
++ -- extend the sign bit
++ a = ~0xFFFFFFFF | a
++ end
++ return a
++ end
++]])))
++if ok then
++ _, lshift = pcall(load(string_loader([[ return function(x,y)
++ -- limit to 32-bit shifts
++ y = y % 32
++ x = x << y
++ if x > 0x7FFFFFFF then
++ -- extend the sign bit
++ x = ~0xFFFFFFFF | x
++ end
++ return x
++ end
++ ]])))
++ _, rshift = pcall(load(string_loader([[ return function(x,y)
++ y = y % 32
++ -- truncate to 32-bit before applying shift
++ x = x & 0xFFFFFFFF
++ x = x >> y
++ if x > 0x7FFFFFFF then
++ x = ~0xFFFFFFFF | x
++ end
++ return x
++ end
++ ]])))
++else
++ do
++ local _obj_0 = require("bit")
++ rshift, lshift, band = _obj_0.rshift, _obj_0.lshift, _obj_0.band
++ end
++end
++return {
++ rshift = rshift,
++ lshift = lshift,
++ band = band
++}
+diff --git a/pgmoon/bit.moon b/pgmoon/bit.moon
+new file mode 100644
+index 0000000..f2a2cc6
+--- /dev/null
++++ b/pgmoon/bit.moon
+@@ -0,0 +1,70 @@
++local rshift, lshift, band, ok, _
++local string_loader
++
++
++-- lua5.1 has separate 'loadstring' and 'load'
++-- functions ('load' doesn't accept strings).
++-- This provides a function that 'load' can use,
++-- and will work on all versions of lua
++
++string_loader = (str) ->
++ sent = false
++ return ->
++ if sent then
++ return nil
++ sent = true
++ return str
++
++
++-- use load to treat as a string to prevent
++-- parse errors under lua < 5.3
++
++-- luajit uses 32-bit integers for bitwise ops, but lua5.3+
++-- uses 32-bit or 64-bit integers, so these wrappers will
++-- truncate results and/or extend the sign, as appropriate
++-- to match luajit's behavior.
++ok, band = pcall(load(string_loader([[
++ return function(a,b)
++ a = a & b
++ if a > 0x7FFFFFFF then
++ -- extend the sign bit
++ a = ~0xFFFFFFFF | a
++ end
++ return a
++ end
++]])))
++
++if ok then
++ _, lshift = pcall(load(string_loader([[
++ return function(x,y)
++ -- limit to 32-bit shifts
++ y = y % 32
++ x = x << y
++ if x > 0x7FFFFFFF then
++ -- extend the sign bit
++ x = ~0xFFFFFFFF | x
++ end
++ return x
++ end
++ ]])))
++ _, rshift = pcall(load(string_loader([[
++ return function(x,y)
++ y = y % 32
++ -- truncate to 32-bit before applying shift
++ x = x & 0xFFFFFFFF
++ x = x >> y
++ if x > 0x7FFFFFFF then
++ x = ~0xFFFFFFFF | x
++ end
++ return x
++ end
++ ]])))
++else
++ import rshift, lshift, band from require "bit"
++
++return {
++ rshift: rshift
++ lshift: lshift
++ band: band
++}
++
+diff --git a/pgmoon/init.lua b/pgmoon/init.lua
+index 4ebe466..9dce4c3 100644
+--- a/pgmoon/init.lua
++++ b/pgmoon/init.lua
+@@ -3,7 +3,7 @@ local insert
+ insert = table.insert
+ local rshift, lshift, band
+ do
+- local _obj_0 = require("bit")
++ local _obj_0 = require("pgmoon.bit")
+ rshift, lshift, band = _obj_0.rshift, _obj_0.lshift, _obj_0.band
+ end
+ local unpack = table.unpack or unpack
+@@ -362,7 +362,7 @@ do
+ local command, affected_rows
+ if command_complete then
+ command = command_complete:match("^%w+")
+- affected_rows = tonumber(command_complete:match("%d+%z$"))
++ affected_rows = tonumber(command_complete:match("(%d+)%z$"))
+ end
+ if row_desc then
+ if not (data_rows) then
+diff --git a/pgmoon/init.moon b/pgmoon/init.moon
+index c9f91a4..a21641d 100644
+--- a/pgmoon/init.moon
++++ b/pgmoon/init.moon
+@@ -1,6 +1,7 @@
+ socket = require "pgmoon.socket"
+ import insert from table
+-import rshift, lshift, band from require "bit"
++
++import rshift, lshift, band from require "pgmoon.bit"
+
+ unpack = table.unpack or unpack
+
+@@ -330,7 +331,7 @@ class Postgres
+
+ if command_complete
+ command = command_complete\match "^%w+"
+- affected_rows = tonumber command_complete\match "%d+%z$"
++ affected_rows = tonumber command_complete\match "(%d+)%z$"
+
+ if row_desc
+ return {} unless data_rows