]> git.webhop.me Git - bs-cst-neutrino-hd.git/commitdiff
use killall5 from sysvinit
authorMarkham <markham001@gmx.de>
Wed, 5 Oct 2022 19:45:17 +0000 (21:45 +0200)
committerMarkham <markham001@gmx.de>
Wed, 5 Oct 2022 19:45:17 +0000 (21:45 +0200)
Makefile
archive-patches/busybox-1.35.0-arm.config
archive-patches/sysvinit/patches/0001-crypt-lib.patch [new file with mode: 0644]
archive-patches/sysvinit/patches/0002-change-INIT_FIFO.patch [new file with mode: 0644]
archive-patches/sysvinit/patches/0003-pidof-add-m-option.patch [new file with mode: 0644]
archive-patches/sysvinit/patches/0004-realpath.patch [new file with mode: 0644]
archive-patches/ushare/ushare.init
make/bootstrap.mk
make/sysvinit.mk [new file with mode: 0644]

index 41205f888fba7e77250c79db33e8f3620d33431f..516d7a78efb35ce44eafd875e5ece5757449825b 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,7 @@ include make/rtl8812au.mk
 include make/rtl8822bu.mk
 include make/neutrino.mk
 include make/libraries.mk
+include make/sysvinit.mk
 include make/system-tools.mk
 include make/ofgwrite.mk
 include make/applications.mk
index 78a86d5513664467623c1866419df67148d03492..11385e91163759b8a74e68bcde2d409e5b4540ad 100644 (file)
@@ -1054,7 +1054,7 @@ CONFIG_MPSTAT=y
 # CONFIG_NMETER is not set
 # CONFIG_PGREP is not set
 # CONFIG_PKILL is not set
-CONFIG_PIDOF=y
+# CONFIG_PIDOF is not set
 # CONFIG_FEATURE_PIDOF_SINGLE is not set
 # CONFIG_FEATURE_PIDOF_OMIT is not set
 CONFIG_PMAP=y
