diff options
author | Devin J. Pohly | 2016-04-12 13:51:49 -0400 |
---|---|---|
committer | Devin J. Pohly | 2016-04-12 13:51:49 -0400 |
commit | d87a73e2bc6d1f4c66a49cc93535f8c936a4d991 (patch) | |
tree | 0ca179a5107dc79f4bd2012acb4fa7f8a5d13c58 | |
parent | 3a6a73a9b77436852e1c2047717ed16ff980d010 (diff) | |
download | aur-udf-infusion-git.tar.gz |
register/unregister functions with install script
-rw-r--r-- | .SRCINFO | 5 | ||||
-rw-r--r-- | PKGBUILD | 16 | ||||
-rw-r--r-- | bootstrap.patch | 82 | ||||
-rw-r--r-- | udf-infusion.install | 39 |
4 files changed, 138 insertions, 4 deletions
@@ -1,8 +1,9 @@ pkgbase = udf-infusion-git pkgdesc = MySQL functionality enhancement UDF pkgver = r104.25c3613 - pkgrel = 1 + pkgrel = 2 url = https://github.com/infusion/udf_infusion + install = udf-infusion.install arch = i686 arch = x86_64 license = GPL2 @@ -11,7 +12,9 @@ pkgbase = udf-infusion-git provides = udf-infusion conflicts = udf-infusion source = git+https://github.com/infusion/udf_infusion + source = bootstrap.patch sha256sums = SKIP + sha256sums = 82a19b98f1338b2c73040e82ca60b0cfcdf1907e0ca4ab20de3d66227027108f pkgname = udf-infusion-git @@ -3,7 +3,7 @@ pkgname=udf-infusion-git _pkgname=${pkgname%-git} _reponame=udf_infusion pkgver=r104.25c3613 -pkgrel=1 +pkgrel=2 pkgdesc="MySQL functionality enhancement UDF" arch=('i686' 'x86_64') url="https://github.com/infusion/udf_infusion" @@ -12,14 +12,22 @@ depends=('gcc-libs') makedepends=('mysql') provides=("$_pkgname") conflicts=("$_pkgname") -source=("git+https://github.com/infusion/udf_infusion") -sha256sums=(SKIP) +install="$_pkgname.install" +source=("git+https://github.com/infusion/udf_infusion" + bootstrap.patch) +sha256sums=('SKIP' + '82a19b98f1338b2c73040e82ca60b0cfcdf1907e0ca4ab20de3d66227027108f') pkgver() { cd "$_reponame" printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" } +prepare() { + cd "$_reponame" + patch -Np1 -i "$srcdir/bootstrap.patch" +} + build() { cd "$_reponame" ./configure --prefix=/usr @@ -29,4 +37,6 @@ build() { package() { cd "$_reponame" make DESTDIR="$pkgdir/" install + install -d "$pkgdir/usr/share/$_pkgname" + install -m644 load.sql unload.sql "$pkgdir/usr/share/$_pkgname" } diff --git a/bootstrap.patch b/bootstrap.patch new file mode 100644 index 000000000000..a3b573f17c96 --- /dev/null +++ b/bootstrap.patch @@ -0,0 +1,82 @@ +diff --git a/load.sql.sh b/load.sql.sh +index add962a..3ec6c12 100644 +--- a/load.sql.sh ++++ b/load.sql.sh +@@ -10,11 +10,21 @@ if_enable() { + } + + create_agg_function() { +- echo "CREATE AGGREGATE FUNCTION $1 RETURNS $2 SONAME 'udf_infusion.so';" ++ case $2 in ++ string) ret=0;; ++ real) ret=1;; ++ integer) ret=2;; ++ esac ++ echo "INSERT INTO mysql.func (name, ret, dl, type) VALUES ('$1', $ret, 'udf_infusion.so', 'aggregate');" + } + + create_function() { +- echo "CREATE FUNCTION $1 RETURNS $2 SONAME 'udf_infusion.so';" ++ case $2 in ++ string) ret=0;; ++ real) ret=1;; ++ integer) ret=2;; ++ esac ++ echo "INSERT INTO mysql.func (name, ret, dl, type) VALUES ('$1', $ret, 'udf_infusion.so', 'function');" + } + + sh unload.sql.sh +diff --git a/unload.sql.sh b/unload.sql.sh +index 25fd264..9d5cfd5 100644 +--- a/unload.sql.sh ++++ b/unload.sql.sh +@@ -1,48 +1,3 @@ +-[ $# -eq 0 ] && enable_all=1 +-enable_functions="$@" +- +-if_enable() { +- [ "$enable_all" = 1 ] && return 0 +- for func in $enable_functions; do +- [ "$func" = "$1" ] && return 0 +- done +- return 1 +-} +- +-drop_function() { +- echo "DROP FUNCTION IF EXISTS $1;" +-} +- +-if_enable "bound" && drop_function "bound" +-if_enable "bround" && drop_function "bround" +-if_enable "corr" && drop_function "corr" +-if_enable "covariance" && drop_function "covariance" +-if_enable "cut" && drop_function "cut" +-if_enable "fnv" && drop_function "fnv" +-if_enable "getint" && drop_function "getint" +-if_enable "group_first" && drop_function "group_first" +-if_enable "group_last" && drop_function "group_last" +-if_enable "invbit" && drop_function "invbit" +-if_enable "isbit" && drop_function "isbit" +-if_enable "kurtosis" && drop_function "kurtosis" +-if_enable "lessavg" && drop_function "lessavg" +-if_enable "lesspartpct" && drop_function "lesspartpct" +-if_enable "lesspart" && drop_function "lesspart" +-if_enable "median" && drop_function "median" +-if_enable "stats_mode" && drop_function "stats_mode" +-if_enable "ngram" && drop_function "ngram" +-if_enable "noverk" && drop_function "noverk" +-if_enable "percentile_cont" && drop_function "percentile_cont" +-if_enable "percentile_disc" && drop_function "percentile_disc" +-if_enable "rotbit" && drop_function "rotbit" +-if_enable "rotint" && drop_function "rotint" +-if_enable "row_number" && drop_function "row_number" +-if_enable "rsumd" && drop_function "rsumd" +-if_enable "rsumi" && drop_function "rsumi" +-if_enable "setbit" && drop_function "setbit" +-if_enable "setint" && drop_function "setint" +-if_enable "skewness" && drop_function "skewness" +-if_enable "slug" && drop_function "slug" +-if_enable "xround" && drop_function "xround" ++echo "DELETE FROM mysql.func WHERE dl = 'udf_infusion.so';" + + true diff --git a/udf-infusion.install b/udf-infusion.install new file mode 100644 index 000000000000..e50eecf661c0 --- /dev/null +++ b/udf-infusion.install @@ -0,0 +1,39 @@ +# Register functions +post_install() { + start= + if systemctl -q is-active mysqld; then + echo Stopping mysqld... >&2 + start=1 + systemctl stop mysqld + fi + echo Registering UDF library... >&2 + mysqld -u mysql --bootstrap < /usr/share/udf-infusion/load.sql 2> /dev/null + if test -n "$start"; then + echo Starting mysqld... >&2 + systemctl start mysqld + fi +} + +post_upgrade() { + post_install "$@" +} + +# Unregister functions +pre_remove() { + start= + if systemctl -q is-active mysqld; then + echo Stopping mysqld... >&2 + start=1 + systemctl stop mysqld + fi + echo Unregistering UDF library... >&2 + mysqld -u mysql --bootstrap < /usr/share/udf-infusion/unload.sql 2> /dev/null + if test -n "$start"; then + echo Starting mysqld... >&2 + systemctl start mysqld + fi +} + +pre_upgrade() { + pre_remove "$@" +} |