diff options
author | pikl | 2024-02-25 17:24:08 +0000 |
---|---|---|
committer | pikl | 2024-02-25 17:24:08 +0000 |
commit | 90391b7e5a6f2b30bcf47536d9e7d8ab24d771f1 (patch) | |
tree | 96e0fbf28aa3ce758f04f19ef438a9fefb20c370 | |
parent | 66306e7a9ac0f985dd006a5dffda110a409e6483 (diff) | |
download | aur-90391b7e5a6f2b30bcf47536d9e7d8ab24d771f1.tar.gz |
exp (#1)
Reviewed-on: https://git.pikl.uk/pikl/aur-pgvecto.rs-immich/pulls/1
-rw-r--r-- | PKGBUILD | 67 | ||||
-rw-r--r-- | debug.diff | 25 |
2 files changed, 79 insertions, 13 deletions
@@ -1,43 +1,84 @@ # Maintainer: pikl <me@pikl.uk> + _pgver=16 # postgresql version _pkgbase=pgvecto.rs pkgname=${_pkgbase}-immich pkgver=0.2.0 -pkgrel=1 +pkgrel=3 pkgdesc="Postgres extension that provides vector similarity search functions. It is written in Rust and based on pgrx. Version required for Immich." arch=(x86_64) url="https://github.com/tensorchord/pgvecto.rs" license=('Apache-2.0') # make deps determined from here - https://docs.pgvecto.rs/developers/development.html -makedepends=('bison' 'ccache' 'flex' 'gcc' 'git' 'gnupg' 'readline' 'libxml2' 'libxslt' 'lsb-release' 'pkgconf' 'tzdata' 'zlib' "postgresql>=${_pgver}" 'clang>=16' 'cargo-nightly') +makedepends=('rustup' 'bison' 'ccache' 'flex' 'gcc' 'git' 'gnupg' 'readline' 'libxml2' 'libxslt' 'lsb-release' 'pkgconf' 'tzdata' 'zlib' "postgresql>=${_pgver}" 'clang>=16' 'rustup') # build fails with LTO enabled options=('!lto') provides=("pgvecto.rs=$pkgver") conflicts=('pgvecto.rs') -source=("${_pkgbase}-${pkgver}.tar.gz::https://github.com/tensorchord/pgvecto.rs/archive/refs/tags/v${pkgver}.tar.gz") +source=( + "${_pkgbase}-${pkgver}.tar.gz::https://github.com/tensorchord/pgvecto.rs/archive/refs/tags/v${pkgver}.tar.gz") sha256sums=('671bfe39a3b87d5dfa5229ab0beffff1bd09686b53779dc511248e79aa4b2646') +_gettcstr() { + cd ${srcdir}/${_pkgbase}-${pkgver} + _toolchain=$(cat rust-toolchain.toml | grep ^channel | cut -d" " -f 3 | tr -d '"') + echo "$_toolchain-$CARCH-unknown-linux-gnu" +} + prepare() { + # https://docs.pgvecto.rs/developers/development.html - cd ${_pkgbase}-${pkgver} - _pgrxver=$(cat Cargo.toml | grep "pgrx =" | awk -F'version = "' '{print $2}' | cut -d'"' -f1) - cargo install cargo-pgrx@0.11.2 + + cd ${srcdir}/${_pkgbase}-${pkgver} + + # workaround to 0.0.0 version number in Cargo.toml + # TODO report to upstream + sed -i -e "s/version = \"0.0.0\"/version = \"${pkgver}\"/" Cargo.toml + + # determine required version of cargo-pgrx + _pgrxver=$(grep 'pgrx = {' Cargo.toml | cut -d '"' -f 2) + + # specifying toolchain version is not strictly necessary since cargo will do it automatically + # although can bt overwritten easily with environment variables, e.g. RUSTUP_TOOLCHAIN=stable + # so most probably best to install is explicitly with this command + rustup toolchain install "$(_gettcstr)" + + # an alternative method for installing cargo-pgrx for debug is to clone the repo direct using + # sources, however: + # * ensure https://github.com/tensorchord/pgrx.git fork is cloned + # * often the version number is not tagged, so use the commit hash to checkout the correct version + # * only build the cargo-pgrx sub-module using `cargo build --release --locked -p cargo-pgrx` + cargo install --locked --version ${_pgrxver} cargo-pgrx } build() { - export RUST_BACKTRACE=full + + # https://docs.pgvecto.rs/developers/development.html # https://docs.pgvecto.rs/getting-started/installation.html - cd ${_pkgbase}-${pkgver} + + rustup toolchain install "$(_gettcstr)" + cd ${srcdir}/${_pkgbase}-${pkgver} + + # workaround problem in pgrx.git cargo-pgrx/src/command/schema.rs:531 where an empty argument + # to the rustc compiler command is generated if RUSTFLAGS environment variable is defined but + # empty - as is typical in arch build environment + # TODO report upstream + unset RUSTFLAGS + # desired postgresql version only - cargo pgrx init --pg16=pg_config - # `cargo pgrx install --release` without installing + cargo pgrx init --pg16=/usr/bin/pg_config + + # equivalent to `cargo pgrx install --release` without installing cargo pgrx package } package() { - cd "${_pkgbase}-${pkgver}/target/release/vectors-pg${_pgver}" + cd "${srcdir}/${_pkgbase}-${pkgver}/target/release/vectors-pg${_pgver}" install -Dm0755 usr/lib/postgresql/vectors.so "${pkgdir}/usr/lib/postgresql/vectors.so" - # install -Dm0644 "usr/share/postgresql/extension/vectors--${pkgver}.sql" "${pkgdir}/usr/share/postgresql/extension/vectors--${pkgver}.sql" - install -Dm0644 "usr/share/postgresql/extension/vectors--0.1.1.sql" "${pkgdir}/usr/share/postgresql/extension/vectors--0.1.1.sql" + install -Dm0644 usr/share/postgresql/extension/vectors--0.2.0.sql "${pkgdir}/usr/share/postgesql/extension/vectors--0.2.0.sql" install -Dm0644 usr/share/postgresql/extension/vectors.control "${pkgdir}/usr/share/postgresql/extension/vectors.control" + + cd "${srcdir}/${_pkgbase}-${pkgver}/sql/upgrade" + # upgrade scripts + cp -r vectors--*.sql "${pkgdir}/usr/share/postgresql/extension" } diff --git a/debug.diff b/debug.diff new file mode 100644 index 000000000000..8ca76f3a196d --- /dev/null +++ b/debug.diff @@ -0,0 +1,25 @@ +diff --git a/cargo-pgrx/src/command/schema.rs b/cargo-pgrx/src/command/schema.rs +index 96a76bdd..631e3540 100644 +--- a/cargo-pgrx/src/command/schema.rs ++++ b/cargo-pgrx/src/command/schema.rs +@@ -528,10 +528,16 @@ fn create_stub( + let mut so_rustc_invocation = crate::env::rustc(); + so_rustc_invocation.stderr(Stdio::inherit()); + +- if let Some(rustc_flags_str) = std::env::var("RUSTFLAGS").ok() { +- let rustc_flags = rustc_flags_str.split(' ').collect::<Vec<_>>(); +- so_rustc_invocation.args(rustc_flags); +- } ++ let so_rustc_invocation_str0 = format!("{:?}", so_rustc_invocation); ++ tracing::debug!(command = %so_rustc_invocation_str0, "Running"); ++ ++ // if let Some(rustc_flags_str) = std::env::var("RUSTFLAGS").ok() { ++ // let rustc_flags = rustc_flags_str.split(' ').collect::<Vec<_>>(); ++ // so_rustc_invocation.args(rustc_flags); ++ // } ++ ++ let so_rustc_invocation_str1 = format!("{:?}", so_rustc_invocation); ++ tracing::debug!(command = %so_rustc_invocation_str1, "Running"); + + so_rustc_invocation.args([ + "--crate-type", |