[126548] trunk/dports/net/ushare

ctreleaven at macports.org ctreleaven at macports.org
Sat Oct 11 18:22:42 PDT 2014


Revision: 126548
          https://trac.macports.org/changeset/126548
Author:   ctreleaven at macports.org
Date:     2014-10-11 18:22:42 -0700 (Sat, 11 Oct 2014)
Log Message:
-----------
add patches for updated libupnp, fix segfaults, add startupitem and notes, add license

Modified Paths:
--------------
    trunk/dports/net/ushare/Portfile

Added Paths:
-----------
    trunk/dports/net/ushare/files/patch-add_std_includes.diff
    trunk/dports/net/ushare/files/patch-ushare-upnp-build-fix.diff

Modified: trunk/dports/net/ushare/Portfile
===================================================================
--- trunk/dports/net/ushare/Portfile	2014-10-12 01:01:19 UTC (rev 126547)
+++ trunk/dports/net/ushare/Portfile	2014-10-12 01:22:42 UTC (rev 126548)
@@ -5,9 +5,11 @@
 
 name                ushare
 version             1.1a
-revision            3
+revision            4
 categories          net multimedia
 platforms           darwin
+supported_archs     x86_64
+# libdlna does not support i386
 maintainers         nomaintainer
 description         a UPnP (TM) A/V & DLNA Media Server
 long_description \
@@ -25,14 +27,17 @@
                         --enable-dlna
 
 homepage            http://ushare.geexbox.org/
+license             GPL-2+
 master_sites        ${homepage}releases
 use_bzip2           yes
 checksums           md5 5bbcdbf1ff85a9710fa3d4e82ccaa251
+
 patchfiles          patch-configure.diff
+# following prevents segfaults
+patchfiles-append   patch-add_std_includes.diff
+# following required due to libupnp changes
+patchfiles-append   patch-ushare-upnp-build-fix.diff
 
-# libdlna isn't universal
-universal_variant no
-
 configure.cflags-append     -std=gnu89 -I${prefix}/include -I${worksrcpath}
 configure.ldflags-append    -lintl
 
@@ -41,3 +46,22 @@
     file rename ${destroot}${prefix}/etc/ushare.conf \
         ${destroot}${prefix}/etc/ushare.conf.sample
 }
+
+universal_variant no
+
+startupitem.create      yes
+startupitem.netchange   yes
+startupitem.executable  ${prefix}/bin/uShare --cfg=${prefix}/etc/ushare.conf
+
+notes "
+****  ${name}  ****
+Before running ${name}, you must configure it by creating and editing:
+>>  ${prefix}/etc/ushare.conf
+${prefix}/etc/ushare.conf.sample is provided as a template.
+
+Note that ${name} runs as root.  This poses a security risk and you should not use
+${name} on internet-facing machine
+
+When loaded, you may be able to configure ${name} with a web browser at
+>>  <ip.addr.of.host>:<port>/web/ushare.html
+"