diff --git a/archive-patches/sysvinit/patches/0001-crypt-lib.patch b/archive-patches/sysvinit/patches/0001-crypt-lib.patch
new file mode 100644 (file)
index 0000000..4f87c0f
--- /dev/null
@@ -0,0 +1,33 @@
+Upstream-Status: Inappropriate [configuration]
+
+# The src Makefile was checking for libcrypt.a on the host, not in the
+# build environment.  This patch checks for $LCRYPT in the environment
+# and uses it if it's there.
+# - jdike@linux.intel.com
+
+Index: sysvinit-2.96/src/Makefile
+===================================================================
+diff --git a/src/Makefile b/src/Makefile
+index 9f9f09e..9ae35df 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -89,6 +89,10 @@ else
+   SULOGINLIBS =
+ endif
++ifneq ($(LCRYPT),)
++  SULOGINLIBS += $(LCRYPT)
++else
++
+ # Additional libs for GNU libc.
+ ifneq ($(wildcard /usr/lib*/libcrypt.*),)
+   SULOGINLIBS += -lcrypt
+@@ -99,6 +103,8 @@ ifneq ($(wildcard /usr/lib/*/libcrypt.*),)
+   SULOGINLIBS += -lcrypt
+ endif
++endif
++
+ all:          $(BIN) $(SBIN) $(USRBIN)
+ #%: %.o
diff --git a/archive-patches/sysvinit/patches/0002-change-INIT_FIFO.patch b/archive-patches/sysvinit/patches/0002-change-INIT_FIFO.patch
new file mode 100644 (file)
index 0000000..c9a644e
--- /dev/null
@@ -0,0 +1,13 @@
+diff --git a/src/initreq.h b/src/initreq.h
+index ee8a355..102b667 100644
+--- a/src/initreq.h
++++ b/src/initreq.h
+@@ -26,7 +26,7 @@
+ #include <sys/param.h>
+ #ifndef INIT_FIFO
+-#define INIT_FIFO  "/run/initctl"
++#define INIT_FIFO  "/dev/initctl"
+ #endif
+ #define INIT_MAGIC 0x03091969
diff --git a/archive-patches/sysvinit/patches/0003-pidof-add-m-option.patch b/archive-patches/sysvinit/patches/0003-pidof-add-m-option.patch
new file mode 100644 (file)
index 0000000..265ee07
--- /dev/null
@@ -0,0 +1,191 @@
+From 6c490ea6579a132fabb7dbd25387bb521f820371 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Wed, 24 Jul 2013 17:07:22 +0800
+Subject: [PATCH] pidof: add -m option
+
+When used with -o, will also omit any processes that have the same
+argv[0] and argv[1] as any explicitly omitted process ids. This can be
+used to avoid multiple shell scripts concurrently calling pidof returning
+each other's pids.
+
+https://bugzilla.redhat.com/show_bug.cgi?id=883856
+
+Upstream-Status: backport
+Imported patch from: https://bugzilla.redhat.com/attachment.cgi?id=658166
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ man/pidof.8    |  6 +++++
+ src/killall5.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++---
+ 2 files changed, 65 insertions(+), 3 deletions(-)
+
+diff --git a/man/pidof.8 b/man/pidof.8
+index ebe5f55..2fdc4d3 100644
+--- a/man/pidof.8
++++ b/man/pidof.8
+@@ -25,6 +25,7 @@ pidof -- find the process ID of a running program.
+ .RB [ \-n ]
+ .RB [ \-x ]
+ .RB [ \-z ]
++.RB [ \-m ]
+ .RB [ \-o
+ .IR omitpid[,omitpid...] ]
+ .RB [ \-o
+@@ -76,6 +77,11 @@ is shown. The default separator is a space.
+ Tells \fIpidof\fP to omit processes with that process id. The special
+ pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP
+ program, in other words the calling shell or shell script.
++.IP -m
++When used with -o, will also omit any processes that have the same
++argv[0] and argv[1] as any explicitly omitted process ids. This can be
++used to avoid multiple shell scripts concurrently calling pidof returning
++each other's pids.
+ .SH "EXIT STATUS"
+ .TP
+ .B 0
+diff --git a/src/killall5.c b/src/killall5.c
+index 8b5cb38..a664954 100644
+--- a/src/killall5.c
++++ b/src/killall5.c
+@@ -126,6 +126,7 @@
+ /* List of processes. */
+ PROC *plist;
++PROC *olist;
+ /* List of processes to omit. */
+ OMIT *omit;
+@@ -357,6 +358,20 @@
+               }
+               if (p->shadow)
+                       clear_shadow(p->shadow);
++              free(p);
++      }
++}
++
++static void clear_omit(void)
++{
++      OMIT *o;
++      PROC *p;
++      for (o = omit; o; o = omit) {
++              omit = omit->next;
++              free(o);
++      }
++      for (p = olist; p; p = olist) {
++              olist = olist->next;
+               free(p);
+       }
+ }
+@@ -486,6 +501,7 @@
+       DIR             *dir;
+       FILE            *fp;
+       PROC            *p, *n;
++      OMIT            *o, *m;
+       struct dirent   *d;
+       struct stat     st;
+       char            path[PATH_MAX+1];
+@@ -726,6 +742,17 @@
+               p->next = plist;
+               plist = p;
+               p->pid = pid;
++              /* Could be smarter, but it's a small list. */
++              m = omit;
++              for (o = omit; m; o = m) {
++                      m = o->next;
++                      if (o->pid == p->pid) {
++                              n = (PROC*)xmalloc(sizeof(PROC));
++                              *n = *p;
++                              n->next = olist;
++                              olist = n;
++                      }
++              }
+       }
+       closedir(dir);
+@@ -937,6 +964,26 @@
+       return q;
+ }
++int matches(PROC *o, PROC *p)
++{
++      int ret = 0;
++      char *oargv1, *pargv1;
++      if ((o->argv0 && p->argv0 && !strcmp(o->argv0,p->argv0))) {
++              if (o->argv1 && p->argv1) {
++                      if ((oargv1 = canonicalize_file_name(o->argv1)) == NULL)
++                              oargv1 = strdup(o->argv1);
++                      if ((pargv1 = canonicalize_file_name(p->argv1)) == NULL)
++                              pargv1 = strdup(p->argv1);
++                      if (! strcmp(oargv1, pargv1)) {
++                              ret = 1;
++                      }
++                      free(oargv1);
++                      free(pargv1);
++              }
++      }
++      return ret;
++}
++
+ /* Give usage message and exit. */
+ void usage(void)
+ {
+@@ -987,6 +1034,7 @@
+ #define PIDOF_OMIT    0x02
+ #define PIDOF_NETFS   0x04
+ #define PIDOF_QUIET     0x08
++#define PIDOF_OMIT_OMIT_MATCHES       0x08
+ /*
+  *    Pidof functionality.
+@@ -1004,6 +1052,7 @@
+       char            tmp[512];
+         char            sep = ' ';
++      olist = (PROC*)0;
+       omit = (OMIT*)0;
+       nlist = (NFS*)0;
+       opterr = 0;
+@@ -1011,7 +1060,7 @@
+       if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0))
+               flags |= PIDOF_NETFS;
+-      while ((opt = getopt(argc,argv,"qhco:d:sxzn")) != EOF) switch (opt) {
++      while ((opt = getopt(argc,argv,"qhcmo:d:sxzn")) != EOF) switch (opt) {
+               case '?':
+                       nsyslog(LOG_ERR,"invalid options on command line!\n");
+                       closelog();
+@@ -1062,6 +1111,9 @@
+                 case 'z':
+                         list_dz_processes = TRUE;
+                         break;
++              case 'm':
++                      flags |= PIDOF_OMIT_OMIT_MATCHES;
++                      break;
+               case 'n':
+                       flags |= PIDOF_NETFS;
+                       break;
+@@ -1093,10 +1145,13 @@
+                       pid_t spid = 0;
+                       while ((p = get_next_from_pid_q(q))) {
+                               if ((flags & PIDOF_OMIT) && omit) {
+-                                      OMIT * optr;
+-                                      for (optr = omit; optr; optr = optr->next) {
++                                      PROC * optr;
++                                      for (optr = olist; optr; optr = optr->next) {
+                                               if (optr->pid == p->pid)
+                                                       break;
++                                              if (flags & PIDOF_OMIT_OMIT_MATCHES)
++                                                      if (matches(optr, p))
++                                                              break;
+                                       }
+                                       /*
+@@ -1138,6 +1193,7 @@
+               printf("\n");
+         }
++      clear_omit();
+       clear_mnt();
+       closelog();
diff --git a/archive-patches/sysvinit/patches/0004-realpath.patch b/archive-patches/sysvinit/patches/0004-realpath.patch
new file mode 100644 (file)
index 0000000..d75e550
--- /dev/null
@@ -0,0 +1,59 @@
+From eb158c97f19d473d01befe96359a7f93ae834517 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Thu, 19 Nov 2015 00:10:03 +0000
+Subject: [PATCH] Fix build on musl use realpath() API its available on all
+ libcs
+
+realpath() API doesnt work on systems with PATH_MAX set to be unlimited e.g. GNU/Hurd
+However for Linux it should always work
+
+Upstream-Status: Inappropriate[Linux specific]
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+---
+ src/killall5.c   | 4 ++--
+ src/mountpoint.c | 1 +
+ src/wall.c       | 1 +
+ 3 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/src/killall5.c b/src/killall5.c
+index a664954..9798423 100644
+--- a/src/killall5.c
++++ b/src/killall5.c
+@@ -970,9 +970,9 @@
+       char *oargv1, *pargv1;
+       if ((o->argv0 && p->argv0 && !strcmp(o->argv0,p->argv0))) {
+               if (o->argv1 && p->argv1) {
+-                      if ((oargv1 = canonicalize_file_name(o->argv1)) == NULL)
++                      if ((oargv1 = realpath(o->argv1, NULL)) == NULL)
+                               oargv1 = strdup(o->argv1);
+-                      if ((pargv1 = canonicalize_file_name(p->argv1)) == NULL)
++                      if ((pargv1 = realpath(p->argv1, NULL)) == NULL)
+                               pargv1 = strdup(p->argv1);
+                       if (! strcmp(oargv1, pargv1)) {
+                               ret = 1;
+diff --git a/src/mountpoint.c b/src/mountpoint.c
+index b24335e..5f20522 100644
+--- a/src/mountpoint.c
++++ b/src/mountpoint.c
+@@ -23,6 +23,7 @@
+  *            Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
++#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include <stdlib.h>
+diff --git a/src/wall.c b/src/wall.c
+index d3a2c70..00826e9 100644
+--- a/src/wall.c
++++ b/src/wall.c
+@@ -30,6 +30,7 @@
+ #include <pwd.h>
+ #include <syslog.h>
+ #include <sys/types.h>
++#include <time.h>
+ #include "init.h"
index a85e63fcae530b0c3f45339d7fe45ea6be05e5c5..f6fbf4355a05d4d91854c0dc19145f2e771f5c9f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 timeout=10
-if [ $2 = 1 ]; then
+if [ "$2" = 1 ]; then
        timeout=0
 fi
 echo $timeout
index 6f42563f7319b35c22af8104a5892aaebcc8780b..10b312e0f57eae4fa5623d5dd78bb5c0ba3f2549 100755 (executable)
@@ -22,7 +22,8 @@ endif
 
 bootstrap: $(BOOTSTRAP)
 
-SYSTEM_TOOLS  = $(D)/busybox
+SYSTEM_TOOLS  = $(D)/sysvinit
+SYSTEM_TOOLS += $(D)/busybox
 SYSTEM_TOOLS += $(D)/zlib
 SYSTEM_TOOLS += $(D)/lzo
 SYSTEM_TOOLS += $(D)/e2fsprogs
diff --git a/make/sysvinit.mk b/make/sysvinit.mk
new file mode 100644 (file)
index 0000000..6366585
--- /dev/null
@@ -0,0 +1,31 @@
+################################################################################
+#
+# sysvinit
+#
+################################################################################
+
+SYSVINIT_VERSION = 3.04
+SYSVINIT_DIR = sysvinit-$(SYSVINIT_VERSION)
+SYSVINIT_SOURCE = sysvinit-$(SYSVINIT_VERSION).tar.xz
+SYSVINIT_SITE = http://download.savannah.nongnu.org/releases/sysvinit
+
+SYSVINIT_PATCH  = 0001-crypt-lib.patch
+SYSVINIT_PATCH += 0002-change-INIT_FIFO.patch
+SYSVINIT_PATCH += 0003-pidof-add-m-option.patch
+SYSVINIT_PATCH += 0004-realpath.patch
+
+$(ARCHIVE)/$(SYSVINIT_SOURCE):
+       $(WGET) $(SYSVINIT_SITE)/$(SYSVINIT_SOURCE)
+
+$(D)/sysvinit: $(ARCHIVE)/$(SYSVINIT_SOURCE) | $(TARGETPREFIX)
+       $(START_BUILD)
+       $(REMOVE)/$(SYSVINIT_DIR)
+       $(UNTAR)/$(SYSVINIT_SOURCE)
+       pushd $(BUILD_TMP)/$(SYSVINIT_DIR); \
+               $(call apply_patches, $(addprefix sysvinit/patches/, $(SYSVINIT_PATCH))); \
+               $(MAKE) -C src CC=$(TARGET)-gcc $(BUILDENV) ULOGINLIBS="-lcrypt"; \
+       install -m 0755 $(BUILD_TMP)/$(SYSVINIT_DIR)/src/killall5 $(TARGETPREFIX)/sbin
+       pushd $(TARGETPREFIX)/bin; \
+               ln -sf /sbin/killall5 pidof
+       $(REMOVE)/$(SYSVINIT_DIR)
+       $(TOUCH)