pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/40290: multimedia/mediatomb doesn't install example config.xml



Attached is my proposed patch, it does the following:

 * Installs /usr/pkg/etc/mediatomb/config.xml owned by MEDIATOMB_USER /
   MEDIATOMB_GROUP from /usr/pkg/share/examples/mediatomb
 * Honours mediatomb_username / mediatomb_groupname rc.conf vars
 * Won't clobber permissions on /var/mediatomb if the directory already
   exists
 * Changes permissions on /var/mediatomb to 0755 (previously 0750, but
   kind've pointless to do that for a daemon that advertises your entire
   filesystem on the network)
 * Installs a mediatomb.desktop menu item that when clicked will point a
   browser to /var/mediatomb/mediatomb.html; this file is auto-generated
   at MT startup to point to the MT web UI, whose port changes from
   startup to startup.

Now I can do the following:

  $ echo 'mediatomb=YES' >>/etc/rc.conf
  $ echo 'mediatomb_username=jmcneill' >>/etc/rc.conf
  $ sudo chown -R jmcneill /var/mediatomb /usr/pkg/etc/mediatomb

and not have to worry about pkg_add -u clobbering my settings in the future.

FYI, the MediaTomb developers have informed me that:

  1. all other packages currently provide a default config.xml
  2. config.xml is only written to by mediatomb in two cases;
       a. if a valid udi is not present, one is added
       b. on upgrades
  3. the fact that MT drops privileges before opening config.xml is a
     bug and should be fixed. We are the first to observe this :)

Cheers,
Jared
Index: INSTALL
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mediatomb/INSTALL,v
retrieving revision 1.1
diff -u -r1.1 INSTALL
--- INSTALL     3 Nov 2008 17:04:51 -0000       1.1
+++ INSTALL     29 Dec 2008 21:31:29 -0000
@@ -8,7 +8,9 @@
 
 case "${STAGE}" in
 PRE-INSTALL)
-    ${MKDIR} -m 0750 ${PKG_HOME}
-    ${CHOWN} ${MEDIATOMB_USER}:${MEDIATOMB_GROUP} ${PKG_HOME}
+    if [ ! -d ${PKG_HOME} ]; then
+        ${MKDIR} -m 0755 ${PKG_HOME}
+        ${CHOWN} ${MEDIATOMB_USER}:${MEDIATOMB_GROUP} ${PKG_HOME}
+    fi
     ;;
 esac
Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mediatomb/Makefile,v
retrieving revision 1.6
diff -u -r1.6 Makefile
--- Makefile    18 Dec 2008 17:28:17 -0000      1.6
+++ Makefile    29 Dec 2008 21:31:29 -0000
@@ -1,7 +1,7 @@
 # $NetBSD: Makefile,v 1.6 2008/12/18 17:28:17 bjs Exp $
 
 DISTNAME=      mediatomb-0.11.0
-PKGREVISION=   3
+PKGREVISION=   4
 CATEGORIES=    multimedia
 MASTER_SITES=  ${MASTER_SITE_SOURCEFORGE:=mediatomb/}
 
@@ -13,6 +13,7 @@
 
 USE_LANGUAGES+=        c c++
 USE_TOOLS+=    pkg-config
+USE_DIRS+=     xdg-1.4
 
 RCD_SCRIPTS=   mediatomb
 
@@ -24,9 +25,31 @@
 PKG_GECOS.${MEDIATOMB_USER}=   MediaTomb Server
 PKG_HOME.${MEDIATOMB_USER}=    ${VARBASE}/mediatomb
 
+PKG_SYSCONFSUBDIR=     mediatomb
+EGDIR=                 ${PREFIX}/share/examples/mediatomb
+CONF_FILES_PERMS+=     ${EGDIR}/config.xml ${PKG_SYSCONFDIR}/config.xml \
+                       ${MEDIATOMB_USER} ${MEDIATOMB_GROUP} 0644
+
 FILES_SUBST+=                  PKG_HOME=${PKG_HOME.${MEDIATOMB_USER}:Q}
 FILES_SUBST+=                  MEDIATOMB_GROUP=${MEDIATOMB_GROUP:Q}
 FILES_SUBST+=                  MEDIATOMB_USER=${MEDIATOMB_USER:Q}
