summarylogtreecommitdiffstats
path: root/PKGBUILD
diff options
context:
space:
mode:
authorCaleb Maclennan2020-10-03 19:00:51 +0300
committerCaleb Maclennan2020-10-03 19:06:44 +0300
commit7d672b8ff80aa56fc73ee0ec99a6a314e8ea95da (patch)
tree753250a454fa34366ce81b4278a3926280d052d4 /PKGBUILD
parent038b3db810e4a825351f6ac1879f2e044a72ff17 (diff)
downloadaur-lua-discount.tar.gz
Fix dependencies and overhaul PKGBUILD scripting
This fixes a number of oversights and (in my opinion) makes it a lot easier to maintain because of simpler scripting (more advanced use of shell function for less copied code, etc.). * Fix completely missing dependencies, both build time and run time. Build time needs all Lua targets, run time needs only matching Lua versions. * Use `luarocks` argument to avoid root manifests rather than removing them after the fact. * Do not repeat code, use re-usable functions (following Arch packaging convention for private namespace) * Don't bother with unnecessary code like testing for a file, removing it, then linking it when a force copy will do (a force link would work, but could cause problems later if we ever have to introduce patches). * Use `shellharden` to confirm and normalize shell quoting issues. Not always my favorite style but at least its consistent.
Diffstat (limited to 'PKGBUILD')
-rw-r--r--PKGBUILD98
1 files changed, 51 insertions, 47 deletions
diff --git a/PKGBUILD b/PKGBUILD
index b0ebaad1577..f3556c816fb 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,73 +1,77 @@
# Maintainer: Dimitris Kiziridis <ragouel at outlook dot com>
+# Maintainer: Caleb Maclennan <caleb@alerque.com>
-pkgname=('lua-discount' 'lua51-discount' 'lua52-discount' 'lua53-discount')
+_rockname=discount
+pkgbase=lua-$_rockname
+pkgname=("lua-$_rockname" "lua53-$_rockname" "lua52-$_rockname" "lua51-$_rockname")
pkgver=0.4
-pkgrel=1
-pkgdesc="Lua bindings for the Discount Markdown library"
+_rockrel=1
+pkgrel=2
+pkgdesc='Lua bindings for the Discount Markdown library'
arch=('x86_64')
-url='https://github.com/craigbarnes/lua-discount'
+url="https://github.com/craigbarnes/$pkgbase"
license=('ISC')
depends=('discount')
-makedepends=('luarocks')
-source=("https://github.com/craigbarnes/lua-discount/archive/${pkgver}.tar.gz"
- "https://luarocks.org/manifests/craigb/discount-${pkgver}-1.rockspec"
- 'LICENSE::https://github.com/craigbarnes/lua-discount/raw/master/LICENSE')
+makedepends=('lua' 'lua53' 'lua52' 'lua51' 'luarocks')
+source=("$url/archive/$pkgver.tar.gz"
+ "https://luarocks.org/manifests/craigb/$_rockname-$pkgver-$_rockrel.rockspec"
+ "LICENSE::$url/raw/master/LICENSE")
sha256sums=('3531eeddde4a89d5b7a4ab9b359a7f01a88ac85dd4fac61554eb199165cfdead'
'edb216e8a28534f18d8950779b50dab083c8f339eaed90b68814b97c27af8255'
'8b2fffc6b27a33bf6958a2a2293ce19ce5cbd7206ccb6dda7a9d3abe6f80c9fa')
prepare() {
- if [[ -f "${srcdir}/lua-discount-${pkgver}/discount-${pkgver}-1.rockspec" ]]; then
- rm "${srcdir}/lua-discount-${pkgver}/discount-${pkgver}-1.rockspec"
- fi
- ln -s "${srcdir}/discount-${pkgver}-1.rockspec" "${srcdir}/lua-discount-${pkgver}/"
+ cp -f "$_rockname-$pkgver-$_rockrel.rockspec" "$pkgbase-$pkgver"
+}
+
+_build_helper() {
+ cd "$srcdir"
+ mkdir -p "$1"
+ cd "$1"
+ luarocks build \
+ --pack-binary-rock \
+ --lua-version="$1" \
+ --deps-mode=none \
+ "../$pkgname-$pkgver/$_rockname-$pkgver-$_rockrel.rockspec"
}
build() {
- mkdir -p 5.1 5.2 5.3 5.4
+ local luas="5.1 5.2 5.3 5.4"
+ for lua in "$luas"; do
+ _build_helper "$lua"
+ done
+}
- # Build for 5.1
- (cd 5.1; luarocks build --pack-binary-rock --lua-version=5.1 --deps-mode=none ../lua-discount-${pkgver}/"discount-$pkgver-1.rockspec")
- # Build for 5.2
- (cd 5.2; luarocks build --pack-binary-rock --lua-version=5.2 --deps-mode=none ../lua-discount-${pkgver}/"discount-$pkgver-1.rockspec")
- # Build for 5.3
- (cd 5.3; luarocks build --pack-binary-rock --lua-version=5.3 --deps-mode=none ../lua-discount-${pkgver}/"discount-$pkgver-1.rockspec")
- # Build for 5.4
- (cd 5.4; luarocks build --pack-binary-rock --lua-version=5.4 --deps-mode=none ../lua-discount-${pkgver}/"discount-$pkgver-1.rockspec")
+_package_helper() {
+ luarocks install \
+ --lua-version="$1" \
+ --tree="$pkgdir/usr/" \
+ --deps-mode=none \
+ --no-manifest \
+ "$1/$_rockname-$pkgver-$_rockrel.linux-x86_64.rock"
+ install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname/" "$srcdir/LICENSE"
}
package_lua-discount() {
- pkgdesc='Lua bindings for the Discount Markdown library for Lua 5.4'
-
- luarocks install --lua-version=5.4 --tree="$pkgdir/usr/" --deps-mode=none 5.4/*.rock
- install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
- # remove luarocks-created root manifest
- rm "$pkgdir/usr/lib/luarocks/rocks-5.4/manifest"
+ depends+=('lua')
+ pkgdesc+=' (for Lua 5.4)'
+ _package_helper 5.4
}
package_lua53-discount() {
- pkgdesc='Lua bindings for the Discount Markdown library for Lua 5.3'
+ depends+=('lua53')
+ pkgdesc+=' (for Lua 5.3)'
+ _package_helper 5.3
+}
- luarocks install --lua-version=5.3 --tree="$pkgdir/usr/" --deps-mode=none 5.3/*.rock
- install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
- # remove luarocks-created root manifest
- rm "$pkgdir/usr/lib/luarocks/rocks-5.3/manifest"
+package_lua52-discount() {
+ depends+=('lua52')
+ pkgdesc+=' (for Lua 5.2)'
+ _package_helper 5.2
}
package_lua51-discount() {
- pkgdesc='Lua bindings for the Discount Markdown library for Lua 5.1'
-
- luarocks install --lua-version=5.1 --tree="$pkgdir/usr/" --deps-mode=none 5.1/*.rock
- install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
- # remove luarocks-created root manifest
- rm "$pkgdir/usr/lib/luarocks/rocks-5.1/manifest"
+ depends+=('lua51')
+ pkgdesc+=' (for Lua 5.1)'
+ _package_helper 5.1
}
-
-package_lua52-discount() {
- pkgdesc='Lua bindings for the Discount Markdown library for Lua 5.2'
-
- luarocks install --lua-version=5.2 --tree="$pkgdir/usr/" --deps-mode=none 5.2/*.rock
- install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
- # remove luarocks-created root manifest
- rm "$pkgdir/usr/lib/luarocks/rocks-5.2/manifest"
-} \ No newline at end of file