git: 892450efb305 - main - databases/rubygem-bdb1: fix runtime error with ruby 3.0: Undefined symbol "rb_secure"

From: Dirk Meyer <dinoex_at_FreeBSD.org>
Date: Mon, 09 May 2022 10:28:04 UTC
The branch main has been updated by dinoex:

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

commit 892450efb3055d3e962acfa008c99e6580b61575
Author:     Dirk Meyer <dinoex@FreeBSD.org>
AuthorDate: 2022-05-09 10:26:10 +0000
Commit:     Dirk Meyer <dinoex@FreeBSD.org>
CommitDate: 2022-05-09 10:27:58 +0000

    databases/rubygem-bdb1: fix runtime error with ruby 3.0: Undefined symbol "rb_secure"
---
 databases/rubygem-bdb1/Makefile                    |  2 +-
 databases/rubygem-bdb1/files/patch-ext_bdb1_bdb1.c | 67 +++++++++++++++++++++-
 .../rubygem-bdb1/files/patch-ext_bdb1_recnum.c     | 16 +++++-
 3 files changed, 79 insertions(+), 6 deletions(-)

diff --git a/databases/rubygem-bdb1/Makefile b/databases/rubygem-bdb1/Makefile
index f3f770dd6d02..2743e608e2b3 100644
--- a/databases/rubygem-bdb1/Makefile
+++ b/databases/rubygem-bdb1/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	bdb1
 PORTVERSION=	0.2.5
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	databases rubygems
 MASTER_SITES=	RG
 
diff --git a/databases/rubygem-bdb1/files/patch-ext_bdb1_bdb1.c b/databases/rubygem-bdb1/files/patch-ext_bdb1_bdb1.c
index 64290a2c98bd..d039d2ebdbb8 100644
--- a/databases/rubygem-bdb1/files/patch-ext_bdb1_bdb1.c
+++ b/databases/rubygem-bdb1/files/patch-ext_bdb1_bdb1.c
@@ -1,6 +1,18 @@
---- ext/bdb1/bdb1.c.orig	2016-01-18 21:34:35 UTC
+--- ext/bdb1/bdb1.c.orig	2022-05-09 10:22:04 UTC
 +++ ext/bdb1/bdb1.c
-@@ -752,15 +752,15 @@ bdb1_s_alloc(VALUE obj)
+@@ -733,9 +733,11 @@ bdb1_close(VALUE obj)
+     VALUE opt;
+     bdb1_DB *dbst;
+ 
++#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
+     if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4) {
+ 	rb_raise(rb_eSecurityError, "Insecure: can't close the database");
+     }
++#endif
+     Data_Get_Struct(obj, bdb1_DB, dbst);
+     bdb1_i_close(dbst);
+     return Qnil;
+@@ -752,15 +754,15 @@ bdb1_s_alloc(VALUE obj)
      dbst->options |= BDB1_NOT_OPEN;
      cl = obj;
      while (cl) {
@@ -19,3 +31,54 @@
  	    dbst->type = DB_RECNO;
  	    break;
  	}
+@@ -878,7 +880,9 @@ bdb1_put(int argc, VALUE *argv, VALUE obj)
+     int ret, flags;
+     db_recno_t recno;
+ 
++#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
+     rb_secure(4);
++#endif
+     GetDB(obj, dbst);
+     if (rb_scan_args(argc, argv, "21", &a, &b, &c) == 3)
+         flags = NUM2INT(c);
+@@ -1071,7 +1075,9 @@ bdb1_del(VALUE obj, VALUE a)
+     db_recno_t recno;
+     volatile VALUE c = Qnil;
+ 
++#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
+     rb_secure(4);
++#endif
+     GetDB(obj, dbst);
+     if (dbst->type == DB_HASH) {
+ 	rb_warning("delete can give strange result with DB_HASH");
+@@ -1112,7 +1118,9 @@ bdb1_delete_if(VALUE obj)
+     int ret, ret1, flags;
+     db_recno_t recno;
+ 
++#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
+     rb_secure(4);
++#endif
+     GetDB(obj, dbst);
+     INIT_RECNO(dbst, key, recno);
+     DATA_ZERO(data);
+@@ -1138,7 +1146,9 @@ bdb1_clear(VALUE obj)
+     int ret, value, flags;
+     db_recno_t recno;
+ 
++#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
+     rb_secure(4);
++#endif
+     GetDB(obj, dbst);
+     INIT_RECNO(dbst, key, recno);
+     DATA_ZERO(data);
+@@ -1536,8 +1546,10 @@ bdb1_sync(VALUE obj)
+ {
+     bdb1_DB *dbst;
+ 
++#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
+     if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
+ 	rb_raise(rb_eSecurityError, "Insecure: can't sync the database");
++#endif
+     GetDB(obj, dbst);
+     bdb1_test_error(dbst->dbp->sync(dbst->dbp, 0));
+     return Qtrue;
diff --git a/databases/rubygem-bdb1/files/patch-ext_bdb1_recnum.c b/databases/rubygem-bdb1/files/patch-ext_bdb1_recnum.c
index e9b7eb20fdcc..6f15ebe7c15b 100644
--- a/databases/rubygem-bdb1/files/patch-ext_bdb1_recnum.c
+++ b/databases/rubygem-bdb1/files/patch-ext_bdb1_recnum.c
@@ -1,6 +1,6 @@
---- ext/bdb1/recnum.c.orig
+--- ext/bdb1/recnum.c.orig	2022-05-09 10:22:04 UTC
 +++ ext/bdb1/recnum.c
-@@ -17,7 +17,7 @@
+@@ -17,7 +17,7 @@ bdb1_recnum_init(int argc, VALUE *argv, VALUE obj)
  	argc++;
      }
      rb_hash_aset(argv[argc - 1], array, INT2FIX(0));
@@ -8,4 +8,14 @@
 +    if (rb_hash_lookup2(argv[argc - 1], sarray, Qundef) != Qundef) {
  	rb_hash_aset(argv[argc - 1], sarray, INT2FIX(0));
      }
-     rb_hash_aset(argv[argc - 1], rb_str_new2("set_flags"), INT2FIX(DB_RENUMBER));
+     return bdb1_init(argc, argv, obj);
+@@ -134,7 +134,9 @@ bdb1_intern_shift_pop(VALUE obj, int depart, int len)
+     db_recno_t recno;
+     VALUE res;
+ 
++#if defined(RUBY_SAFE_LEVEL_MAX) && RUBY_SAFE_LEVEL_MAX >= 4
+     rb_secure(4);
++#endif
+     GetDB(obj, dbst);
+     INIT_RECNO(dbst, key, recno);
+     DATA_ZERO(data);