+FILES_SUBST+=                  PKG_SYSCONFDIR=${PKG_SYSCONFDIR:Q}
+
+MEDIATOMB_HOME=                ${PKG_HOME.${MEDIATOMB_USER}}
+
+SUBST_CLASSES+=                config
+SUBST_FILES.config=    config.xml mediatomb.desktop
+SUBST_VARS.config=     MEDIATOMB_HOME PREFIX OPSYS
+SUBST_STAGE.config=    post-patch
+
+post-extract:
+       ${CP} ${FILESDIR}/config.xml.in ${WRKSRC}/config.xml
+       ${CP} ${FILESDIR}/mediatomb.desktop.in ${WRKSRC}/mediatomb.desktop
+
+post-install:
+       ${INSTALL_DATA_DIR} ${EGDIR}
+       ${INSTALL_DATA} ${WRKSRC}/config.xml ${EGDIR}/config.xml
+       ${INSTALL_DATA} ${WRKSRC}/mediatomb.desktop 
${PREFIX}/share/applications/mediatomb.desktop
 
 PREFER.bind=   pkgsrc  # we need the package for the lwres lib
 
Index: PLIST
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mediatomb/PLIST,v
retrieving revision 1.2
diff -u -r1.2 PLIST
--- PLIST       3 Nov 2008 17:04:51 -0000       1.2
+++ PLIST       29 Dec 2008 21:31:29 -0000
@@ -1,6 +1,8 @@
 @comment $NetBSD: PLIST,v 1.2 2008/11/03 17:04:51 tron Exp $
 bin/mediatomb
 man/man1/mediatomb.1
+share/applications/mediatomb.desktop
+share/examples/mediatomb/config.xml
 share/examples/rc.d/mediatomb
 share/mediatomb/js/common.js
 share/mediatomb/js/import.js
@@ -96,3 +98,4 @@
 @dirrm share/mediatomb/web
 @dirrm share/mediatomb/js
 @dirrm share/mediatomb
+@dirrm share/examples/mediatomb
Index: files/config.xml.in
===================================================================
RCS file: files/config.xml.in
diff -N files/config.xml.in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/config.xml.in 29 Dec 2008 21:31:29 -0000
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<config version="1" xmlns="http://mediatomb.cc/config/1"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://mediatomb.cc/config/1 
http://mediatomb.cc/config/1.xsd";>
+  <server>
+    <ui enabled="yes">
+      <accounts enabled="no" session-timeout="30">
+        <account user="mediatomb" password="mediatomb"/>
+      </accounts>
+    </ui>
+    <name>MediaTomb (@OPSYS@)</name>
+    <udn/>
+    <home>@MEDIATOMB_HOME@/.</home>
+    <webroot>@PREFIX@/share/mediatomb/web</webroot>
+    <storage>
+      <sqlite3 enabled="yes">
+        <database-file>mediatomb.db</database-file>
+      </sqlite3>
+    </storage>
+    <protocolInfo extend="no"/><!-- For PS3 support change to "yes" -->
+    <!--
+       Uncomment the lines below to get rid of jerky avi playback on the
+       DSM320 or to enable subtitles support on the DSM units
+    -->
+    <!--
+    <custom-http-headers>
+      <add header="X-User-Agent: redsonic"/>
+    </custom-http-headers>
+
+    <manufacturerURL>redsonic.com</manufacturerURL>
+    <modelNumber>105</modelNumber>
+    -->
+    <!-- Uncomment the line below if you have a Telegent TG100 -->
+    <!--
+       <upnp-string-limit>101</upnp-string-limit>
+    -->
+  </server>
+  <import hidden-files="no">
+    <scripting script-charset="UTF-8">
+      <common-script>/usr/pkg/share/mediatomb/js/common.js</common-script>
+      
<playlist-script>/usr/pkg/share/mediatomb/js/playlists.js</playlist-script>
+      <virtual-layout type="builtin">
+        <import-script>/usr/pkg/share/mediatomb/js/import.js</import-script>
+      </virtual-layout>
+    </scripting>
+    <mappings>
+      <extension-mimetype ignore-unknown="no">
+        <map from="mp3" to="audio/mpeg"/>
+        <map from="mp4" to="video/mp4"/>
+        <map from="ogg" to="application/ogg"/>
+        <map from="asf" to="video/x-ms-asf"/>
+        <map from="asx" to="video/x-ms-asf"/>
+        <map from="wma" to="audio/x-ms-wma"/>
+        <map from="wax" to="audio/x-ms-wax"/>
+        <map from="wmv" to="video/x-ms-wmv"/>
+        <map from="wvx" to="video/x-ms-wvx"/>
+        <map from="wm" to="video/x-ms-wm"/>
+        <map from="wmx" to="video/x-ms-wmx"/>
+        <map from="m3u" to="audio/x-mpegurl"/>
+        <map from="pls" to="audio/x-scpls"/>
+        <map from="flv" to="video/x-flv"/>
+        <!-- Uncomment the line below for PS3 divx support -->
+        <!-- <map from="avi" to="video/x-divx"/> -->
+        <!-- Uncomment the line below for D-Link DSM / ZyXEL DMA-1000 -->
+        <!-- <map from="avi" to="video/avi"/> -->
+      </extension-mimetype>
+      <mimetype-upnpclass>
+        <map from="audio/*" to="object.item.audioItem.musicTrack"/>
+        <map from="video/*" to="object.item.videoItem"/>
+        <map from="image/*" to="object.item.imageItem"/>
+      </mimetype-upnpclass>
+      <mimetype-contenttype>
+        <treat mimetype="audio/mpeg" as="mp3"/>
+        <treat mimetype="application/ogg" as="ogg"/>
+        <treat mimetype="audio/x-flac" as="flac"/>
+        <treat mimetype="image/jpeg" as="jpg"/>
+        <treat mimetype="audio/x-mpegurl" as="playlist"/>
+        <treat mimetype="audio/x-scpls" as="playlist"/>
+        <treat mimetype="audio/x-wav" as="pcm"/>
+        <treat mimetype="audio/L16" as="pcm"/>
+        <treat mimetype="video/x-msvideo" as="avi"/>
+      </mimetype-contenttype>
+    </mappings>
+  </import>
+  <transcoding enabled="no">
+    <mimetype-profile-mappings>
+      <transcode mimetype="video/x-flv" using="vlcmpeg"/>
+      <transcode mimetype="application/ogg" using="vlcmpeg"/>
+      <transcode mimetype="application/ogg" using="oggflac2raw"/>
+      <transcode mimetype="audio/x-flac" using="oggflac2raw"/>
+    </mimetype-profile-mappings>
+    <profiles>
+      <profile name="oggflac2raw" enabled="no" type="external">
+        <mimetype>audio/L16</mimetype>
+        <accept-url>no</accept-url>
+        <first-resource>yes</first-resource>
+        <accept-ogg-theora>no</accept-ogg-theora>
+        <agent command="ogg123" arguments="-d raw -f %out %in"/>
+        <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
+      </profile>
+      <profile name="vlcmpeg" enabled="no" type="external">
+        <mimetype>video/mpeg</mimetype>
+        <accept-url>yes</accept-url>
+        <first-resource>yes</first-resource>
+        <accept-ogg-theora>yes</accept-ogg-theora>
+        <agent command="vlc" arguments="-I dummy %in --sout 
#transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out}
 vlc:quit"/>
