Port gmediaserver to -ng

git-svn-id: svn://svn.openwrt.org/openwrt/packages@4388 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
florian 2006-08-02 08:07:18 +00:00
parent da45adc969
commit 9fae648b72
4 changed files with 219 additions and 0 deletions

90
net/gmediaserver/Makefile Normal file
View File

@ -0,0 +1,90 @@
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
PKG_NAME:=gmediaserver
PKG_VERSION:=0.9.0
PKG_RELEASE:=1
PKG_MD5SUM:=93de0f8dcbc1353a0d0dd5b5ab4b3142
PKG_SOURCE_URL:=http://savannah.nongnu.org/download/gmediaserver/
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_CAT:=zcat
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
include $(INCLUDE_DIR)/package.mk
define Package/gmediaserver
SECTION:=net
CATEGORY:=Network
DEPENDS:=+id3lib +libupnp
TITLE:=An UPnP music media server
DESCRIPTION:=An UPnP music media server.
URL:=http://www.nongnu.org/gmediaserver/
endef
define Build/Configure
(cd $(PKG_BUILD_DIR); rm -rf config.{cache,status} ; \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
LIBS=" -lixml -lthreadutil -lupnp -luClibc++ -lz" \
am_cv_func_iconv=no \
./configure \
--target=$(GNU_TARGET_NAME) \
--host=$(GNU_TARGET_NAME) \
--build=$(GNU_HOST_NAME) \
--program-prefix="" \
--program-suffix="" \
--prefix=/usr \
--exec-prefix=/usr \
--bindir=/usr/bin \
--datadir=/usr/share \
--includedir=/usr/include \
--infodir=/usr/share/info \
--libdir=/usr/lib \
--libexecdir=/usr/lib \
--localstatedir=/var \
--mandir=/usr/share/man \
--sbindir=/usr/sbin \
--sysconfdir=/etc \
$(DISABLE_LARGEFILE) \
$(DISABLE_NLS) \
--enable-shared \
--disable-static \
--disable-rpath \
--with-gnu-ld \
--with-id3lib="$(STAGING_DIR)/usr" \
--with-libupnp="$(STAGING_DIR)/usr" \
);
endef
define Build/Compile
rm -rf $(PKG_INSTALL_DIR)
mkdir -p $(PKG_INSTALL_DIR)
$(MAKE) -C $(PKG_BUILD_DIR) \
DESTDIR="$(PKG_INSTALL_DIR)" \
all install
endef
define Package/gmediaserver/install
install -m0755 -d $(1)/etc/default
install -m0644 ./files/gmediaserver.default $(1)/etc/default/gmediaserver
install -m0755 -d $(1)/etc/init.d
install -m0755 ./files/gmediaserver.init $(1)/etc/init.d/gmediaserver
install -m0755 -d $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/bin/gmediaserver $(1)/usr/sbin/
$(RSTRIP) $(1)
$(IPKG_BUILD) $(1) $(PACKAGE_DIR)
endef
$(eval $(call BuildPackage,gmediaserver))

View File

@ -0,0 +1 @@
OPTIONS="--background --interface=br0 --pid-file=$PID_F"

View File

@ -0,0 +1,21 @@
#!/bin/sh
BIN=gmediaserver
DEFAULT=/etc/default/$BIN
RUN_D=/var/run
PID_F=$RUN_D/$BIN.pid
[ -f $DEFAULT ] && . $DEFAULT
case $1 in
start)
$BIN $OPTIONS
;;
stop)
[ -f $PID_F ] && kill $(cat $PID_F)
;;
*)
echo "usage: $0 (start|stop)"
exit 1
esac
exit $?

View File

@ -0,0 +1,107 @@
diff -ruN gmediaserver-0.8.0-old/src/main.c gmediaserver-0.8.0-new/src/main.c
--- gmediaserver-0.8.0-old/src/main.c 2005-09-10 09:26:00.000000000 +0200
+++ gmediaserver-0.8.0-new/src/main.c 2005-09-17 20:48:01.000000000 +0200
@@ -32,8 +32,10 @@
#include <stdbool.h> /* Gnulib, C99 */
#include <signal.h> /* ? */
#include <locale.h> /* ? */
+#ifdef HAVE_ICONV
#include <iconv.h> /* Gnulib, POSIX */
#include "iconvme.h" /* Gnulib */
+#endif
#ifdef HAVE_NL_LANGINFO
#include <langinfo.h>
#endif
@@ -71,8 +73,10 @@
#ifdef HAVE_ID3LIB
{ "disable-id3", no_argument, NULL, OPT_DISABLE_ID3 },
#endif
+#ifdef HAVE_ICONV
{ "in-charset", required_argument, NULL, OPT_IN_CHARSET },
{ "device-charset", required_argument, NULL, OPT_DEVICE_CHARSET },
+#endif
{ "friendly-name", required_argument, NULL, OPT_FRIENDLY_NAME },
{ "pid-file", required_argument, NULL, OPT_PIDFILE },
{ "profile", required_argument, NULL, OPT_PROFILE, },
@@ -90,15 +94,21 @@
{ NULL, 0, NULL, 0 }
};
+#ifdef HAVE_ICONV
iconv_t charset_convert = (iconv_t) -1;
+#endif
const char version_etc_copyright[] = "Copyright (C) 2005 Oskar Liljeblad.";
char *
convert_string(const char *str)
{
+#ifdef HAVE_ICONV
if (charset_convert == (iconv_t) -1)
return xstrdup(str);
return iconv_alloc(charset_convert, str);
+#else
+ return xstrdup(str);
+#endif
}
static void
@@ -140,13 +150,17 @@
char *logfilename = NULL;
char *timestamp_format = NULL;
uint32_t expire_time;
+#ifdef HAVE_ICONV
char *in_charset = NULL;
char *device_charset = NULL;
+#endif
set_program_name(argv[0]);
+#ifdef LOCALE
if (setlocale(LC_ALL, "") == NULL)
warn(_("cannot set locale: %s\n"), errstr);
+#endif
#ifdef ENABLE_NLS
if (bindtextdomain(PACKAGE, LOCALEDIR) == NULL)
warn(_("cannot bind message domain: %s\n"), errstr);
@@ -174,12 +188,14 @@
id3_enabled = false;
break;
#endif
+#ifdef HAVE_ICONV
case OPT_IN_CHARSET:
in_charset = optarg;
break;
case OPT_DEVICE_CHARSET:
device_charset = optarg;
break;
+#endif
case OPT_FRIENDLY_NAME:
if (optarg[0] == '\0')
die(_("friendly name cannot be empty\n"));
@@ -320,6 +336,7 @@
init_logging(logfilename, timestamp_format);
+#ifdef HAVE_ICONV
if (device_charset != NULL) {
if (in_charset == NULL) {
#ifdef HAVE_NL_LANGINFO
@@ -336,6 +353,7 @@
if (charset_convert == (iconv_t) -1)
die(_("cannot create character set convertor\nTry using another value for --in-charset or --device-charset\n"));
}
+#endif
/* We could write pid before initiating logging too.
*/
@@ -409,8 +427,10 @@
if (pidfilename != NULL)
unlink(pidfilename); /* ignore errors */
+#ifdef HAVE_ICONV
if (charset_convert != (iconv_t) -1)
iconv_close(charset_convert); /* ignore errors (only EINVAL) */
+#endif
finish_logging(true);