Added: trunk/dports/net/ushare/files/patch-add_std_includes.diff
===================================================================
--- trunk/dports/net/ushare/files/patch-add_std_includes.diff	                        (rev 0)
+++ trunk/dports/net/ushare/files/patch-add_std_includes.diff	2014-10-12 01:22:42 UTC (rev 126548)
@@ -0,0 +1,70 @@
+See https://bugs.archlinux.org/task/24866
+Comment by Anton Komolov (xRemaLx) - Tuesday, 21 February 2012, 06:17 GMT
+On my system (64bit), I use this patch for a month. No more segfaults :)
+Problem is solved by the patch: mixing 32-bit and 64 bit pointers. This happens 
+if the compiler does not find a definition of the standard functions in header 
+files. On a 64 bit system automatically uses the 64 bit function, even though 
+the program is 32 bit.
+
+
+--- src/cds.c	2007-12-09 16:03:36.000000000 +0300
++++ src/cds.c	2012-01-26 05:14:03.317360310 +0400
+@@ -20,6 +20,8 @@
+  */
+ 
+ #include <stdlib.h>
++#include <string.h>
++#include <stdio.h>
+ #include <upnp/upnp.h>
+ #include <upnp/upnptools.h>
+ 
+--- src/cms.c	2007-12-09 16:03:36.000000000 +0300
++++ src/cms.c	2012-01-26 05:15:33.236991387 +0400
+@@ -20,6 +20,7 @@
+  */
+ 
+ #include <stdlib.h>
++#include <string.h>
+ #include <upnp/upnp.h>
+ #include <upnp/upnptools.h>
+ 
+--- src/http.c	2012-01-26 05:27:44.073992912 +0400
++++ src/http.c	2012-01-26 05:17:31.756505126 +0400
+@@ -25,6 +25,7 @@
+ #include <errno.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <string.h>
+ #include <unistd.h>
+ #include <errno.h>
+ 
+--- src/presentation.c	2007-12-09 16:03:36.000000000 +0300
++++ src/presentation.c	2012-01-26 05:19:41.635972259 +0400
+@@ -19,6 +19,8 @@
+  */
+ 
+ #include <stdlib.h>
++#include <string.h>
++#include <stdio.h>
+ 
+ #if HAVE_LANGINFO_CODESET
+ # include <langinfo.h>
+--- src/mime.c	2007-12-09 16:03:36.000000000 +0300
++++ src/mime.c	2012-01-26 05:23:54.251602492 +0400
+@@ -21,6 +21,7 @@
+ 
+ #include <stdlib.h>
+ #include <string.h>
++#include <stdio.h>
+ 
+ #include "mime.h"
+ #include "ushare.h"
+--- src/services.c	2007-12-09 16:03:36.000000000 +0300
++++ src/services.c	2012-01-26 05:21:28.572200186 +0400
+@@ -20,6 +20,7 @@
+  */
+ 
+ #include <stdlib.h>
++#include <string.h>
+ #include <upnp/upnp.h>
+ #include <upnp/upnptools.h>

