git: a313aafb0ebc - main - databases/duckdb: Add pre-compiled sqlite extension; Fix version reported by DuckDB

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Thu, 16 Nov 2023 06:40:50 UTC
The branch main has been updated by yuri:

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

commit a313aafb0ebc587ac25ba438a485a6f7d93282b7
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2023-11-16 06:37:35 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2023-11-16 06:40:47 +0000

    databases/duckdb: Add pre-compiled sqlite extension; Fix version reported by DuckDB
    
    Other extensions should be added as pre-compiled extensions the same way,
    because otherwise DuckDB attempts to download pre-compiled extensions
    as binaries which only works for Linux, and is also very insecure.
---
 databases/duckdb/Makefile                   | 12 ++++++++++--
 databases/duckdb/distinfo                   |  4 +++-
 databases/duckdb/files/patch-CMakeLists.txt | 28 ++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/databases/duckdb/Makefile b/databases/duckdb/Makefile
index 9105f595aa0e..4f4af8907571 100644
--- a/databases/duckdb/Makefile
+++ b/databases/duckdb/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	duckdb
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.9.2
+PORTREVISION=	1
 CATEGORIES=	databases
 
 MAINTAINER=	yuri@FreeBSD.org
@@ -12,6 +13,7 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 
 USES=		cmake:testing compiler:c++11-lang ssl
 USE_GITHUB=	yes
+GH_TUPLE=	duckdb:sqlite_scanner:ef91604:sqlite/extension/sqlite_scanner
 
 CMAKE_ON=	BUILD_SHARED_LIBS
 CMAKE_OFF=	BUILD_UNITTESTS
@@ -23,7 +25,8 @@ BINARY_ALIAS=	git=false
 OPTIONS_DEFINE=			TPCE
 OPTIONS_DEFAULT=		TPCE
 OPTIONS_GROUP=			EXTENSIONS
-OPTIONS_GROUP_EXTENSIONS=	AUTOCOMPLETE EXCEL FTS HTTPFS ICU INET JEMALLOC JSON PARQUET SQLSMITH TPCDS TPCH VISUALIZER
+OPTIONS_GROUP_EXTENSIONS=	AUTOCOMPLETE EXCEL FTS HTTPFS ICU INET JEMALLOC JSON PARQUET SQLSMITH TPCDS TPCH VISUALIZER \
+				SQLITE_SCANNER
 
 EXTENSIONS_DESC=		Extensions:
 
@@ -36,7 +39,12 @@ DUCKDB_EXTENSIONS+=	;${opt:tl}
 ${opt}_PLIST_FILES=	lib/lib${opt:tl}_extension.a
 .endfor
 
-CMAKE_ARGS=	-DBUILD_EXTENSIONS="${DUCKDB_EXTENSIONS:tW:S/ //g:S/^;//}"
+CMAKE_ARGS=	-DBUILD_EXTENSIONS="${DUCKDB_EXTENSIONS:tW:S/ //g:S/^;//}" \
+		-DDUCKDB_MAJOR_VERSION=${PORTVERSION:R:R} \
+		-DDUCKDB_MINOR_VERSION=${PORTVERSION:R:E} \
+		-DDUCKDB_PATCH_VERSION=${PORTVERSION:E}
+
+SQLITE_SCANNER_CXXFLAGS=	-I${WRKSRC}/extension/sqlite_scanner/src/include # workaround for the header not being found
 
 TPCE_DESC=			Enable building of the TPC-E tool
 TPCE_CMAKE_BOOL=		BUILD_TPCE
diff --git a/databases/duckdb/distinfo b/databases/duckdb/distinfo
index 00ba6c24c23e..aac9b3d196fd 100644
--- a/databases/duckdb/distinfo
+++ b/databases/duckdb/distinfo
@@ -1,3 +1,5 @@
-TIMESTAMP = 1700026259
+TIMESTAMP = 1700111325
 SHA256 (duckdb-duckdb-v0.9.2_GH0.tar.gz) = afff7bd925a98dc2af4039b8ab2159b0705cbf5e0ee05d97f7bb8dce5f880dc2
 SIZE (duckdb-duckdb-v0.9.2_GH0.tar.gz) = 75296956
+SHA256 (duckdb-sqlite_scanner-ef91604_GH0.tar.gz) = 935698a7fde1ec5b5dd94dfd0e02e89a331ca732f6c07add76307839382491cc
+SIZE (duckdb-sqlite_scanner-ef91604_GH0.tar.gz) = 4648835
diff --git a/databases/duckdb/files/patch-CMakeLists.txt b/databases/duckdb/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..a1cb950405d1
--- /dev/null
+++ b/databases/duckdb/files/patch-CMakeLists.txt
@@ -0,0 +1,28 @@
+--- CMakeLists.txt.orig	2023-11-13 18:58:24 UTC
++++ CMakeLists.txt
+@@ -240,7 +240,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
+ endif()
+ 
+ find_package(Git)
+-if(Git_FOUND)
++if(FALSE AND Git_FOUND)
+   if (NOT DEFINED GIT_COMMIT_HASH)
+     execute_process(
+             COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
+@@ -279,11 +279,11 @@ if(GIT_RESULT EQUAL "0")
+   endif()
+ else()
+   # fallback for when building from tarball
+-  set(DUCKDB_MAJOR_VERSION 0)
+-  set(DUCKDB_MINOR_VERSION 0)
+-  set(DUCKDB_PATCH_VERSION 1)
+-  set(DUCKDB_DEV_ITERATION 0)
+-  set(DUCKDB_VERSION "v${DUCKDB_MAJOR_VERSION}.${DUCKDB_MINOR_VERSION}.${DUCKDB_PATCH_VERSION}-dev${DUCKDB_DEV_ITERATION}")
++  #set(DUCKDB_MAJOR_VERSION 0)
++  #set(DUCKDB_MINOR_VERSION 0)
++  #set(DUCKDB_PATCH_VERSION 1)
++  #set(DUCKDB_DEV_ITERATION 0)
++  set(DUCKDB_VERSION "v${DUCKDB_MAJOR_VERSION}.${DUCKDB_MINOR_VERSION}.${DUCKDB_PATCH_VERSION}")
+ endif()
+ 
+ message(STATUS "git hash ${GIT_COMMIT_HASH}, version ${DUCKDB_VERSION}")