Revert procd to fix issue #50
authorRISCi_ATOM <bob@bobcall.me>
Mon, 2 Apr 2018 07:13:47 +0000 (03:13 -0400)
committerRISCi_ATOM <bob@bobcall.me>
Mon, 2 Apr 2018 07:13:47 +0000 (03:13 -0400)
package/system/procd/Makefile
package/system/procd/files/hotplug-preinit.json
package/system/procd/files/hotplug.json
package/system/procd/files/procd.sh

index 986a1424b0c0911c6e5116f3ec1431450a5567bb..e8541cac66f6b7522d3f37fda088449f7ba8f57e 100644 (file)
@@ -8,13 +8,13 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=procd
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_URL=$(PROJECT_GIT)/project/procd.git
+PKG_SOURCE_URL=$(LEDE_GIT)/project/procd.git
 PKG_SOURCE_DATE:=2018-01-23
-PKG_SOURCE_VERSION:=653629f19e591a0827ab39de07b4526bb119a57a
-PKG_MIRROR_HASH:=2e0c3ae45521eea456a8411c8d9ef19ed9a5ed6c0ab38b9496555625fb4ba6a2
+PKG_SOURCE_VERSION:=9a4036fb1b7412ab2ea4f360d2cc7e6a5e0fa6b5
+PKG_MIRROR_HASH:=669f062e9c5228ef9d09cc9904d8ce4651f0b8506a6c2fff27b21e83b26f0abb
 CMAKE_INSTALL:=1
 
 PKG_LICENSE:=GPL-2.0
@@ -22,9 +22,11 @@ PKG_LICENSE_FILES:=
 
 PKG_MAINTAINER:=John Crispin <john@phrozen.org>
 
+PKG_FLAGS:=nonshared
+
 PKG_CONFIG_DEPENDS:= \
        CONFIG_TARGET_INIT_PATH CONFIG_KERNEL_SECCOMP \
-       CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \
+       CONFIG_NAND_SUPPORT CONFIG_PROCD_SHOW_BOOT CONFIG_PROCD_ZRAM_TMPFS \
        CONFIG_KERNEL_NAMESPACES CONFIG_PACKAGE_procd-ujail CONFIG_PACKAGE_procd-seccomp
 
 include $(INCLUDE_DIR)/package.mk
@@ -40,7 +42,7 @@ TARGET_LDFLAGS += $(if $(CONFIG_USE_GLIBC),-lrt)
 define Package/procd
   SECTION:=base
   CATEGORY:=Base system
-  DEPENDS:=+ubusd +ubus +libjson-script +flock +ubox +USE_GLIBC:librt +libubox +libubus
+  DEPENDS:=+ubusd +ubus +libjson-script +ubox +USE_GLIBC:librt +libubox +libubus +NAND_SUPPORT:procd-nand
   TITLE:=OpenWrt system process manager
 endef
 
@@ -58,6 +60,20 @@ define Package/procd-seccomp
   TITLE:=OpenWrt process seccomp helper + utrace
 endef
 
+define Package/procd-nand
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=@NAND_SUPPORT +ubi-utils
+  TITLE:=OpenWrt sysupgrade nand helper
+endef
+
+define Package/procd-nand-firstboot
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=procd-nand
+  TITLE:=OpenWrt firstboot nand helper
+endef
+
 define Package/procd/config
 menu "Configuration"
        depends on PACKAGE_procd
@@ -75,6 +91,10 @@ endmenu
 endef
 
 
+ifeq ($(CONFIG_NAND_SUPPORT),y)
+  CMAKE_OPTIONS += -DBUILD_UPGRADED=1
+endif
+
 ifeq ($(CONFIG_PROCD_SHOW_BOOT),y)
   CMAKE_OPTIONS += -DSHOW_BOOT_ON_CONSOLE=1
 endif
@@ -93,7 +113,7 @@ CMAKE_OPTIONS += -DSECCOMP_SUPPORT=$(SECCOMP) -DUTRACE_SUPPORT=$(SECCOMP)
 define Package/procd/install
        $(INSTALL_DIR) $(1)/sbin $(1)/etc $(1)/lib/functions
 
-       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger,upgraded} $(1)/sbin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{init,procd,askfirst,udevtrigger} $(1)/sbin/
        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libsetlbf.so $(1)/lib
        $(INSTALL_BIN) ./files/reload_config $(1)/sbin/
        $(INSTALL_DATA) ./files/hotplug*.json $(1)/etc/
@@ -109,10 +129,25 @@ define Package/procd-seccomp/install
        $(INSTALL_DIR) $(1)/sbin $(1)/lib
        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-seccomp.so $(1)/lib
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/utrace $(1)/sbin/
-       $(LN) utrace $(1)/sbin/seccomp-trace
+       ln -s utrace $(1)/sbin/seccomp-trace
        $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libpreload-trace.so $(1)/lib
 endef
 
+define Package/procd-nand/install
+       $(INSTALL_DIR) $(1)/sbin $(1)/lib/upgrade
+
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/upgraded $(1)/sbin/
+       $(INSTALL_DATA) ./files/nand.sh $(1)/lib/upgrade/
+endef
+
+define Package/procd-nand-firstboot/install
+       $(INSTALL_DIR) $(1)/lib/preinit
+
+       $(INSTALL_DATA) ./files/nand-preinit.sh $(1)/lib/preinit/60-nand-firstboot.sh
+endef
+
 $(eval $(call BuildPackage,procd))
 $(eval $(call BuildPackage,procd-ujail))
 $(eval $(call BuildPackage,procd-seccomp))
