git: 214f1e0b7578 - main - databases/emacsql-devel: Add new port

From: Yasuhiro Kimura <yasu_at_FreeBSD.org>
Date: Sat, 13 May 2023 06:38:12 UTC
The branch main has been updated by yasu:

URL: https://cgit.FreeBSD.org/ports/commit/?id=214f1e0b757862e4e9081c6f1c06e48ad368a225

commit 214f1e0b757862e4e9081c6f1c06e48ad368a225
Author:     Yasuhiro Kimura <yasu@FreeBSD.org>
AuthorDate: 2023-05-12 09:44:36 +0000
Commit:     Yasuhiro Kimura <yasu@FreeBSD.org>
CommitDate: 2023-05-13 06:34:29 +0000

    databases/emacsql-devel: Add new port
    
    EmacSQL is a high-level Emacs Lisp front-end for SQLite (primarily),
    PostgreSQL, MySQL, and potentially other SQL databases.
    
    This is development version of EmacSQL.
    
    https://github.com/magit/emacsql
---
 databases/Makefile                                 |  1 +
 databases/emacsql-devel/Makefile                   | 51 ++++++++++++++++++++++
 databases/emacsql-devel/distinfo                   |  3 ++
 .../emacsql-devel/files/patch-emacsql-sqlite.el    | 44 +++++++++++++++++++
 .../emacsql-devel/files/patch-sqlite_Makefile      | 24 ++++++++++
 .../emacsql-devel/files/patch-sqlite_emacsql.c     | 11 +++++
 databases/emacsql-devel/pkg-descr                  | 12 +++++
 databases/emacsql-devel/pkg-plist                  | 20 +++++++++
 databases/emacsql/Makefile                         |  2 +-
 9 files changed, 167 insertions(+), 1 deletion(-)

diff --git a/databases/Makefile b/databases/Makefile
index ce41ad199edf..df2e4c765cd0 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -59,6 +59,7 @@
     SUBDIR += ejdb
     SUBDIR += emacs-sqlite3-api
     SUBDIR += emacsql
+    SUBDIR += emacsql-devel
     SUBDIR += erlfdb
     SUBDIR += evolution-data-server
     SUBDIR += fastdb
