Вот, пожалуйста, собрал.
Может кому пригодится.======================================================================
Makefile
# Created by: Mr. Anonymous <anonymous@anonym.org>
# $FreeBSD$PORTNAME= ushare
PORTVERSION= 1.1a
PORTREVISION= 9
CATEGORIES= net
MASTER_SITES= http://ushare.geexbox.org/releases/
MAINTAINER= votdev@gmx.de
COMMENT= This is a lightweight UPnP (TM) A/V Media Server
LICENSE= GPLv2+
LIB_DEPENDS= libupnp.so:devel/upnp
LIB_DEPENDS+= libavformat.so:multimedia/ffmpeg
HAS_CONFIGURE= yes
USES= gmake iconv pathfix pkgconfig tar:bzip2
USES+= gettext-runtime
LDFLAGS+= -L${LOCALBASE}/lib -lintl
CFLAGS+= -I${LOCALBASE}/include -I${WRKSRC}
OPTIONS_DEFINE= LIBDLNA
LIBDLNA_DESC= Enable DLNA (PS3) support
LIB_DEPENDS+= libdlna.so:devel/libdlna
LIBDLNA_CONFIGURE_ON= --enable-dlna
PLIST_FILES= bin/ushare etc/rc.d/ushare etc/ushare.conf.sample man/man1/ushare.1.gz
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/src/${PORTNAME} ${STAGEDIR}${PREFIX}/bin
${INSTALL_SCRIPT} ${WRKSRC}/scripts/${PORTNAME} ${STAGEDIR}${PREFIX}/etc/rc.d
${INSTALL_DATA} ${WRKSRC}/scripts/${PORTNAME}.conf ${STAGEDIR}${PREFIX}/etc/${PORTNAME}.conf.sample
${INSTALL_MAN} ${WRKSRC}/src/${PORTNAME}.1 ${STAGEDIR}${MANPREFIX}/man/man1
post-install:
${CP} -np ${STAGEDIR}${PREFIX}/etc/${PORTNAME}.conf.sample ${PREFIX}/etc/${PORTNAME}.conf
.include <bsd.port.mk>
Важно! Не забудьте про символы табуляции в Makefile
======================================================================
distinfo
SHA256 (ushare-1.1a.tar.bz2) = 7b9b85c79968d4f4560f02a99e33c6a33ff58f9d41d8faea79e31cce2ee78665
SIZE (ushare-1.1a.tar.bz2) = 65864
======================================================================
pkg-descr
GeeXboX uShare is a UPnP (TM) A/V Media Server. It implements the server
component that provides UPnP media devices with information on available
multimedia files. uShare uses the built-in http server of libupnp to stream
the files to clients.WWW: http://ushare.geexbox.org/
======================================================================
files/patch-scripts_ushare
--- scripts/ushare.orig 2007-12-09 13:03:36 UTC
+++ scripts/ushare
@@ -1,82 +1,29 @@
-#!/bin/sh -e
+#!/bin/sh
#
-# uShare init script
+# ushare.sh for rc.d usage (c) 2007 Volker Theile <votdev@gmx.de>.
#
-### BEGIN INIT INFO
-# Provides: ushare
-# Required-Start: $local_fs $syslog $network
-# Should-Start:
-# Required-Stop:
-# Should-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: uShare
-# Description: uShare UPnP (TM) A/V & DLNA Media Server
-# You should edit configuration in /etc/ushare.conf file
-# See http://ushare.geexbox.org for details
-### END INIT INFO
-
-PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/usr/bin/ushare
-NAME=ushare
-DESC="uShare UPnP A/V & DLNA Media Server"
-PIDFILE=/var/run/ushare.pid
-CONFIGFILE=/etc/ushare.conf-# abort if no executable exists
-[ -x $DAEMON ] || exit 0
+# PROVIDE: ushare
+# REQUIRE: DAEMON
+# BEFORE: LOGIN
+# KEYWORD: shutdown
-# Get lsb functions
-. /lib/lsb/init-functions
-. /etc/default/rcS
+# Add the following line to /etc/rc.conf to enable `ushare':
+#
+#ushare_enable="YES"
-[ -f /etc/default/ushare ] && . /etc/default/ushare
+. /etc/rc.subr
-checkpid() {
- [ -e $PIDFILE ] || touch $PIDFILE
-}
+name="ushare"
+rcvar="${name}_enable"
-check_shares() {
- if [ -r "$CONFIGFILE" ]; then
- . $CONFIGFILE
- [ -n "$USHARE_DIR" ] && return 0
- fi
- return 1
-}
+command="/usr/local/bin/${name}"
+command_args="--daemon"
+required_files="/usr/local/etc/${name}.conf"
-case "$1" in
- start)
- log_daemon_msg "Starting $DESC: $NAME"
- if ! $(check_shares); then
- log_warning_msg "No shares avalaible ..."
- log_end_msg 0
- else
- checkpid
- start-stop-daemon --start --quiet --background --oknodo \
- --make-pidfile --pidfile $PIDFILE \
- --exec $DAEMON -- $USHARE_OPTIONS
- log_end_msg $?
- fi
- ;;
- stop)
- log_daemon_msg "Stopping $DESC: $NAME"
- start-stop-daemon --stop --signal 2 --quiet --oknodo --pidfile $PIDFILE
- log_end_msg $?
- ;;
- reload|force-reload)
- log_daemon_msg "Reloading $DESC: $NAME"
- start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
- log_end_msg $?
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- *)
- N=/etc/init.d/$NAME
- log_success_msg "Usage: $N {start|stop|restart|reload|force-reload}"
- exit 1
- ;;
-esac
+# read configuration and set defaults
+load_rc_config "${name}"
+: ${ushare_enable="NO"}
+: ${ushare_flags=""}
-exit 0
+run_rc_command "$1"
======================================================================
files/patch-src_trace.c
--- src/trace.c.orig 2007-12-09 13:03:36 UTC
+++ src/trace.c
@@ -57,7 +57,7 @@ print_log (log_level level, const char *
va_end (va);
}-inline void
+extern inline void
start_log (void)
{
openlog (PACKAGE_NAME, LOG_PID, LOG_DAEMON);
======================================================================
files/patch-src_trace.h
--- src/trace.h.orig 2007-12-09 13:03:36 UTC
+++ src/trace.h
@@ -29,7 +29,7 @@ typedef enum { void print_log (log_level level, const char *format, ...)
__attribute__ ((format (printf, 2, 3)));
-inline void start_log (void);
+extern inline void start_log (void);
/* log_info
* Normal print, to replace printf
======================================================================
files/patch-src_ushare.c
--- src/ushare.c.orig 2007-12-09 13:03:36 UTC
+++ src/ushare.c
@@ -171,6 +171,19 @@ ushare_signal_exit (void)
pthread_mutex_unlock (&ut->termination_mutex);
}+
+#ifdef __FreeBSD__
+static void
+*get_ip_addr(struct sockaddr *sa)
+{
+ if (sa->sa_family == AF_INET)
+ return &(((struct sockaddr_in*)sa)->sin_addr);
+ else
+ return &(((struct sockaddr_in6*)sa)->sin6_addr);
+}
+#endif /* __FreeBSD__ */
+
+
static void
handle_action_request (struct Upnp_Action_Request *request)
{
@@ -188,7 +201,11 @@ handle_action_request (struct Upnp_Actio
if (strcmp (request->DevUDN + 5, ut->udn))
return;
+#ifndef __FreeBSD__
ip = request->CtrlPtIPAddr.s_addr;
+#else
+ ip = get_ip_addr((struct sockaddr *)&request->CtrlPtIPAddr) ;
+#endif /* __FreeBSD__ */
ip = ntohl (ip);
sprintf (val, "%d.%d.%d.%d",
(ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF);
@@ -348,6 +365,7 @@ init_upnp (struct ushare_t *ut)
UpnpEnableWebserver (TRUE);
+#ifndef __FreeBSD__
res = UpnpSetVirtualDirCallbacks (&virtual_dir_callbacks);
if (res != UPNP_E_SUCCESS)
{
@@ -355,6 +373,43 @@ init_upnp (struct ushare_t *ut)
free (description);
return -1;
}
+#else
+ if ((res = UpnpVirtualDir_set_GetInfoCallback(virtual_dir_callbacks.get_info)) != UPNP_E_SUCCESS ) {
+ log_error (_("Cannot set virtual directory callback - get_info\n"));
+ free (description);
+ return -1;
+ }
+
+ if ((res = UpnpVirtualDir_set_OpenCallback(virtual_dir_callbacks.open)) != UPNP_E_SUCCESS ) {
+ log_error (_("Cannot set virtual directory callback - open\n"));
+ free (description);
+ return -1;
+ }
+
+ if ((res = UpnpVirtualDir_set_ReadCallback(virtual_dir_callbacks.read)) != UPNP_E_SUCCESS ) {
+ log_error (_("Cannot set virtual directory callback - read\n"));
+ free (description);
+ return -1;
+ }
+
+ if ((res = UpnpVirtualDir_set_WriteCallback(virtual_dir_callbacks.write)) != UPNP_E_SUCCESS ) {
+ log_error (_("Cannot set virtual directory callback - write\n"));
+ free (description);
+ return -1;
+ }
+
+ if ((res = UpnpVirtualDir_set_SeekCallback(virtual_dir_callbacks.seek)) != UPNP_E_SUCCESS ) {
+ log_error (_("Cannot set virtual directory callback - seek\n"));
+ free (description);
+ return -1;
+ }
+
+ if ((res = UpnpVirtualDir_set_CloseCallback(virtual_dir_callbacks.close)) != UPNP_E_SUCCESS ) {
+ log_error (_("Cannot set virtual directory callback - close\n"));
+ free (description);
+ return -1;
+ }
+#endif /* __FreeBSD__ */
res = UpnpAddVirtualDir (VIRTUAL_DIR);
if (res != UPNP_E_SUCCESS)
@@ -421,6 +476,7 @@ has_iface (char *interface)
itf = itflist;
while (itf)
{
+#ifndef __FreeBSD__
if ((itf->ifa_flags & IFF_UP)
&& !strncmp (itf->ifa_name, interface, IFNAMSIZ))
{
@@ -430,6 +486,23 @@ has_iface (char *interface)
return true;
}
itf = itf->ifa_next;
+#else
+ if (strncmp (itf->ifa_name, interface, IFNAMSIZ)) {
+ itf = itf->ifa_next;
+ continue ;
+ }
+
+ if (itf->ifa_flags & IFF_UP) {
+ log_info (_("Interface %s is up.\n"), interface);
+ freeifaddrs (itflist);
+ return true ;
+ } else {
+ log_error (_("Interface %s is down.\n"), interface);
+ log_error (_("Recheck uShare's configuration and try again !\n"));
+ freeifaddrs (itflist);
+ return false ;
+ }
+#endif /* __FreeBSD__ */
}
freeifaddrs (itf);
@@ -718,7 +791,7 @@ reload_config (int s __attribute__ ((unu
}
}
-inline void
+extern inline void
display_headers (void)
{
printf (_("%s (version %s), a lightweight UPnP A/V and DLNA Media Server.\n"),
======================================================================
files/patch-src_ushare.h
--- src/ushare.h.orig 2007-12-09 13:03:36 UTC
+++ src/ushare.h
@@ -27,6 +27,11 @@
#include <stdbool.h>
#include <pthread.h>+#ifdef __FreeBSD__
+#include <stdio.h>
+#include <string.h>
+#endif /* __FreeBSD__ */
+
#ifdef HAVE_DLNA
#include <dlna.h>
#endif /* HAVE_DLNA */
@@ -127,6 +132,6 @@ struct action_event_t {
struct service_t *service;
};
-inline void display_headers (void);
+extern inline void display_headers (void);
#endif /* _USHARE_H_ */
Протестировал на FreeBSD 11.1-RELEASE
Работает.