Skip to content

Commit

Permalink
Fix the debut PKGBUILD
Browse files Browse the repository at this point in the history
  • Loading branch information
buck-yeh committed May 22, 2022
1 parent c086e70 commit 58c48d3
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 8 deletions.
77 changes: 75 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,75 @@
# bux-sqlite
Wrapper classes and utilities of the original sqlite3 CAPI

## Table of Contents

* [Rationale](#rationale)
* [API Summary](#api-summary)
* [Recurring Types and Their Safe Counterparts](#recurring-types-and-their-safe-counterparts)
* [Installation](#installation)
* [in <a href="https://archlinux.org/" rel="nofollow">ArchLinux</a>](#in-archlinux)
* [from github in any of <a href="https://distrowatch.com/" rel="nofollow">Linux distros</a>](#from-github-in-any-of-linux-distros)

*(Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc))*

## Rationale

The idea is to minimize boilerplate code when doing the same things using native [SQLite API](https://www.sqlite.org/capi3ref.html). Only recurring usages are wrapped into helper classes or plain functions. Mixed uses of this module and the native API are expected. Always prefer `bux::C_SQLite`, `bux::C_SQLiteStmt` over `sqlite3*`, `sqlite3_stmt*` and you will be fine.

## API Summary

### Recurring Types and Their Safe Counterparts

| Original Type | Wrapper Class |
|:-------------:|:--------------|
| `sqlite3*` | `bux::C_SQLite` |
| `sqlite3_stmt*` | `bux::C_SQLiteStmt` |

1. The right colum (_class type_) of each row above can be cast to the left column (_native SQLite pointer type_) implicitly & _safely_.
2. `bux::C_SQLite` can only be constructed by a valid SQLite databse file name.
3. `bux::C_SQLiteStmt` is contructed by passing a `bux::C_SQLite` instance and a SQL statement. And it is the recommended way to bind SQL arguments by calling native `sqlite3_bind_\w+()` functions before its own `execute()` method.

## Installation

### in [ArchLinux](https://archlinux.org/)

1. Make sure you have installed [`yay`](https://aur.archlinux.org/packages/yay/) or any other [pacman wrapper](https://wiki.archlinux.org/index.php/AUR_helpers).
2. `yay -S bux-sqlite` to install. `bux` is also installed with it.
3. `yay -Ql bux-sqlite` to see the installed files:

~~~bash
bux-mariadb-client /usr/
bux-mariadb-client /usr/include/
bux-mariadb-client /usr/include/bux/
bux-mariadb-client /usr/include/bux/oo_mariadb.h
bux-mariadb-client /usr/lib/
bux-mariadb-client /usr/lib/libbux-mariadb-client.a
bux-mariadb-client /usr/share/
bux-mariadb-client /usr/share/licenses/
bux-mariadb-client /usr/share/licenses/bux-mariadb-client/
bux-mariadb-client /usr/share/licenses/bux-mariadb-client/LICENSE
~~~

4. Include the sole header file by prefixing the header name with `bux/`:

~~~c++
#include <bux/oo_sqlite.h>
~~~

*p.s.* Compiler is expected to search `/usr/include` by default.
5. If directly using `gcc` or `clang` is intended, the required compiler flags are `-lbux-sqlite -lbux`

### from github in any of [Linux distros](https://distrowatch.com/)

1. Make sure you have installed `cmake` `make` `gcc` `git` `fmt` `sqlite`, or the likes. Known package names in different distros/package-managers:
| Distro/PkgMngr | Package Name |
|:----------------:|:------------:|
| ArchLinux/yay | `fmt`, `sqlite` |
| Fedora/dnf | `fmt-devel`, `sqlite-devel` |

2. ~~~bash
git clone https://github.com/buck-yeh/bux-sqlite.git
cd bux-sqlite
cmake -D FETCH_DEPENDEES=1 -D DEPENDEE_ROOT=_deps .
make -j
~~~

3. Include `include/bux/oo_sqlite.h` and link with `src/libbux-sqlite.a`
12 changes: 6 additions & 6 deletions distros/archlinux/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# then please put 'unknown'.

# Maintainer: Buck Yeh <buck.yeh at gmail dot com>
pkgname=bux-mariadb-client
pkgname=bux-sqlite
pkgver=VERSION
pkgrel=1
epoch=
pkgdesc='Wrapper classes and utilities of the original sqlite3 CAPI'
pkgdesc='Wrapper classes and utilities of the original SQLite3 CAPI'
arch=('x86_64')
url='https://github.com/buck-yeh/bux-sqlite.git'
license=('MIT')
groups=()
depends=('sqlite' 'bux' 'fmt')
depends=('sqlite' 'fmt')
makedepends=('cmake' 'make' 'gcc' 'git' 'binutils' 'fakeroot' 'gawk')
checkdepends=()
optdepends=()
Expand Down Expand Up @@ -45,10 +45,10 @@ build() {

check() {
cd "$pkgname" || return 1
if [[ ! -f src/libbux-mariadb-client.a ]]; then
if [[ ! -f src/libbux-sqlite.a ]]; then
return 1
fi
if [[ ! -f include/bux/oo_mariadb.h ]]; then
if [[ ! -f include/bux/oo_sqlite.h ]]; then
return 1
fi
return 0
Expand All @@ -58,7 +58,7 @@ package() {
cd "$pkgname" || return 1
mkdir -p "$pkgdir/usr/lib"
mkdir -p "$pkgdir/usr/include/bux"
cp src/libbux-mariadb-client.a "$pkgdir/usr/lib/"
cp src/libbux-sqlite.a "$pkgdir/usr/lib/"
cp include/bux/*.h "$pkgdir/usr/include/bux/"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

0 comments on commit 58c48d3

Please sign in to comment.