diff --git a/libs/re/Makefile b/libs/re/Makefile index 5ce0c58..235587b 100644 --- a/libs/re/Makefile +++ b/libs/re/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=re PKG_VERSION:=0.5.6 -PKG_RELEASE:=3 +PKG_RELEASE:=4 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.creytiv.com/pub @@ -45,16 +45,21 @@ endef # LD is changed to TARGET_CC to fix build failures on x86 32bit. Without this # there's no linking to ssp, which results in undefined references. +# used by 001-extend-ninit-nclose-check.patch +TARGET_CFLAGS+=-DOPENWRT + ifneq ($(CONFIG_USE_GLIBC)$(CONFIG_USE_MUSL),) TARGET_CFLAGS+=-D_GNU_SOURCE endif MAKE_FLAGS+= \ + CROSS_COMPILE="$(TARGET_CROSS)" \ EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \ LD="$(TARGET_CC)" \ + OS=linux \ + RELEASE=1 \ SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \ - SYSROOT_ALT="$(STAGING_DIR)/usr" \ - RELEASE=1 + SYSROOT_ALT="$(STAGING_DIR)/usr" define Build/InstallDev $(INSTALL_DIR) $(1)/usr/share/re diff --git a/libs/rem/Makefile b/libs/rem/Makefile index d50ae87..91d42ed 100644 --- a/libs/rem/Makefile +++ b/libs/rem/Makefile @@ -34,14 +34,16 @@ define Package/librem endef MAKE_FLAGS+= \ + CROSS_COMPILE="$(TARGET_CROSS)" \ EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \ LD="$(TARGET_CC)" \ LIBRE_MK="$(STAGING_DIR)/usr/share/re/re.mk" \ LIBRE_INC="$(STAGING_DIR)/usr/include/re" \ LIBRE_SO="$(STAGING_DIR)/usr/lib" \ + OS=linux \ + RELEASE=1 \ SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \ - SYSROOT_ALT="$(STAGING_DIR)/usr" \ - RELEASE=1 + SYSROOT_ALT="$(STAGING_DIR)/usr" define Build/InstallDev $(INSTALL_DIR) $(1)/usr/include diff --git a/net/baresip/Makefile b/net/baresip/Makefile index 958f124..a530821 100644 --- a/net/baresip/Makefile +++ b/net/baresip/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=baresip PKG_VERSION:=0.5.6 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.creytiv.com/pub @@ -65,6 +65,7 @@ define Package/baresip $(call Package/baresip/Default) TITLE:=Portable and modular SIP User-Agent with A/V support DEPENDS:=+libre +librem + USERID:=$(PKG_NAME)=374:$(PKG_NAME)=374 MENU:=1 endef @@ -96,15 +97,17 @@ BARESIP_MOD_OPTIONS:= \ $(foreach m,$(baresip-mods),$(baresip-mod-$(m))=$(if $(CONFIG_PACKAGE_baresip-mod-$(m)),1)) MAKE_FLAGS+= \ + CROSS_COMPILE="$(TARGET_CROSS)" \ EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \ LD="$(TARGET_CC)" \ LIBRE_MK="$(STAGING_DIR)/usr/share/re/re.mk" \ LIBRE_INC="$(STAGING_DIR)/usr/include/re" \ LIBRE_SO="$(STAGING_DIR)/usr/lib" \ LIBREM_PATH="$(STAGING_DIR)/usr" \ + OS=linux \ + RELEASE=1 \ SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \ SYSROOT_ALT="$(STAGING_DIR)/usr" \ - RELEASE=1 \ $(BARESIP_MOD_OPTIONS) TARGET_CFLAGS+=-D_GNU_SOURCE @@ -118,10 +121,38 @@ define Package/baresip/install $(1)/usr/lib/baresip/modules $(INSTALL_DIR) $(1)/usr/share/baresip $(CP) $(PKG_INSTALL_DIR)/usr/share/baresip/* $(1)/usr/share/baresip + $(INSTALL_DIR) $(1)/etc/baresip + $(INSTALL_CONF) $(PKG_BUILD_DIR)/docs/examples/{accounts,config,contacts} $(1)/etc/baresip + $(INSTALL_DIR) $(1)/etc/default + $(INSTALL_CONF) ./files/baresip.default $(1)/etc/default/baresip $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/baresip.init $(1)/etc/init.d/baresip endef +define Package/baresip/conffiles +/etc/baresip/accounts +/etc/baresip/config +/etc/baresip/contacts +/etc/default/baresip +/etc/init.d/baresip +endef + +define Package/baresip/postinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + chown $(PKG_NAME):$(PKG_NAME) \ + /etc/baresip/accounts \ + /etc/baresip/config \ + /etc/baresip/contacts + + # Prevent $(PKG_NAME) from auto-starting after an upgrade. The modules may + # not be upgraded yet and the user configuration may need a revision. + sed -i '/^ENABLE_BARESIP="yes"/s/^/#/' \ + /etc/default/$(PKG_NAME) +fi +exit 0 +endef + ################## # bareSIP modules # 1. Name diff --git a/net/baresip/files/baresip.default b/net/baresip/files/baresip.default new file mode 100644 index 0000000..b251c80 --- /dev/null +++ b/net/baresip/files/baresip.default @@ -0,0 +1,10 @@ +### bareSIP init configuration ### + +# Uncomment once you verified your configuration, otherwise the init script will +# not start bareSIP. +#ENABLE_BARESIP="yes" + +# The following is added to the command line when starting bareSIP: +OPTIONS="" + +# The configuration for the daemon is done in /etc/baresip! diff --git a/net/baresip/files/baresip.init b/net/baresip/files/baresip.init index e398595..c18c985 100644 --- a/net/baresip/files/baresip.init +++ b/net/baresip/files/baresip.init @@ -1,14 +1,91 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2010-2011 OpenWrt.org -# Copyright (C) 2010 Alfred E. Heggestad -# +# Copyright (C) 2017 OpenWrt.org START=92 -start() { - service_start /usr/bin/baresip -d +USE_PROCD=1 + +#PROCD_DEBUG=1 + +DAEMON=baresip +DEFAULT=/etc/default/$DAEMON +LOGGER="/usr/bin/logger -p user.err -s -t $DAEMON" +OPTIONS= +PROG=/usr/bin/$DAEMON +TIMEOUT=30 + +[ -f $DEFAULT ] && . $DEFAULT + +start_service() { + local dir= + + if [ "$ENABLE_BARESIP" != yes ]; then + $LOGGER User configuration incomplete - not starting $DAEMON + $LOGGER Check ENABLE_BARESIP in $DEFAULT + exit 1 + fi + + procd_open_instance + procd_set_param command $PROG + procd_append_param command \ + -f /etc/$DAEMON \ + $OPTIONS + procd_set_param pidfile /var/run/${DAEMON}.pid + # forward stderr to logd + procd_set_param stderr 1 + # forward stdout to logd + #procd_set_param stdout 1 + procd_set_param user $DAEMON + procd_close_instance } -stop() { - service_stop /usr/bin/baresip +stop_service() { + local retval= + local mypid= + local timeout=$TIMEOUT + + pgrep $DAEMON &> /dev/null + [ $? -ne 0 ] && exit 0 + + [ -f /var/run/${DAEMON}.pid ] + retval=$? + + # init script could find itself in a scenario where baresip was started + # very recently, so make it wait a while for a pid file to appear + while [ $retval -ne 0 -a $timeout -gt 0 ]; do + sleep 1 + [ -f /var/run/${DAEMON}.pid ] + retval=$? + timeout=$(($timeout-1)) + done + + [ $retval -eq 0 ] || { + $LOGGER PID file does not exist + exit 1 + } + + mypid=$(cat /var/run/${DAEMON}.pid) + + [ "$mypid" -gt 1 ] 2> /dev/null || { + $LOGGER PID file contains garbage + exit 1 + } + + timeout=$TIMEOUT + kill $mypid 2>/dev/null + pgrep $DAEMON | grep -w $mypid &>/dev/null + retval=$? + + while [ $retval -eq 0 -a $timeout -gt 0 ]; do + sleep 10 + pgrep $DAEMON | grep -w $mypid &>/dev/null + retval=$? + [ $retval -eq 0 ] && kill $mypid 2>/dev/null + timeout=$(($timeout-10)) + done + + [ $retval -ne 1 ] && { + $LOGGER Failed to stop $DAEMON + exit 1 + } } diff --git a/net/baresip/patches/001-fix-linker-call.patch b/net/baresip/patches/001-fix-linker-call.patch deleted file mode 100644 index 0df5ced..0000000 --- a/net/baresip/patches/001-fix-linker-call.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/Makefile -+++ b/Makefile -@@ -199,9 +199,9 @@ libbaresip.pc: - $(BIN): $(APP_OBJS) - @echo " LD $@" - ifneq ($(GPROF),) -- $(HIDE)$(LD) $(LFLAGS) $(APP_LFLAGS) $^ ../re/libre.a $(LIBS) -o $@ -+ $(HIDE)$(LD) $(LFLAGS) $(SH_LFLAGS) $(APP_LFLAGS) $^ ../re/libre.a $(LIBS) -o $@ - else -- $(HIDE)$(LD) $(LFLAGS) $(APP_LFLAGS) $^ \ -+ $(HIDE)$(LD) $(LFLAGS) $(SH_LFLAGS) $(APP_LFLAGS) $^ \ - -L$(LIBRE_SO) -lre $(LIBS) -o $@ - endif - diff --git a/net/restund/Makefile b/net/restund/Makefile index 21c956e..fa53d2e 100644 --- a/net/restund/Makefile +++ b/net/restund/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=restund PKG_VERSION:=0.4.12 -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://www.creytiv.com/pub @@ -39,6 +39,7 @@ define Package/restund $(call Package/restund/Default) TITLE:=Modular STUN/TURN server DEPENDS:=+libre + USERID:=$(PKG_NAME)=373:$(PKG_NAME)=373 endef restund-mod-mysql:=USE_MYSQL @@ -47,14 +48,16 @@ RESTUND_MOD_OPTIONS:= \ $(foreach m,$(restund-mods),$(restund-mod-$(m))=$(if $(CONFIG_PACKAGE_restund-mod-$(m)),1)) MAKE_FLAGS+= \ + CROSS_COMPILE="$(TARGET_CROSS)" \ EXTRA_LFLAGS="$(TARGET_LDFLAGS)" \ LD="$(TARGET_CC)" \ LIBRE_MK="$(STAGING_DIR)/usr/share/re/re.mk" \ LIBRE_INC="$(STAGING_DIR)/usr/include/re" \ LIBRE_SO="$(STAGING_DIR)/usr/lib" \ + OS=linux \ + RELEASE=1 \ SYSROOT="$(shell $(FIND) $(TOOLCHAIN_DIR) -path '*/include/pthread.h' | sed -ne '1s|/include/pthread.h||p')" \ SYSROOT_ALT="$(STAGING_DIR)/usr" \ - RELEASE=1 \ $(RESTUND_MOD_OPTIONS) define Package/restund/install @@ -76,14 +79,31 @@ define Package/restund/install $(SED) \ 's|^\(module_path\)\([ \t]\+\).*$$$$|\1\2/usr/lib/restund/modules|g' \ $(1)/etc/restund.conf + $(INSTALL_DIR) $(1)/etc/default + $(INSTALL_CONF) ./files/restund.default $(1)/etc/default/restund $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/restund.init $(1)/etc/init.d/restund endef define Package/restund/conffiles +/etc/default/restund +/etc/init.d/restund /etc/restund.conf endef +define Package/restund/postinst +#!/bin/sh +if [ -z "$${IPKG_INSTROOT}" ]; then + chown $(PKG_NAME):$(PKG_NAME) /etc/restund.conf + + # Prevent $(PKG_NAME) from auto-starting after an upgrade. The modules may + # not be upgraded yet and the user configuration may need a revision. + sed -i '/^ENABLE_RESTUND="yes"/s/^/#/' \ + /etc/default/$(PKG_NAME) +fi +exit 0 +endef + # # 1. Name # 2. Title diff --git a/net/restund/files/restund.default b/net/restund/files/restund.default new file mode 100644 index 0000000..3e7cbc6 --- /dev/null +++ b/net/restund/files/restund.default @@ -0,0 +1,8 @@ +### restund init configuration ### + +# Uncomment once you verified your configuration, otherwise the init script will +# not start restund. +#ENABLE_RESTUND="yes" + +# The following is added to the command line when starting restund: +OPTIONS="" diff --git a/net/restund/files/restund.init b/net/restund/files/restund.init index d6360ff..ee722ca 100644 --- a/net/restund/files/restund.init +++ b/net/restund/files/restund.init @@ -1,15 +1,91 @@ #!/bin/sh /etc/rc.common -# -# Copyright (C) 2010-2011 OpenWrt.org -# Copyright (C) 2010 Alfred E. Heggestad -# +# Copyright (C) 2017 OpenWrt.org START=60 -start() { - service_start /usr/sbin/restund +USE_PROCD=1 + +#PROCD_DEBUG=1 + +DAEMON=restund +DEFAULT=/etc/default/$DAEMON +LOGGER="/usr/bin/logger -p user.err -s -t $DAEMON" +OPTIONS= +PROG=/usr/sbin/$DAEMON +TIMEOUT=30 + +[ -f $DEFAULT ] && . $DEFAULT + +start_service() { + local dir= + + if [ "$ENABLE_RESTUND" != yes ]; then + $LOGGER User configuration incomplete - not starting $DAEMON + $LOGGER Check ENABLE_RESTUND in $DEFAULT + exit 1 + fi + + procd_open_instance + procd_set_param command $PROG + procd_append_param command \ + -n \ + $OPTIONS + procd_set_param pidfile /var/run/${DAEMON}.pid + # forward stderr to logd + procd_set_param stderr 1 + # forward stdout to logd + procd_set_param stdout 1 + procd_set_param user $DAEMON + procd_close_instance } -stop() { - service_stop /usr/sbin/restund +stop_service() { + local retval= + local mypid= + local timeout=$TIMEOUT + + pgrep $DAEMON &> /dev/null + [ $? -ne 0 ] && exit 0 + + [ -f /var/run/${DAEMON}.pid ] + retval=$? + + # init script could find itself in a scenario where restund was started + # very recently, so make it wait a while for a pid file to appear + while [ $retval -ne 0 -a $timeout -gt 0 ]; do + sleep 1 + [ -f /var/run/${DAEMON}.pid ] + retval=$? + timeout=$(($timeout-1)) + done + + [ $retval -eq 0 ] || { + $LOGGER PID file does not exist + exit 1 + } + + mypid=$(cat /var/run/${DAEMON}.pid) + + [ "$mypid" -gt 1 ] 2> /dev/null || { + $LOGGER PID file contains garbage + exit 1 + } + + timeout=$TIMEOUT + kill $mypid 2>/dev/null + pgrep $DAEMON | grep -w $mypid &>/dev/null + retval=$? + + while [ $retval -eq 0 -a $timeout -gt 0 ]; do + sleep 10 + pgrep $DAEMON | grep -w $mypid &>/dev/null + retval=$? + [ $retval -eq 0 ] && kill $mypid 2>/dev/null + timeout=$(($timeout-10)) + done + + [ $retval -ne 1 ] && { + $LOGGER Failed to stop $DAEMON + exit 1 + } } diff --git a/net/restund/patches/001-fix-linker-call.patch b/net/restund/patches/001-fix-linker-call.patch deleted file mode 100644 index abae86c..0000000 --- a/net/restund/patches/001-fix-linker-call.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/Makefile -+++ b/Makefile -@@ -99,9 +99,9 @@ all: $(MOD_BINS) $(BIN) - $(BIN): $(OBJS) - @echo " LD $@" - ifneq ($(GPROF),) -- @$(LD) $(LFLAGS) $(APP_LFLAGS) $^ ../re/libre.a $(LIBS) -o $@ -+ @$(LD) $(LFLAGS) $(SH_LFLAGS) $(APP_LFLAGS) $^ ../re/libre.a $(LIBS) -o $@ - else -- @$(LD) $(LFLAGS) $(APP_LFLAGS) $^ -L$(LIBRE_SO) -lre $(LIBS) -o $@ -+ @$(LD) $(LFLAGS) $(SH_LFLAGS) $(APP_LFLAGS) $^ -L$(LIBRE_SO) -lre $(LIBS) -o $@ - endif - - $(BUILD)/%.o: %.c $(BUILD) Makefile $(APP_MK)