diff --git a/databases/emacsql-devel/Makefile b/databases/emacsql-devel/Makefile
new file mode 100644
index 000000000000..e27cf43eef3a
--- /dev/null
+++ b/databases/emacsql-devel/Makefile
@@ -0,0 +1,51 @@
+PORTNAME=	emacsql
+DISTVERSION=	3.1.1-42
+DISTVERSIONSUFFIX=	-g6401226
+CATEGORIES=	databases elisp
+PKGNAMESUFFIX=	-devel${EMACS_PKGNAMESUFFIX}
+
+MAINTAINER=	yasu@FreeBSD.org
+COMMENT=	High-level Emacs Lisp RDBMS front-end (Development Version)
+WWW=		https://github.com/magit/emacsql
+
+LICENSE=	UNLICENSE
+LICENSE_FILE=	${WRKSRC}/UNLICENSE
+
+BUILD_DEPENDS=	emacs-sqlite3-api${EMACS_PKGNAMESUFFIX}>=0.16:databases/emacs-sqlite3-api@${EMACS_FLAVOR} \
+		pg.el${EMACS_PKGNAMESUFFIX}>=0.16:databases/pg.el@${EMACS_FLAVOR}
+LIB_DEPENDS=	libsqlite3.so:databases/sqlite3
+RUN_DEPENDS=	emacs-sqlite3-api${EMACS_PKGNAMESUFFIX}>=0.16:databases/emacs-sqlite3-api@${EMACS_FLAVOR} \
+		pg.el${EMACS_PKGNAMESUFFIX}>=0.16:databases/pg.el@${EMACS_FLAVOR}
+
+USES=		emacs gmake localbase:ldflags
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	magit
+
+MAKE_ENV+=	LOAD_PATH="-L ${PREFIX}/${EMACS_SITE_LISPDIR} -L ${PREFIX}/${EMACS_VERSION_SITE_LISPDIR}"
+MAKE_JOBS_UNSAFE=	yes
+TEST_TARGET=	test
+
+CONFLICTS_INSTALL=	emacsql emacsql-emacs_*
+
+PORTDOCS=	README.md
+
+OPTIONS_DEFINE=	DOCS
+
+post-patch:
+	${RM} ${WRKSRC}/sqlite/sqlite3.[ch]
+	${REINPLACE_CMD} 's,%%PREFIX%%,${PREFIX},g' ${WRKSRC}/emacsql-sqlite.el
+
+do-install:
+	@${MKDIR} ${STAGEDIR}${PREFIX}/bin \
+		${STAGEDIR}${PREFIX}/${EMACS_VERSION_SITE_LISPDIR}/${PORTNAME}
+	${INSTALL_PROGRAM} ${WRKSRC}/sqlite/emacsql-sqlite \
+		${STAGEDIR}${PREFIX}/bin
+	${INSTALL_DATA} ${WRKSRC}/*.el ${WRKSRC}/*.elc \
+		${STAGEDIR}${PREFIX}/${EMACS_VERSION_SITE_LISPDIR}/${PORTNAME}
+
+do-install-DOCS-on:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+	${INSTALL_DATA} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR}
+
+.include <bsd.port.mk>
diff --git a/databases/emacsql-devel/distinfo b/databases/emacsql-devel/distinfo
new file mode 100644
index 000000000000..cf8ac913ecf5
--- /dev/null
+++ b/databases/emacsql-devel/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1683885114
+SHA256 (magit-emacsql-3.1.1-42-g6401226_GH0.tar.gz) = a60dfc7620d0448c8dd5b8b5644a83cea22012240b2463f0a0bcb6c88eede87a
+SIZE (magit-emacsql-3.1.1-42-g6401226_GH0.tar.gz) = 2398782
diff --git a/databases/emacsql-devel/files/patch-emacsql-sqlite.el b/databases/emacsql-devel/files/patch-emacsql-sqlite.el
new file mode 100644
index 000000000000..8ddae08ac1fe
--- /dev/null
+++ b/databases/emacsql-devel/files/patch-emacsql-sqlite.el
@@ -0,0 +1,44 @@
+--- emacsql-sqlite.el.orig	2022-02-18 15:43:25 UTC
++++ emacsql-sqlite.el
+@@ -33,16 +33,7 @@
+     "sqlite/emacsql-sqlite")
+   "Relative path to emacsql executable.")
+ 
+-(defvar emacsql-sqlite-executable
+-  (expand-file-name emacsql-sqlite-executable-path
+-                    (if (or (file-writable-p emacsql-sqlite-data-root)
+-                            (file-exists-p (expand-file-name
+-                                            emacsql-sqlite-executable-path
+-                                            emacsql-sqlite-data-root)))
+-                        emacsql-sqlite-data-root
+-                      (expand-file-name
+-                       (concat "emacsql/" emacsql-version)
+-                       user-emacs-directory)))
++(defvar emacsql-sqlite-executable "%%PREFIX%%/bin/emacsql-sqlite"
+   "Path to the EmacSQL backend (this is not the sqlite3 shell).")
+ 
+ (defvar emacsql-sqlite-reserved
+@@ -100,6 +91,7 @@ used.")
+     (emacsql-wait connection)
+     (emacsql connection [:pragma (= busy-timeout $s1)]
+              (/ (* emacsql-global-timeout 1000) 2))
++    (emacsql connection [:pragma (= foreign_keys 1)])
+     (emacsql-register connection)))
+ 
+ (cl-defun emacsql-sqlite (file &key debug)
+@@ -163,12 +155,12 @@ If called with non-nil ASYNC the return value is meani
+                       if path return it))
+          (src (expand-file-name "sqlite" emacsql-sqlite-data-root))
+          (files (mapcar (lambda (f) (expand-file-name f src))
+-                        '("sqlite3.c" "emacsql.c")))
++                        '("emacsql.c")))
+          (cflags (list (format "-I%s" src) (format "-O%d" (or o-level 2))))
+          (ldlibs (cl-case system-type
+                    (windows-nt (list))
+-                   (berkeley-unix (list "-lm"))
+-                   (otherwise (list "-lm" "-ldl"))))
++                   (berkeley-unix (list "-lm" "-lsqlite3"))
++                   (otherwise (list "-lm" "-ldl" "-lsqlite3"))))
+          (options (emacsql-sqlite-compile-switches))
+          (output (list "-o" emacsql-sqlite-executable))
+          (arguments (nconc cflags options files ldlibs output)))
diff --git a/databases/emacsql-devel/files/patch-sqlite_Makefile b/databases/emacsql-devel/files/patch-sqlite_Makefile
new file mode 100644
index 000000000000..7408786dead2
--- /dev/null
+++ b/databases/emacsql-devel/files/patch-sqlite_Makefile
@@ -0,0 +1,24 @@
+--- sqlite/Makefile.orig	2022-10-11 15:22:51 UTC
++++ sqlite/Makefile
+@@ -1,8 +1,8 @@
+ -include ../.config.mk
+ 
+ .POSIX:
+-LDLIBS = -ldl -lm
+-CFLAGS = -O2 -Wall -Wextra -Wno-implicit-fallthrough \
++LDLIBS = -lsqlite3
++CFLAGS += \
+     -DSQLITE_THREADSAFE=0 \
+     -DSQLITE_DEFAULT_FOREIGN_KEYS=1 \
+     -DSQLITE_ENABLE_FTS5 \
+@@ -12,8 +12,8 @@ CFLAGS = -O2 -Wall -Wextra -Wno-implicit-fallthrough \
+     -DSQLITE_ENABLE_JSON1 \
+     -DSQLITE_SOUNDEX
+ 
+-emacsql-sqlite: emacsql.c sqlite3.c
+-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ emacsql.c sqlite3.c $(LDLIBS)
++emacsql-sqlite: emacsql.c
++	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ emacsql.c $(LDLIBS)
+ 
+ clean:
+ 	rm -f emacsql-sqlite
diff --git a/databases/emacsql-devel/files/patch-sqlite_emacsql.c b/databases/emacsql-devel/files/patch-sqlite_emacsql.c
new file mode 100644
index 000000000000..24590656df22
--- /dev/null
+++ b/databases/emacsql-devel/files/patch-sqlite_emacsql.c
@@ -0,0 +1,11 @@
+--- sqlite/emacsql.c.orig	2020-07-14 00:28:59 UTC
++++ sqlite/emacsql.c
+@@ -1,7 +1,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+-#include "sqlite3.h"
++#include <sqlite3.h>
+ 
+ #define TRUE 1
+ #define FALSE 0
diff --git a/databases/emacsql-devel/pkg-descr b/databases/emacsql-devel/pkg-descr
new file mode 100644
index 000000000000..172b572e6c59
--- /dev/null
+++ b/databases/emacsql-devel/pkg-descr
@@ -0,0 +1,12 @@
+EmacSQL is a high-level Emacs Lisp front-end for SQLite (primarily),
+PostgreSQL, MySQL, and potentially other SQL databases.
+
+It works by maintaining a inferior process running (a "connection")
+for interacting with the back-end database. Connections are
+automatically cleaned up if they are garbage collected. All requests
+are synchronous.
+
+Any readable lisp value can be stored as a value in EmacSQL, including
+numbers, strings, symbols, lists, vectors, and closures. EmacSQL has
+no concept of "TEXT" values; it's all just lisp objects. The lisp
+object nil corresponds 1:1 with NULL in the database.
diff --git a/databases/emacsql-devel/pkg-plist b/databases/emacsql-devel/pkg-plist
new file mode 100644
index 000000000000..034968dd773c
--- /dev/null
+++ b/databases/emacsql-devel/pkg-plist
@@ -0,0 +1,20 @@
+bin/emacsql-sqlite
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-autoloads.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-compiler.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-compiler.elc
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-mysql.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-mysql.elc
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-pg.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-pg.elc
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-psql.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-psql.elc
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-sqlite-builtin.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-sqlite-builtin.elc
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-sqlite-common.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-sqlite-common.elc
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-sqlite-module.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-sqlite-module.elc
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-sqlite.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql-sqlite.elc
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql.el
+%%EMACS_VERSION_SITE_LISPDIR%%/emacsql/emacsql.elc
diff --git a/databases/emacsql/Makefile b/databases/emacsql/Makefile
index 8cc8a9a4f741..1ea8caba745d 100644
--- a/databases/emacsql/Makefile
+++ b/databases/emacsql/Makefile
@@ -27,7 +27,7 @@ MAKE_ENV+=	LOAD_PATH="-L ${PREFIX}/${EMACS_SITE_LISPDIR} -L ${PREFIX}/${EMACS_VE
 MAKE_JOBS_UNSAFE=	yes
 TEST_TARGET=	test
 
-CONFLICTS_INSTALL=	emacsql emacsql-emacs_*
+CONFLICTS_INSTALL=	emacsql emacsql-devel* emacsql-emacs_*
 
 PORTDOCS=	README.md