siflower: fix plugin update

This commit is contained in:
gl-dengxinfa 2022-11-22 15:32:05 +08:00
parent f4f3cfbfe7
commit e10c8ca2e8

View File

@ -0,0 +1,109 @@
From 5cea0b734a0de9b5f51e2e142b0e11633b09cd5b Mon Sep 17 00:00:00 2001
From: gl-dengxinfa <xinfa.deng@gl-inet.com>
Date: Tue, 22 Nov 2022 15:30:28 +0800
Subject: [PATCH] fix: plugin add database record
---
.../system/opkg/patches/001-support-db.patch | 60 +++++++++++++++++++
.../002-conffile-use-standard-output.patch | 22 +++++++
2 files changed, 82 insertions(+)
create mode 100644 openwrt-18.06/package/system/opkg/patches/001-support-db.patch
create mode 100644 openwrt-18.06/package/system/opkg/patches/002-conffile-use-standard-output.patch
diff --git a/openwrt-18.06/package/system/opkg/patches/001-support-db.patch b/openwrt-18.06/package/system/opkg/patches/001-support-db.patch
new file mode 100644
index 000000000..b37225f41
--- /dev/null
+++ b/openwrt-18.06/package/system/opkg/patches/001-support-db.patch
@@ -0,0 +1,60 @@
+--- a/libopkg/opkg_cmd.c
++++ b/libopkg/opkg_cmd.c
+@@ -41,6 +41,29 @@
+ #include "opkg_configure.h"
+ #include "xsystem.h"
+
++int exec_command(const char *command)
++{
++ opkg_msg(NOTICE, "Updating database.\n");
++ remove("/var/lock/opkg.lock");
++
++ FILE *fp;
++
++ fp = popen(command, "r");
++ if (fp == NULL) {
++ return -1;
++ }
++ pclose(fp);
++
++ fp = fopen("/var/lock/opkg.lock", "w+");
++ if (fp != NULL) {
++ fclose(fp);
++ }
++
++ opkg_msg(NOTICE, "Database update completed.\n");
++
++ return 0;
++}
++
+ static void print_pkg(pkg_t * pkg)
+ {
+ char *version = pkg_version_str_alloc(pkg);
+@@ -200,7 +224,7 @@ static int opkg_update_cmd(int argc, cha
+ rmdir(tmp);
+ free(tmp);
+ free(lists_dir);
+-
++ exec_command("update_plugins_db update");
+ return failures;
+ }
+
+@@ -486,7 +510,8 @@ static int opkg_install_cmd(int argc, ch
+ err = -1;
+
+ write_status_files_if_changed();
+-
++ if (err == 0)
++ exec_command("update_plugins_db install");
+ return err;
+ }
+
+@@ -914,6 +939,8 @@ static int opkg_remove_cmd(int argc, cha
+ opkg_msg(NOTICE, "No packages removed.\n");
+
+ write_status_files_if_changed();
++ if (err == 0)
++ exec_command("update_plugins_db remove");
+ return err;
+ }
+
diff --git a/openwrt-18.06/package/system/opkg/patches/002-conffile-use-standard-output.patch b/openwrt-18.06/package/system/opkg/patches/002-conffile-use-standard-output.patch
new file mode 100644
index 000000000..f587af496
--- /dev/null
+++ b/openwrt-18.06/package/system/opkg/patches/002-conffile-use-standard-output.patch
@@ -0,0 +1,22 @@
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -1151,7 +1151,7 @@ static int resolve_conffiles(pkg_t * pkg
+ char *new_conffile;
+ sprintf_alloc(&new_conffile, "%s-opkg",
+ root_filename);
+- opkg_msg(ERROR,
++ opkg_msg(NOTICE,
+ "Existing conffile %s "
+ "is different from the conffile in the new package."
+ " The new conffile will be placed at %s.\n",
+--- a/opkg-2021-06-13-1bf042dd/libopkg/pkg.c
++++ b/libopkg/pkg.c
+@@ -1409,7 +1409,7 @@ int pkg_run_script(pkg_t * pkg, const ch
+ return 0;
+ }
+
+- sprintf_alloc(&cmd, "%s %s", path, args);
++ sprintf_alloc(&cmd, "%s %s 2>&1", path, args);
+ free(path);
+ {
+ const char *argv[] = { "/bin/sh", "-c", cmd, NULL };
--
2.34.1