+        <buffer size="14400000" chunk-size="512000" fill-size="120000"/>
+      </profile>
+    </profiles>
+  </transcoding>
+</config>
Index: files/mediatomb.desktop.in
===================================================================
RCS file: files/mediatomb.desktop.in
diff -N files/mediatomb.desktop.in
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/mediatomb.desktop.in  29 Dec 2008 21:31:29 -0000
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=MediaTomb
+Comment=MediaTomb UPnP MediaServer web interface
+Exec=@PREFIX@/bin/gnome-open @MEDIATOMB_HOME@/mediatomb.html
+Icon=@PREFIX@/share/mediatomb/web/icons/mt-icon120.png
+Terminal=false
+Categories=Application;AudioVideo;
+Type=Application
+Encoding=UTF-8
Index: files/mediatomb.sh
===================================================================
RCS file: /cvsroot/pkgsrc/multimedia/mediatomb/files/mediatomb.sh,v
retrieving revision 1.1
diff -u -r1.1 mediatomb.sh
--- files/mediatomb.sh  3 Nov 2008 17:04:51 -0000       1.1
+++ files/mediatomb.sh  29 Dec 2008 21:31:29 -0000
@@ -10,10 +10,12 @@
 
 name="mediatomb"
 rcvar=$name
+load_rc_config_var mediatomb_username mediatomb_username
+load_rc_config_var mediatomb_groupname mediatomb_groupname
 command="@PREFIX@/bin/mediatomb"
 logfile="@VARBASE@/log/${name}.log"
 pidfile="@PKG_HOME@/${name}.pid"
-command_args="-d -u @MEDIATOMB_USER@ -g @MEDIATOMB_USER@ -m @PKG_HOME@ -P 
${pidfile} -l ${logfile} -f ."
+command_args="-d -u ${mediatomb_username:-@MEDIATOMB_USER@} -g 
${mediatomb_groupname:-@MEDIATOMB_USER@} -m @PKG_HOME@ -P ${pidfile} -l 
${logfile} -c @PKG_SYSCONFDIR@/config.xml"
 extra_commands="reload"
 
 if [ -f /etc/rc.subr ]; then


Home | Main Index | Thread Index | Old Index