gl-infra-builder-FUjr/patches-19.x/0103-opkg-support-database.patch
GL.iNet-Hongjian.Zhang bd0f47ea7b fix opkg patch
2021-08-11 09:37:08 +08:00

110 lines
2.9 KiB
Diff

From 1a4d42b90f03e5022ad8f55985b4be5be098ed8e Mon Sep 17 00:00:00 2001
From: "GL.iNet-Hongjian.Zhang" <hongjian.zhang@gl-inet.com>
Date: Wed, 11 Aug 2021 09:31:00 +0800
Subject: [PATCH] opkg support database
---
package/system/opkg/Makefile | 2 +-
.../system/opkg/patches/001-support-db.patch | 76 +++++++++++++++++++
2 files changed, 77 insertions(+), 1 deletion(-)
create mode 100644 package/system/opkg/patches/001-support-db.patch
diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile
index c8fb12e93d..bade23b87e 100644
--- a/package/system/opkg/Makefile
+++ b/package/system/opkg/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=opkg
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_FLAGS:=essential
PKG_SOURCE_PROTO:=git
diff --git a/package/system/opkg/patches/001-support-db.patch b/package/system/opkg/patches/001-support-db.patch
new file mode 100644
index 0000000000..e29587453c
--- /dev/null
+++ b/package/system/opkg/patches/001-support-db.patch
@@ -0,0 +1,76 @@
+Index: b/libopkg/opkg_cmd.c
+===================================================================
+--- a/libopkg/opkg_cmd.c 2021-08-10 17:26:51.439919016 +0800
++++ b/libopkg/opkg_cmd.c 2021-08-10 17:28:30.269461593 +0800
+@@ -21,6 +21,8 @@
+ #include <fnmatch.h>
+ #include <signal.h>
+ #include <unistd.h>
++#include <sys/wait.h>
++#include <fcntl.h>
+
+ #include "opkg_conf.h"
+ #include "opkg_cmd.h"
+@@ -41,6 +43,36 @@
+ #include "opkg_configure.h"
+ #include "xsystem.h"
+
++int fork_exec(const char *command)
++{
++ pid_t fpid;
++ pid_t ffpid;
++ int fd;
++ int stat;
++ fpid = fork();
++ if (fpid < 0) {
++ return -1;
++ } else if (fpid == 0) {
++ ffpid = fork();
++ if (ffpid == 0) {
++ fd = open("/dev/null", O_RDWR);
++ if (fd > -1) {
++ dup2(fd, STDIN_FILENO);
++ dup2(fd, STDOUT_FILENO);
++ dup2(fd, STDERR_FILENO);
++ if (fd > STDERR_FILENO)
++ close(fd);
++ }
++ execlp("/bin/sh", "sh", "-c", command, (char *)NULL);
++ } else {
++ exit(1);
++ }
++ } else {
++ waitpid(fpid, &stat, 0);
++ }
++ return 0;
++}
++
+ static void print_pkg(pkg_t * pkg)
+ {
+ char *version = pkg_version_str_alloc(pkg);
+@@ -196,7 +228,7 @@ static int opkg_update_cmd(int argc, cha
+ rmdir(tmp);
+ free(tmp);
+ free(lists_dir);
+-
++ fork_exec("update_plugins_db update");
+ return failures;
+ }
+
+@@ -482,7 +514,7 @@ static int opkg_install_cmd(int argc, ch
+ err = -1;
+
+ write_status_files_if_changed();
+-
++ fork_exec("update_plugins_db install");
+ return err;
+ }
+
+@@ -900,6 +932,7 @@ static int opkg_remove_cmd(int argc, cha
+ opkg_msg(NOTICE, "No packages removed.\n");
+
+ write_status_files_if_changed();
++ fork_exec("update_plugins_db remove");
+ return err;
+ }
+
--
2.17.1