Add a simple config migrator to move config items around at load. I've used it

to move general/process_m3u to scanning/process_playlists, scanning/process_xml
to scanning/process_itunes, and make scanning/process_m3u actually control just
m3u file rather than all playlists.  In addition, scan/correct_order has been
moved to daap/correct_order.  This closes long-standing bug #172.
This commit is contained in:
Ron Pedde 2007-04-06 05:05:50 +00:00
parent e6d550dd49
commit 00ded64dab
13 changed files with 129 additions and 329 deletions

View File

@ -109,17 +109,6 @@
<short_description></short_description>
<type size="80" browse="file">text</type>
</item>
<item id="general:process_m3u">
<name>Process .m3u Files</name>
<short_description>
Should m3u files be processed as playlists?
</short_description>
<type default_value="0">select</type>
<options>
<option value="0">No</option>
<option value="1">Yes</option>
</options>
</item>
<item id="general:compdirs" advanced="true">
<name>Compilation Directories</name>
<short_description></short_description>
@ -127,8 +116,19 @@
</item>
</section>
<section name="Scanning" advanced="true">
<item id="scanning:process_xml">
<name>Process xmlFiles</name>
<item id="scanning:process_playlists">
<name>Process Playlists</name>
<short_description>
Should static playlists (.m3u, etc) be processed?
</short_description>
<type default_value="1">select</type>
<options>
<option value="0">No</option>
<option value="1">Yes</option>
</options>
</item>
<item id="scanning:process_itunes">
<name>Process iTunes files</name>
<short_description>
Should iTunes xml-files be processed?
</short_description>
@ -138,6 +138,17 @@
<option value="1">Yes</option>
</options>
</item>
<item id="scanning:process_m3u">
<name>Process .m3u files</name>
<short_description>
Should .m3u playlists be processed?
</short_description>
<type default_value="0">select</type>
<options>
<option value="0">No</option>
<option value="1">Yes</option>
</options>
</item>
<item id="scanning:case_sensitive">
<name>Case Sensitive</name>
<short_description>
@ -246,7 +257,10 @@
<option value="1">Yes</option>
</options>
</item>
<item id="scan:correct_order" advanced="true">
</section>
<section name="Daap" advanced="true">
<item id="daap:correct_order">
<name>Ordered Playlists</name>
<short_description>
Should playlists be returned in the order specified in the playlist?
@ -257,9 +271,6 @@
<option value="1">Yes</option>
</options>
</item>
</section>
<section name="Daap" advanced="true">
<item id="daap:empty_strings">
<name>Empty strings</name>
<short_description></short_description>

View File

@ -1,47 +0,0 @@
mt-daapd (0.9-@ver@) unstable; urgency=low
* Nightly build
-- Ron Pedde <ron@pedde.com> Wed, 11 Oct 2006 21:02:00 -0600
mt-daapd (0.2.1.1-1) unstable; urgency=low
* Trivial fixes for stupid bugs
-- Ron Pedde <ron@pedde.com> Sat, 5 Feb 2005 15:18:00 -0600
mt-daapd (0.2.1-1) unstable; urgency=low
* Add support for ogg metainfo
* Add support for xing/lame tags
* Better connect speed
* More bug fixes
-- Ron Pedde <ron@pedde.com> Sat, 29 Jan 2005 23:09:00 -0600
mt-daapd (0.2.1-pre1-1) unstable; urgency=low
* Add support for background filesystem scans
* More aac and id3 tags
* Various bug fixes
-- Ron Pedde <ron@pedde.com> Sat, 23 Oct 2004 19:10:00 -0500
mt-daapd (0.2.0-1) unstable; urgency=low
* Add gdbm database
* Add support for .m4a and .m4p
* Various bug fixes
-- Ron Pedde <ron@pedde.com> Mon, 6 Apr 2004 21:10:00 -0600
mt-daapd (0.1.1-1) unstable; urgency=low
* Add track information
* Support for Solaris
* Format string fixes
* Support for Howl 0.9 or better
-- Ron Pedde <ron@pedde.com> Thu, 29 Jan 2004 11:37:14 -0600
mt-daapd (0.1.0-1) unstable; urgency=low
* Initial Release.
-- Aubin Paul <debian@outlyer.org> Tue, 6 Jan 2004 08:16:53 -0500

