summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--package.xml2
-rw-r--r--rpminfo.c21
3 files changed, 17 insertions, 12 deletions
diff --git a/README.md b/README.md
index 65f4319..40123a6 100644
--- a/README.md
+++ b/README.md
@@ -221,15 +221,13 @@ For example, can be used to set the Database path and backend
$ mock -r almalinux-8-x86_64 init
...
+ $ mock -r fedora-41-x86_64 ini
+ ...
$ php -a
php > rpmdefine("_dbpath /var/lib/mock/almalinux-8-x86_64/root/var/lib/rpm");
php > rpmdefine("_db_backend bdb_ro");
php > var_dump(rpmdbinfo("almalinux-release")[0]["Summary"]);
string(22) "AlmaLinux release file"
-
- $ mock -r fedora-41-x86_64 ini
- ...
- $ php -a
php > rpmdefine("_dbpath /var/lib/mock/fedora-41-x86_64/root/usr/lib/sysimage/rpm");
php > rpmdefine("_db_backend sqlite");
php > var_dump(rpmdbinfo("fedora-release")[0]["Summary"]);
diff --git a/package.xml b/package.xml
index 172eba6..04a39be 100644
--- a/package.xml
+++ b/package.xml
@@ -13,7 +13,7 @@ Documentation: https://www.php.net/rpminfo
<email>remi@php.net</email>
<active>yes</active>
</lead>
- <date>2024-09-03</date>
+ <date>2024-12-19</date>
<version>
<release>1.2.0dev</release>
<api>1.2.0</api>
diff --git a/rpminfo.c b/rpminfo.c
index 17d08b4..ae8b8e7 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -70,6 +70,13 @@ static rpmdb rpminfo_getdb(void) {
return RPMINFO_G(db);
}
+static void rpminfo_closedb(void) {
+ if (RPMINFO_G(db)) {
+ rpmtsCloseDB(RPMINFO_G(ts));
+ RPMINFO_G(db) = NULL;
+ }
+}
+
static void rpm_header_to_zval(zval *return_value, Header h, zend_bool full)
{
HeaderIterator hi;
@@ -879,7 +886,7 @@ PHP_FUNCTION(rpmexpand)
RETURN_THROWS();
}
- (void)rpminfo_getts(); // read config files
+ (void)rpminfo_getts(); /* read config files */
result = rpmExpand(text, NULL);
RETVAL_STRING(result);
@@ -899,7 +906,7 @@ PHP_FUNCTION(rpmexpandnumeric)
RETURN_THROWS();
}
- (void)rpminfo_getts(); // read config files
+ (void)rpminfo_getts(); /* read config files */
result = rpmExpandNumeric(text);
@@ -919,7 +926,9 @@ PHP_FUNCTION(rpmdefine)
RETURN_THROWS();
}
- (void)rpminfo_getts(); // read config files
+ (void)rpminfo_getts(); /* read config files */
+
+ rpminfo_closedb(); /* Close the DB to allow path change */
result = rpmDefineMacro(NULL, macro, RMIL_GLOBAL);
@@ -999,10 +1008,8 @@ PHP_RINIT_FUNCTION(rpminfo)
PHP_RSHUTDOWN_FUNCTION(rpminfo)
{
if (RPMINFO_G(ts)) {
- if (RPMINFO_G(db)) {
- rpmtsCloseDB(RPMINFO_G(ts));
- RPMINFO_G(db) = NULL;
- }
+ rpminfo_closedb();
+
rpmtsFree(RPMINFO_G(ts));
RPMINFO_G(ts) = NULL;
}