summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9cefeee8f1adc35624b14fc7473e36ad776f31bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Maintainer: Caleb Maclennan <caleb@alerque.com>

_npmname=sqlite3
pkgname="nodejs-$_npmname"
pkgver=5.0.2
pkgrel=1
pkgdesc='Asynchronous, non-blocking SQLite3 bindings'
arch=('x86_64')
url="https://github.com/mapbox/${pkgname/js-/-}"
license=('GPL3')
depends=('nodejs' 'nodejs-node-pre-gyp')
makedepends=('jq' 'moreutils' 'npm')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('39ce61088a0c51e41e9d8dee59db98f1cf043104a0d78650e67253ef161cfe81')

prepare() {
    cd "${pkgname/js}-$pkgver"
    jq 'del(.dependencies["node-pre-gyp"])' package.json |
        sponge package.json
}

build() {
    cd "${pkgname/js}-$pkgver"
    npm pack
}

package() {
    cd "${pkgname/js}-$pkgver"
    npm install --production --build-from-source -g --user root --cache "$srcdir/npm-cache" --prefix "$pkgdir/usr" $_npmname-$pkgver.tgz
    find "$pkgdir"/usr -type d -exec chmod 755 {} +
    find "$pkgdir" -type f -name package.json \
        -execdir sh -c "jq '. |= with_entries(select(.key | test(\"_.+\") | not))' {} | sponge {}" \;
    chown -R root:root "$pkgdir"
}