1
debian/compat vendored
View File

@ -1 +0,0 @@
4

13
debian/control vendored
View File

@ -1,13 +0,0 @@
Source: mt-daapd
Section: sound
Priority: optional
Maintainer: Aubin Paul <debian@outlyer.org>
Build-Depends: debhelper (>= 4.0.0), libid3tag0-dev, zlib1g-dev, libgdbm-dev, libsqlite0-dev libogg-dev libvorbis-dev libflac-dev
Standards-Version: 3.6.0
Package: mt-daapd
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: iTunes-compatible DAAP server
An iTunes server for Linux, Solaris, OSX, and other POSIX Unix machines.

13
debian/copyright vendored
View File

@ -1,13 +0,0 @@
This package was debianized by Aubin Paul <debian@outlyer.org> on
Tue, 6 Jan 2004 08:16:53 -0500.
It was downloaded from http://mt-daapd.sourceforge.net/
Upstream Author(s): Ron Pedde <ron@pedde.com>
Copyright:
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License Version 2, found on Debian systems
in the file /usr/share/common-licenses/GPL

3
debian/dirs vendored
View File

@ -1,3 +0,0 @@
usr/bin
usr/sbin
var/cache/mt-daapd

6
debian/docs vendored
View File

@ -1,6 +0,0 @@
CREDITS
NEWS
README
TODO
contrib/mt-daapd.conf

74
debian/init.d vendored
View File

@ -1,74 +0,0 @@
#! /bin/sh
#
# skeleton example file to build /etc/init.d/ scripts.
# This file should be used to construct scripts for /etc/init.d.
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/mt-daapd
NAME=mt-daapd
DESC=mt-daapd
test -x $DAEMON || exit 0
# Include mt-daapd defaults if available
if [ -f /etc/default/mt-daapd ] ; then
. /etc/default/mt-daapd
fi
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet -m --pidfile /var/run/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS 2>/dev/null
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--signal 2 --exec $DAEMON --oknodo
echo "$NAME."
;;
#reload)
#
# If the daemon can reload its config files on the fly
# for example by sending it SIGHUP, do it here.
#
# If the daemon responds to changes in its config file
# directly anyway, make this a do-nothing entry.
#
# echo "Reloading $DESC configuration files."
# start-stop-daemon --stop --signal 1 --quiet --pidfile \
# /var/run/$NAME.pid --exec $DAEMON
#;;
restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --exec $DAEMON --pidfile \
/var/run/$NAME.pid --oknodo
sleep 1
start-stop-daemon --start --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0

23
debian/postinst vendored
View File

@ -1,23 +0,0 @@
#!/bin/sh -e
action="$1"
CONF=/etc/mt-daapd.conf
CACHE=/var/cache/mt-daapd
case "$1" in
configure)
if [ -x /etc/init.d/daap ]; then
if ( grep "mt-daapd" /etc/init.d/daap > /dev/null 2>&1 ); then
echo "Removing /etc/init.d/daap. New startup script is mt-daapd."
rm /etc/init.d/daap
fi
fi
if [ ! -f $CONF ] ; then cp /usr/share/doc/mt-daapd/mt-daapd.conf $CONF; fi
if [ ! -d $CACHE ] ; then mkdir -p $CACHE; fi
chown nobody $CACHE
;;
esac

107
debian/rules vendored
View File

