summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5fb3dc244afa9e8203fcde04824f3a2d1c7a5bdd (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Maintainer: envolution

pkgname=libsql-sqlite3
_altname=libsqlite3 #what do we call this to not conflict with core/sqlite ?
_pkgname=libsql
pkgver=0.24.28
pkgrel=3
pkgdesc='libsql sqlite3 compatibility libraries and executables'
url='https://turso.tech/libsql'
license=(MIT)
makedepends=('cargo')
#This does not play well as a sqlite3 replacement
#if thic changes in future, the initial PKGBUILD can be used
#provides=(sqlite sqlite3 'libsqlite3.so')
#conflicts=(sqlite3)
arch=('i686' 'x86_64')
source=("https://github.com/tursodatabase/libsql/archive/refs/tags/libsql-server-v${pkgver}.tar.gz")
b2sums=('ff520abc812e0f85663b9e683954066808cb6d576424c456fdae95dce76d471f3176cd7d9c0af6a55e00c20b307e64276ce831c2710e5f78908eb958fafb532c')

_pkgdir="${_pkgname}-libsql-server-v${pkgver}"
prepare() {
  cd $_pkgdir
  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
  cd $_pkgdir
  export CARGO_TARGET_DIR=target
  export RUSTUP_TOOLCHAIN=stable
  cargo xtask build --frozen --release
}

package() {
  pkgdesc="A compatibility binary for SQLite3 using libsql"

  cd "$_pkgdir/libsql-sqlite3"

  # Install binaries
  install -Dm755 sqlite3 "$pkgdir/usr/bin/${_altname}"

  # Install libraries
  install -dm755 "$pkgdir/usr/lib/${_altname}"
  find .libs -name '*.so' -exec install -Dm755 {} "$pkgdir/usr/lib/${_altname}/" \;
  find .libs -name '*.a' -exec install -Dm644 {} "$pkgdir/usr/lib/${_altname}/" \;
  install -Dm644 *.la "$pkgdir/usr/lib/${_altname}"

  # Install headers
  install -Dm644 sqlite3.h "$pkgdir/usr/include/${_altname}/sqlite3.h"
  install -Dm644 sqlite3ext.h "$pkgdir/usr/include/${_altname}/sqlite3ext.h"
  install -Dm644 sqlite3session.h "$pkgdir/usr/include/${_altname}/sqlite3session.h"
  install -Dm644 sqlite_cfg.h "$pkgdir/usr/include/${_altname}/sqlite_cfg.h"

  # Install pkg-config files
  install -Dm644 libsql.pc "$pkgdir/usr/lib/pkgconfig/libsql.pc"
  install -Dm644 sqlite3.pc "$pkgdir/usr/lib/pkgconfig/${_altname}.pc"

  # Install documentation
  install -Dm644 README-SQLite.md "$pkgdir/usr/share/doc/$pkgname/README-SQLite.md"
  install -Dm644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE.md"

  # Install man pages
  install -Dm644 sqlite3.1 "$pkgdir/usr/share/man/man1/${_altname}.1"
}