+$(eval $(call BuildPackage,procd-nand))
+$(eval $(call BuildPackage,procd-nand-firstboot))
index 658c685474fe0e31dd2667662d07ba037661c147..58afc6c696ff546f0f5da20fb9fc131f1afbd77c 100644 (file)
@@ -8,11 +8,11 @@
                                        [ "load-firmware", "/lib/firmware" ],
                                        [ "return" ]
                                ]
-                       ]
-               ]
-       } ],
+                       ],
+               ],
+       }, ],
        [ "if",
                [ "eq", "SUBSYSTEM", "button" ],
                [ "exec", "/etc/rc.button/failsafe" ]
-       ]
+       ],
 ]
index 1c949bbea33a0c066934aef92d53d6a096192013..e5f8d967e8c16c8dc85a437a5259c0ba840d766c 100644 (file)
@@ -4,27 +4,27 @@
                        [ "if",
                                [ "and",
                                        [ "has", "MAJOR" ],
-                                       [ "has", "MINOR" ]
+                                       [ "has", "MINOR" ],
                                ],
                                [
                                        [ "if",
                                                [ "eq", "DEVNAME",
-                                                       [ "null", "full", "ptmx", "zero", "tty", "net", "random", "urandom" ]
+                                                       [ "null", "full", "ptmx", "zero", "tty", "net", "random", "urandom" ],
                                                ],
                                                [
                                                        [ "makedev", "/dev/%DEVNAME%", "0666" ],
-                                                       [ "return" ]
+                                                       [ "return" ],
                                                ]
                                        ],
                                        [ "if",
                                                [ "regex", "DEVNAME", "^snd" ],
-                                               [ "makedev", "/dev/%DEVNAME%", "0660", "audio" ]
+                                               [ "makedev", "/dev/%DEVNAME%", "0660", "audio" ],
                                        ],
                                        [ "if",
                                                [ "has", "DEVNAME" ],
-                                               [ "makedev", "/dev/%DEVNAME%", "0600" ]
-                                       ]
-                               ]
+                                               [ "makedev", "/dev/%DEVNAME%", "0600" ],
+                                       ],
+                               ],
                        ],
                        [ "if",
                                [ "has", "FIRMWARE" ],
                                        [ "load-firmware", "/lib/firmware" ],
                                        [ "return" ]
                                ]
-                       ]
+                       ],
                ],
                "remove" : [
                        [ "if",
                                [ "and",
                                        [ "has", "DEVNAME" ],
                                        [ "has", "MAJOR" ],
-                                       [ "has", "MINOR" ]
+                                       [ "has", "MINOR" ],
                                ],
                                [ "rm", "/dev/%DEVNAME%" ]
                        ]
@@ -49,7 +49,7 @@
        [ "if",
                [ "and",
                        [ "has", "BUTTON" ],
-                       [ "eq", "SUBSYSTEM", "button" ]
+                       [ "eq", "SUBSYSTEM", "button" ],
                ],
                [ "button", "/etc/rc.button/%BUTTON%" ]
        ],
@@ -65,5 +65,5 @@
                        [ "isdir", "/etc/hotplug.d/%SUBSYSTEM%" ],
                        [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
                ]
-       ]
+       ],
 ]
index 6f16b746ffb42c3c7eeba9fed628676a8eb3e761..e6ca8a6bc924fe65d8832f96a203d0a6edabf987 100644 (file)
 #   Send a signal to a service instance (or all instances)
 #
 
-. "$IPKG_INSTROOT/usr/share/libubox/jshn.sh"
+. $IPKG_INSTROOT/usr/share/libubox/jshn.sh
 
 PROCD_RELOAD_DELAY=1000
 _PROCD_SERVICE=
 
-procd_lock() {
-       local basescript=$(readlink "$initscript")
-       local service_name="$(basename ${basescript:-$initscript})"
-
-       flock -n 1000 &> /dev/null
-       if [ "$?" != "0" ]; then
-               exec 1000>"$IPKG_INSTROOT/var/lock/procd_${service_name}.lock"
-               flock 1000
-               if [ "$?" != "0" ]; then
-                       logger "warning: procd flock for $service_name failed"
-               fi
-       fi
-}
-
 _procd_call() {
        local old_cb
 
@@ -61,7 +47,6 @@ _procd_call() {
 }
 
 _procd_wrapper() {
-       procd_lock
        while [ -n "$1" ]; do
                eval "$1() { _procd_call _$1 \"\$@\"; }"
                shift
@@ -94,9 +79,6 @@ _procd_close_service() {
        _procd_open_trigger
        service_triggers
        _procd_close_trigger
-       _procd_open_data
-       service_data
-       _procd_close_data
        _procd_ubus_call ${1:-set}
 }
 
@@ -152,18 +134,6 @@ _procd_close_trigger() {
        json_close_array
 }
 
-_procd_open_data() {
-       let '_procd_data_open = _procd_data_open + 1'
-       [ "$_procd_data_open" -gt 1 ] && return
-       json_add_object "data"
-}
-
-_procd_close_data() {
-       let '_procd_data_open = _procd_data_open - 1'
-       [ "$_procd_data_open" -lt 1 ] || return
-       json_close_object
-}
-
 _procd_open_validate() {
        json_select ..
        json_add_array "validate"
@@ -243,7 +213,7 @@ _procd_set_param() {
                        json_add_string "" "$@"
                        json_close_array
                ;;
-               nice|term_timeout)
+               nice)
                        json_add_int "$type" "$1"
                ;;
                reload_signal)
@@ -413,10 +383,6 @@ _procd_send_signal() {
        local instance="$2"
        local signal="$3"
 
-       case "$signal" in
-               [A-Z]*) signal="$(kill -l "$signal" 2>/dev/null)" || return 1;;
-       esac
-
        json_init
        json_add_string name "$service"
        [ -n "$instance" -a "$instance" != "*" ] && json_add_string instance "$instance"