@ -1,107 +0,0 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
endif
config.status: configure
dh_testdir
# Add here commands to configure the package.
CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --enable-sqlite --enable-flac --enable-oggvorbis
build: build-stamp
build-stamp: config.status
dh_testdir
# Add here commands to compile the package.
$(MAKE)
#/usr/bin/docbook-to-man debian/mt-daapd.sgml > mt-daapd.1
touch build-stamp
clean:
dh_testdir
dh_testroot
rm -f build-stamp
# Add here commands to clean up after the build process.
-$(MAKE) distclean
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
cp -f /usr/share/misc/config.guess config.guess
endif
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/mt-daapd.
$(MAKE) install DESTDIR=$(CURDIR)/debian/mt-daapd
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs ChangeLog
dh_installdocs
dh_installexamples
# dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
dh_installinit --init-script=mt-daapd
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
# dh_compress
dh_fixperms
# dh_perl
# dh_python
# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

View File

@ -87,6 +87,13 @@ typedef struct _CONF_ELEMENTS {
char *term;
} CONF_ELEMENTS;
typedef struct _CONF_MAP {
char *old_section;
char *old_key;
char *new_section;
char *new_key;
} CONF_MAP;
/** Forwards */
static int _conf_verify(LL_HANDLE pll);
static LL_ITEM *_conf_fetch_item(LL_HANDLE pll, char *section, char *key);
@ -99,6 +106,7 @@ static int _conf_split(char *s, char *delimiters, char ***argvp);
static void _conf_dispose_split(char **argv);
static int _conf_xml_dump(XMLSTRUCT *pxml,LL *pll,int sublevel,char *parent);
static int _conf_verify_element(char *section, char *key, char *value);
static void _conf_remap_entry(char *old_section, char *old_key, char **new_section, char **new_key);
static CONF_ELEMENTS conf_elements[] = {
{ 1, 0, CONF_T_STRING,"general","runas" },
@ -140,9 +148,49 @@ static CONF_ELEMENTS conf_elements[] = {
{ 0, 0, CONF_T_INT,"scanning","follow_symlinks" },
{ 0, 0, CONF_T_INT,"scanning","skip_first" },
{ 0, 0, CONF_T_INT,"scan","correct_order" },
{ 0, 0, CONF_T_INT, NULL, NULL }
/* remapped values */
{ 0, 0, CONF_T_INT,"scanning","process_playlists" },
{ 0, 0, CONF_T_INT,"scanning","process_itunes" },
{ 0, 0, CONF_T_INT,"scanning","process_m3u" },
{ 0, 0, CONF_T_INT,"daap","correct_order" },
{ 0, 0, CONF_T_INT, NULL, NULL },
};
static CONF_MAP _conf_map[] = {
{ "general","process_m3u","scanning","process_playlists" },
{ "scanning","process_xml","scanning","process_itunes" },
{ "scan","correct_order","daap","correct_order" },
{ NULL, NULL, NULL, NULL }
};
/**
* Upgrade a config silently by remapping old configuration values
* to new configuration values
*/
void _conf_remap_entry(char *old_section, char *old_key, char **new_section, char **new_key) {
CONF_MAP *pmap;
pmap = _conf_map;
while(pmap->old_section) {
if((!strcasecmp(old_section,pmap->old_section)) &&
(!strcasecmp(old_key,pmap->old_key))) {
/* found it! */
DPRINTF(E_LOG,L_CONF,"Config option %s/%s has "
"been replaced by %s/%s\n",
pmap->old_section,pmap->old_key,
pmap->new_section, pmap->new_key);
*new_section = pmap->new_section;
*new_key = pmap->new_key;
return;
}
pmap++;
}
*new_section = old_section;
*new_key = old_key;
}
/**
* Try and create a directory, including parents (probably
@ -550,6 +598,9 @@ int conf_read(char *file) {
int index;
char *temp;
char *replaced_section = NULL; /* config key/value updates */
char *replaced_key = NULL; /* config key/value updates */
if(conf_main_file) {
conf_close();
free(conf_main_file);
@ -577,7 +628,7 @@ int conf_read(char *file) {
ll_create(&pllcomment); /* don't care if we lose comments */
comment = NULL;
pllcurrent=NULL;
pllcurrent = NULL;
/* got what will be the root of the config tree, now start walking through
* the input file, populating the tree
@ -627,7 +678,6 @@ int conf_read(char *file) {
ll_add_ll(pllnew,term,plltemp);
/* set current section and name */
pllcurrent = plltemp;
if(section_name)
free(section_name);
section_name = strdup(term);
@ -666,11 +716,11 @@ int conf_read(char *file) {
strsep(&value,delim);
if((value) && (term) && (strlen(term))) {
while((strlen(term) && (strchr("\t ",term[strlen(term)-1]))))
term[strlen(term)-1] = '\0';
term[strlen(term)-1] = '\0';
while(strlen(value) && (strchr("\t ",*value)))
value++;
while((strlen(value) && (strchr("\t ",value[strlen(value)-1]))))
value[strlen(value)-1] = '\0';
value[strlen(value)-1] = '\0';
/* convert spaces to underscores in key */
temp = term;
@ -680,7 +730,7 @@ int conf_read(char *file) {
temp++;
}
if(!pllcurrent) {
if(!section_name) {
/* in compat mode -- add a general section */
if((err=ll_create(&plltemp)) != LL_E_SUCCESS) {
DPRINTF(E_LOG,L_CONF,"Error creating list: %d\n",err);
@ -689,7 +739,6 @@ int conf_read(char *file) {
return CONF_E_UNKNOWN;
}
ll_add_ll(pllnew,"general",plltemp);
pllcurrent = plltemp;
if(section_name)
free(section_name); /* shouldn't ahppen */
@ -706,7 +755,26 @@ int conf_read(char *file) {
}
/* see what kind this is, and act accordingly */
pce = _conf_get_keyinfo(section_name,term);
_conf_remap_entry(section_name, term, &replaced_section, &replaced_key);
DPRINTF(E_DBG,L_CONF,"Got %s/%s, convert to %s/%s (%s)\n",section_name,
term, replaced_section, replaced_key, value);
pli = ll_fetch_item(pllnew,replaced_section);
if(pli) {
DPRINTF(E_DBG,L_CONF,"Found existing section\n");
pllcurrent = pli->value.as_ll;
} else {
DPRINTF(E_DBG,L_CONF,"creating new section\n");
if((err = ll_create(&pllcurrent)) != LL_E_SUCCESS) {
ll_destroy(pllnew);
DPRINTF(E_LOG,L_CONF,"Error creating linked list: %d\n",err);
fclose(fin);
return CONF_E_UNKNOWN;
}
ll_add_ll(pllnew,replaced_section,pllcurrent);
}
pce = _conf_get_keyinfo(replaced_section, replaced_key);
key_type = CONF_T_STRING;
if(pce)
key_type = pce->type;
@ -715,13 +783,13 @@ int conf_read(char *file) {
case CONF_T_MULTIPATH:
case CONF_T_MULTICOMMA:
/* first, see if we already have a tree... */
pli = ll_fetch_item(pllcurrent,term);
pli = ll_fetch_item(pllcurrent,replaced_key);
if(!pli) {
if((ll_create(&plltemp) != LL_E_SUCCESS)) {
DPRINTF(E_FATAL,L_CONF,"Could not create "
"linked list.\n");
}
ll_add_ll(pllcurrent,term,plltemp);
ll_add_ll(pllcurrent,replaced_key,plltemp);
ll_set_flags(plltemp,0); /* allow dups */
} else {
plltemp = pli->value.as_ll;
@ -731,19 +799,19 @@ int conf_read(char *file) {
if(_conf_split(value,",",&valuearray) >= 0) {
index = 0;
while(valuearray[index]) {
ll_add_string(plltemp,term,valuearray[index]);
ll_add_string(plltemp,replaced_key,valuearray[index]);
index++;
}
_conf_dispose_split(valuearray);
} else {
ll_add_string(plltemp,term,value);
ll_add_string(plltemp,replaced_key,value);
}
break;
case CONF_T_INT:
case CONF_T_STRING:
case CONF_T_EXISTPATH:
default:
ll_add_string(pllcurrent,term,value);
ll_add_string(pllcurrent,replaced_key,value);
break;
}
@ -751,7 +819,7 @@ int conf_read(char *file) {
if(comment) {
/* this is an inline comment */
snprintf(keybuffer,sizeof(keybuffer),"in_%s_%s",
section_name,term);
replaced_section,replaced_key);
ll_add_string(pllcomment,keybuffer,comment);
comment = NULL;
}
@ -759,7 +827,7 @@ int conf_read(char *file) {
if(prev_comments[0] != '\0') {
/* we had some preceding comments */
snprintf(keybuffer,sizeof(keybuffer),"pre_%s_%s",
section_name, term);
replaced_section, replaced_key);
ll_add_string(pllcomment,keybuffer,prev_comments);
prev_comments[0] = '\0';
current_comment_length=0;
@ -770,6 +838,7 @@ int conf_read(char *file) {
if(((term) && (strlen(term))) && (!value)) {
DPRINTF(E_LOG,L_CONF,"Error in config file on line %d\n",line);
DPRINTF(E_LOG,L_CONF,"key: %s, value: %s\n",replaced_key,value);
ll_destroy(pllnew);
return CONF_E_PARSE;
}
@ -779,7 +848,6 @@ int conf_read(char *file) {
if(!comment)
comment = "";
/* add to prev comments */
while((current_comment_length + (int)strlen(comment) + 2 >=
total_comment_length) && (total_comment_length < 32768)) {
@ -809,14 +877,17 @@ int conf_read(char *file) {
}
}
if(section_name)
if(section_name) {
free(section_name);
section_name = NULL;
}
if(prev_comments) {
if(prev_comments[0] != '\0') {
ll_add_string(pllcomment,"end",prev_comments);
}
free(prev_comments);
prev_comments = NULL;
}
fclose(fin);

View File

@ -184,8 +184,8 @@ void scan_add_playlistlist(char *path) {
DPRINTF(E_SPAM,L_SCAN,"Adding playlist %s\n",path);
if(!conf_get_int("general","process_m3u",0)) {
DPRINTF(E_DBG,L_SCAN,"Skipping playlist %s (process_m3u)\n",path);
if(!conf_get_int("scanning","process_playlists",1)) {
DPRINTF(E_DBG,L_SCAN,"Skipping playlist %s (process_playlists)\n",path);
return;
}
@ -228,14 +228,19 @@ void scan_process_playlistlist(void) {
file = strrchr(pnext->path,PATHSEP) + 1;
}
if(strcasecmp(file,"iTunes Music Library.xml") == 0) {
if(conf_get_int("scanning","process_xml",1)) {
if((!strcasecmp(file,"iTunes Music Library.xml")) ||
(!strcasecmp(file,"iTunes Library.xml"))) {
if(conf_get_int("scanning","process_itunes",1)) {
DPRINTF(E_INF,L_SCAN,"Scanning %s\n",pnext->path);
scan_xml_playlist(pnext->path);
DPRINTF(E_INF,L_SCAN,"Done Scanning %s\n",pnext->path);
}
} else if(strcasecmp(ext,".m3u") == 0) {
scan_static_playlist(pnext->path);
} else if(!strcasecmp(ext,".m3u")) {
if(conf_get_int("scanning","process_m3u",0)) {
DPRINTF(E_INF,L_SCAN,"Scanning %s\n",pnext->path);
scan_static_playlist(pnext->path);
DPRINTF(E_INF,L_SCAN,"Done Scanning %s\n",pnext->path);
}
}
}

View File

@ -195,8 +195,8 @@ int decode_tag(FILE *fout, unsigned char *current, int level, int len) {
current[2] << 8 |
current[3];
// fprintf(stderr,"Tag: %c%c%c%c, subtag len: %d, len: %d\n",
// tag[0],tag[1],tag[2],tag[3],subtag_len, len);
fprintf(stderr,"Tag: %c%c%c%c, subtag len: %d, len: %d\n",
tag[0],tag[1],tag[2],tag[3],subtag_len, len);
current += 4;
len -= 4;