Added: trunk/dports/net/ushare/files/patch-ushare-upnp-build-fix.diff
===================================================================
--- trunk/dports/net/ushare/files/patch-ushare-upnp-build-fix.diff	                        (rev 0)
+++ trunk/dports/net/ushare/files/patch-ushare-upnp-build-fix.diff	2014-10-12 01:22:42 UTC (rev 126548)
@@ -0,0 +1,161 @@
+update libupnp to 1.6.8, broke compiling of uShare
+
+See https://dev.openwrt.org/ticket/8296
+and https://lists.rpmfusion.org/pipermail/rpmfusion-developers/2011-September/010113.html
+
+diff -wbBur ushare-1.1a/src/http.c ushare-1.1a.my/src/http.c
+--- src/http.c	2007-12-09 13:03:36.000000000 +0000
++++ src/http.c	2010-10-29 11:13:07.000000000 +0000
+@@ -77,8 +77,7 @@
+   info->content_type = ixmlCloneDOMString (content_type);
+ }
+ 
+-static int
+-http_get_info (const char *filename, struct File_Info *info)
++int http_get_info (const char *filename, struct File_Info *info)
+ {
+   extern struct ushare_t *ut;
+   struct upnp_entry_t *entry = NULL;
+@@ -197,8 +196,7 @@
+   return ((UpnpWebFileHandle) file);
+ }
+ 
+-static UpnpWebFileHandle
+-http_open (const char *filename, enum UpnpOpenFileMode mode)
++UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode)
+ {
+   extern struct ushare_t *ut;
+   struct upnp_entry_t *entry = NULL;
+@@ -251,8 +249,7 @@
+   return ((UpnpWebFileHandle) file);
+ }
+ 
+-static int
+-http_read (UpnpWebFileHandle fh, char *buf, size_t buflen)
++int http_read (UpnpWebFileHandle fh, char *buf, size_t buflen)
+ {
+   struct web_file_t *file = (struct web_file_t *) fh;
+   ssize_t len = -1;
+@@ -286,8 +283,7 @@
+   return len;
+ }
+ 
+-static int
+-http_write (UpnpWebFileHandle fh __attribute__((unused)),
++int http_write (UpnpWebFileHandle fh __attribute__((unused)),
+             char *buf __attribute__((unused)),
+             size_t buflen __attribute__((unused)))
+ {
+@@ -296,8 +292,7 @@
+   return 0;
+ }
+ 
+-static int
+-http_seek (UpnpWebFileHandle fh, off_t offset, int origin)
++int http_seek (UpnpWebFileHandle fh, off_t offset, int origin)
+ {
+   struct web_file_t *file = (struct web_file_t *) fh;
+   off_t newpos = -1;
+@@ -371,8 +366,7 @@
+   return 0;
+ }
+ 
+-static int
+-http_close (UpnpWebFileHandle fh)
++int http_close (UpnpWebFileHandle fh)
+ {
+   struct web_file_t *file = (struct web_file_t *) fh;
+ 
+@@ -402,13 +396,3 @@
+ 
+   return 0;
+ }
+-
+-struct UpnpVirtualDirCallbacks virtual_dir_callbacks =
+-  {
+-    http_get_info,
+-    http_open,
+-    http_read,
+-    http_write,
+-    http_seek,
+-    http_close
+-  };
+diff -wbBur ushare-1.1a/src/http.h ushare-1.1a.my/src/http.h
+--- src/http.h	2007-12-09 13:03:36.000000000 +0000
++++ src/http.h	2010-10-29 11:13:11.000000000 +0000
+@@ -25,6 +25,13 @@
+ #include <upnp/upnp.h>
+ #include <upnp/upnptools.h>
+ 
+-struct UpnpVirtualDirCallbacks virtual_dir_callbacks;
++int http_close (UpnpWebFileHandle fh);
++int http_write (UpnpWebFileHandle fh __attribute__((unused)),
++            char *buf __attribute__((unused)),
++            size_t buflen __attribute__((unused)));
++int http_seek (UpnpWebFileHandle fh, off_t offset, int origin);
++UpnpWebFileHandle http_open (const char *filename, enum UpnpOpenFileMode mode);
++int http_read (UpnpWebFileHandle fh, char *buf, size_t buflen);
++int http_get_info (const char *filename, struct File_Info *info);
+ 
+ #endif /* _HTTP_H_ */
+diff -wbBur ushare-1.1a/src/ushare.c ushare-1.1a.my/src/ushare.c
+--- src/ushare.c	2007-12-09 13:03:36.000000000 +0000
++++ src/ushare.c	2010-10-29 11:17:45.000000000 +0000
+@@ -188,7 +188,7 @@
+   if (strcmp (request->DevUDN + 5, ut->udn))
+     return;
+ 
+-  ip = request->CtrlPtIPAddr.s_addr;
++  ip = (*(struct sockaddr_in*)&request->CtrlPtIPAddr).sin_addr.s_addr;
+   ip = ntohl (ip);
+   sprintf (val, "%d.%d.%d.%d",
+            (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF);
+@@ -348,7 +348,47 @@
+ 
+   UpnpEnableWebserver (TRUE);
+ 
+-  res = UpnpSetVirtualDirCallbacks (&virtual_dir_callbacks);
++  res = UpnpVirtualDir_set_WriteCallback(http_write);
++  if (res != UPNP_E_SUCCESS)
++  {
++    log_error (_("Cannot set virtual directory callbacks\n"));
++    free (description);
++    return -1;
++  }
++
++  res = UpnpVirtualDir_set_GetInfoCallback(http_get_info);
++  if (res != UPNP_E_SUCCESS)
++  {
++    log_error (_("Cannot set virtual directory callbacks\n"));
++    free (description);
++    return -1;
++  }
++
++  res = UpnpVirtualDir_set_ReadCallback(http_read);
++  if (res != UPNP_E_SUCCESS)
++  {
++    log_error (_("Cannot set virtual directory callbacks\n"));
++    free (description);
++    return -1;
++  }
++
++  res = UpnpVirtualDir_set_OpenCallback(http_open);
++  if (res != UPNP_E_SUCCESS)
++  {
++    log_error (_("Cannot set virtual directory callbacks\n"));
++    free (description);
++    return -1;
++  }
++
++  res = UpnpVirtualDir_set_SeekCallback(http_seek);
++  if (res != UPNP_E_SUCCESS)
++  {
++    log_error (_("Cannot set virtual directory callbacks\n"));
++    free (description);
++    return -1;
++  }
++
++  res = UpnpVirtualDir_set_CloseCallback(http_close);
+   if (res != UPNP_E_SUCCESS)
+   {
+     log_error (_("Cannot set virtual directory callbacks\n"));
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20141011/f0044b8d/attachment.html>


More information about the macports-changes mailing list