xupnpd: Update to latest version, switch to procd and add parameter for root directory
authorHauke Mehrtens <hauke@hauke-m.de>
Sat, 3 May 2014 11:29:26 +0000 (11:29 +0000)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 3 May 2014 11:29:26 +0000 (11:29 +0000)
Update to latest version, switch to procd and add parameter for root directory.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
SVN-Revision: 40674

multimedia/xupnpd/Makefile
multimedia/xupnpd/files/xupnpd.init
multimedia/xupnpd/patches/101-root_dir_param.patch [new file with mode: 0644]

index 3d3f0154203995997ba386f0d734964ee0076c33..2ec40a9b34cdbf68695510f91b173c04bb75acfe 100644 (file)
@@ -8,9 +8,9 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=xupnpd
-PKG_REV:=387
+PKG_REV:=398
 PKG_VERSION:=$(PKG_REV)
-PKG_RELEASE:=5
+PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=svn
 PKG_SOURCE_VERSION:=$(PKG_REV)
index eddd0f497425d56a978ab9c98446fa0acdb55ed4..29c458a9a41075f2305b70dd800c49721b559aad 100644 (file)
@@ -1,23 +1,15 @@
 #!/bin/sh /etc/rc.common
-# Copyright (C) 2013 OpenWrt.org
+# Copyright (C) 2013-2014 OpenWrt.org
 
-START=99
-STOP=99
+START=50
+USE_PROCD=1
 
-SERVICE_DAEMONIZE=1
-SERVICE_WRITE_PID=1
+start_service() {
+       procd_open_instance
 
-XUPNPDROOTDIR=/usr/share/xupnpd
-XUPNPD=/usr/bin/xupnpd
+       procd_set_param command /usr/bin/xupnpd
+       procd_append_param command -d /usr/share/xupnpd
 
-start() {
-        service_start $XUPNPD
-}
-
-stop() {
-        service_stop $XUPNPD
-}
-
-reload() {
-        service_reload $XUPNPD
+       procd_set_param respawn
+       procd_close_instance
 }
diff --git a/multimedia/xupnpd/patches/101-root_dir_param.patch b/multimedia/xupnpd/patches/101-root_dir_param.patch
new file mode 100644 (file)
index 0000000..68ea3e8
--- /dev/null
@@ -0,0 +1,83 @@
+--- a/main.cpp
++++ b/main.cpp
+@@ -4,11 +4,14 @@
+  * https://tsdemuxer.googlecode.com/svn/trunk/xupnpd
+  */
++#include <ctype.h>
+ #include <stdio.h>
+ #include <syslog.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <stdlib.h>
++#include <sys/stat.h>
++#include <sys/types.h>
+ #include "luacompat.h"
+ #include "luaxlib.h"
+ #include "luaxcore.h"
+@@ -16,35 +19,36 @@
+ int main(int argc,char** argv)
+ {
+-    const char* p=strrchr(argv[0],'/');
+-
+-    int rc;
+-
+-    if(p)
+-    {
+-        char location[512];
+-        int n=p-argv[0];
+-        if(n>=sizeof(location))
+-            n=sizeof(location)-1;
+-        strncpy(location,argv[0],n);
+-        location[n]=0;
+-
+-        rc=chdir(location);
+-
+-        argv[0]=(char*)p+1;
+-    }
+-
+-    const char* root=getenv("XUPNPDROOTDIR");
+-    if(root && *root)
+-        rc=chdir(root);
+-
+-    {
+-        FILE* fp=fopen("xupnpd.lua","r");
+-        if(fp)
+-            fclose(fp);
+-        else
+-            rc=chdir("/usr/share/xupnpd/");
+-    }
++      int c;
++      char *xupnpd_root = "/usr/share/xupnpd/";
++      struct stat s;
++
++      opterr = 0;
++      while ((c = getopt (argc, argv, "d:")) != -1) {
++              switch (c) {
++                      case 'd':
++                              xupnpd_root = optarg;
++                              break;
++                      case '?':
++                              if (optopt == 'd')
++                                      fprintf(stderr, "Option -%c requires an argument.\n", optopt);
++                              else if (isprint(optopt))
++                                      fprintf(stderr, "Unknown option \"-%c\".\n", optopt);
++                              else
++                                      fprintf(stderr, "Unknown option\n");
++                                      return 1;
++                      default:
++                              abort();
++              }
++      }
++
++      if(stat(xupnpd_root, &s) != -1 && S_ISDIR(s.st_mode)) {
++              c = chdir(xupnpd_root);
++      }
++      else {
++              fprintf(stderr, "Directory %s doesn't exist.\n", xupnpd_root);
++              return 1;
++      }
+     lua_State* L=lua_open();
+     if(L)