Commits

Anonymous committed eb3371c

redid slackbuild last one was a hack
Signed-off-by: vector <veclinux@mail.com>

Comments (0)

Files changed (14)

var/vabs/cups/src/cups.SlackBuild

-#!/bin/sh
-
-# Copyright 2008, 2009, 2010, 2011, 2012  Patrick J. Volkerding, Sebeka, Minnesota, USA
-# All rights reserved.
+#!/usr/bin/bash
+# This script assumes it will be launched within "/NAME/VERSION/src" dir.
+# With all sources in "src" Your Vector Linux .txz package, slack-desc,
+# and slack-required will be found in "VERSION" dir. The extraction and
+# build will be in a temp dir created in "NAME" dir, and then removed on exit.
+# Comment out second to last line to keep this dir intact.
 #
-# Redistribution and use of this script, with or without modification, is
-# permitted provided that the following conditions are met:
+# This Template was compiled from the contributions of many users of the Vector
+# Linux forum at http://forum.vectorlinux.com and from tidbits collected 
+# from all over the internet. 
 #
-# 1. Redistributions of this script must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
+# Generated by sbbuilder-0.4.15, written by Rodrigo Bistolfi 
+# (rbistolfi) and Raimon Grau Cuscó (Kidd) for VectorLinux.
 #
-#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
-#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# CUPS build script by volkerdi@slackware.com.
-NAME="cups"
-VERSION=${VERSION:-"1.5.3"}
+# Please put your name below if you add some original scripting lines.
+# AUTHORS = 
+
+NAME="cups"            #Enter package Name!
+VERSION=${VERSION:-"1.5.3"}      #Enter package Version!
+VER=$(echo $VERSION|sed 's/-/_/') #this fixes - in version
+VL_PACKAGER=${VL_PACKAGER:-"vector"}   #Enter your Name!
+LINK=${LINK:-"http://ftp.easysw.com/pub/$NAME/$VERSION/$NAME-${VERSION}-source.tar.bz2"}  #Enter URL for package here!
+
+
+#SYSTEM VARIABLES
+#----------------------------------------------------------------------------
 BUILDNUM=${BUILDNUM:-"1"}
 VL_VERSION=${VL_VERSION:-"$(ls /var/log/packages/|grep vlconfig2|cut -d "-" -f4|cut -c 2-5)"}
 BUILD=${BUILD:-"$BUILDNUM""$VL_VERSION"}
-LINK=${LINK:-"http://ftp.easysw.com/pub/$NAME/$VERSION/$NAME-${VERSION}-source.tar.bz2"}
-
-MAKEDEPENDS=${MAKEDEPENDS:-"openldap"} #Add deps needed TO BUILD this package here.
-if [ "$NORUN" != 1 ]; then
-
-# This will not build if we have libiconv installed
-hasiconv=$(ls /var/log/packages | grep "libiconv-")
-if [ "x$hasiconv" != "x" ]; then
-	echo "libiconv has been found on this system.  CUPS will not build with this library installed."
-	echo "In 30 seconds, libiconv will be removed... Press CTRL+C to stop"
-	sleep 30
-	removepkg libiconv
-	slapt-get -u
-	slapt-get -i -y --reinstall glibc
+ARCH=${ARCH:-"$(uname -m)"}
+CONFIG_OPTIONS=${CONFIG_OPTIONS:-""}
+LDFLAG_OPTIONS=${LDFLAG_OPTIONS:-""}
+ADDRB=${ADDRB:-""} #Add deps that need to be added to the slack-required file here
+EXRB=${EXRB:-""} #Add deps that need to be excluded from the slack-required file here
+MAKEDEPENDS=${MAKEDEPENDS:-"openldap avahi hicolor-icon-theme"} #Add deps needed TO BUILD this package here.
+#----------------------------------------------------------------------------
+
+# DO NOT EXECUTE if NORUN is set to 1
+if [ "$NORUN" != "1" ]; then
+
+#SETUP PACKAGING ENVIRONMENT
+#--------------------------------------------
+CWD=$(pwd)
+cd ../
+RELEASEDIR=$(pwd)
+cd $CWD
+mkdir -p $RELEASEDIR/tmp
+TMP=$RELEASEDIR/tmp
+PKG=$TMP/package-$NAME
+#--------------------------------------------
+
+
+
+if [ $UID != 0 ]; then
+   echo "You are not authorized to run this script. Please login as root"
+   exit 1
+fi
+
+if [ ! -x /usr/bin/requiredbuilder ]; then
+   echo "Requiredbuilder not installed, or not executable."
+   exit 1
+fi
+
+if [ $VL_PACKAGER = "YOURNAME" ]; then
+   echo 'Who are you?
+   Please edit VL_PACKAGER=${VL_PACKAGER:-YOURNAME} in this script.
+   Change the word "YOURNAME" to your VectorLinux packager name.
+   You may also export VL_PACKAGER, or call this script with
+   VL_PACKAGER="YOUR NAME HERE"'
+   exit 1
 fi
 
+
 #CFLAGS SETUP
 #--------------------------------------------
 if [[ "$ARCH" = i?86 ]]; then
   ARCH=i586
   SLKCFLAGS="-O2 -march=i586 -mtune=i686"
-  CONFIGURE_TRIPLET="i586-vector-linux"
+  CONFIGURE_TRIPLET="i486-vector-linux"
   LIBDIRSUFFIX=""
 elif [ "$ARCH" = "x86_64" ]; then
   SLKCFLAGS="-O2 -fpic"
 export LDFLAGS="$LDFLAGS $LDFLAG_OPTIONS"
 #--------------------------------------------
 
-#get the source..........
+
+#GET THE SOURCE
+#--------------------------------------------
 for SRC in $(echo $LINK);do
 if [ ! -f $CWD/$(basename $SRC) ]
 then
-	wget --no-check-certificate -c $SRC
+        wget --no-check-certificate -c $SRC
 fi
 done
-NUMJOBS=${NUMJOBS:-" -j7 "}
-
-CWD=$(pwd)
-cd ../
-RELEASEDIR=$(pwd)
-cd $CWD
-mkdir -p $RELEASEDIR/tmp
-TMP=$RELEASEDIR/tmp
+#--------------------------------------------
 
-PKG=$TMP/package-cups
 
 rm -rf $PKG
-mkdir -p $TMP $PKG
-
 cd $TMP
-rm -rf cups-$VERSION
-tar xvf $CWD/cups-$VERSION-source.tar.?z* || exit 1
-cd cups-$VERSION
+rm -rf $NAME-$VERSION
+
+
+#EXTRACT SOURCES
+#-----------------------------------------------------
+echo "Extracting source..."
+tar xvf $CWD/$NAME-$VERSION-source.tar.* || exit 1
+#this moves whatever was extracted to the std dirname we are expecting
+mv * $NAME-$VERSION &> /dev/null 2>&1
+mkdir -p $PKG
+#-----------------------------------------------------
+
+
+cd $TMP/$NAME-$VERSION
+
 
 #PATCHES
 #-----------------------------------------------------
 done
 #-----------------------------------------------------
  
+ 
+
+#SET PERMISSIONS
+#-----------------------------------------
+echo "Setting permissions..."
+chown -R root:root .
+find . -perm 664 -exec chmod 644 {} \;
+find . -perm 777 -exec chmod 755 {} \;
+find . -perm 2777 -exec chmod 755 {} \;
+find . -perm 775 -exec chmod 755 {} \;
+find . -perm 2755 -exec chmod 755 {} \;
+find . -perm 774 -exec chmod 644 {} \;
+find . -perm 666 -exec chmod 644 {} \;
+find . -perm 600 -exec chmod 644 {} \;
+find . -perm 444 -exec chmod 644 {} \;
+find . -perm 400 -exec chmod 644 {} \;
+find . -perm 440 -exec chmod 644 {} \;
+find . -perm 511 -exec chmod 755 {} \;
+find . -perm 711 -exec chmod 755 {} \;
+find . -perm 555 -exec chmod 755 {} \;
+#-----------------------------------------
 
+
+
+#CONFIGURE & MAKE
+#----------------------------------------------------------------------
+# If you are building a KDE-related app, then change the following
+# arguments in the script below:
+# --prefix=$(kde-config -prefix) \
+# --sysconfdir=/etc/kde \
+#
+# Making these changes will ensure that your package will build in the
+# correct path and that it will work seamlessly within the KDE environment.
+#
+#-----------------------------------------------------------------------
+
+echo "Configuring source..."
 sed -i.orig -e 's#$exec_prefix/lib/cups#$libdir/cups#g' configure
-./configure \
+./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
   --libdir=/usr/lib${LIBDIRSUFFIX} \
   --enable-ssl \
   --enable-openssl=yes \
   --enable-gnutls=no \
   --disable-nls \
+  --enable-dbus --with-dbusdir=/etc/dbus-1 \
+  --enable-threads \
+  --enable-avahi \
   --enable-cdsassl=no \
-  --docdir=/usr/doc \
+  --with-docdir=/usr/doc \
   --without-php \
   --disable-pam \
+  --with-optim="$CFLAGS" \
   --build=$CONFIGURE_TRIPLET
 
 make $NUMJOBS || exit 1
 mkdir -p $PKG/var/spool
 make BUILDROOT=$PKG install || exit 1
 
+
+#######################################################################
+#Miscellenious tweaks and things outside a normal ./configure go here #
+#######################################################################
 # I've added so many things like /etc/init.d/ to Slackware that CUPS
 # is now installing init scripts to the Red Hat locations.  We'll move
 # them to the usual locations:
 mv $PKG/etc/init.d/cups $PKG/etc/rc.d/rc.cups.new
 chmod 644 $PKG/etc/rc.d/rc.cups.new
 # Clear out the additions:
-# rm -rf $PKG/etc/init.d $PKG/etc/rc{0,2,3,5}.d
+rm -rf $PKG/etc/init.d $PKG/etc/rc{0,2,3,5}.d
 # fix .desktop file
   sed -i 's|^Exec=htmlview http://localhost:631/|Exec=xdg-open http://localhost:631/|g' ${PKG}/usr/share/applications/cups.desktop
 ### OBSOLETE.  The USB backend is patched to support usblp again. ###
   fi
 )
 
-mkdir -p $PKG/install
-cat $CWD/slack-desc > $PKG/install/slack-desc
-
-# Remove preformatted manpages and move the manpages to /usr/man:
-( cd $PKG/usr/share/man
-  find . -type d -name "cat*" | xargs rm -rf
-  cd ..
-  mv man ..
-)
-
-# Adjust/expand docs:
-( mkdir -p $PKG/usr/doc
-  mv $PKG/usr/share/doc/cups $PKG/usr/doc/cups-$VERSION
-  rmdir $PKG/usr/share/doc
-  cd $PKG/usr/doc
-  ln -sf cups-$VERSION cups )
-
-# If there's a ChangeLog, installing at least part of the recent history
-# is useful, but don't let it get totally out of control:
-if [ -r CHANGES.txt ]; then
-  DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION)
-  cat CHANGES.txt | head -n 1000 > $DOCSDIR/CHANGES.txt
-  touch -r CHANGES.txt $DOCSDIR/CHANGES.txt
-fi
-
 # I'm sorry, but PDF files are almost as bloated and annoying as
 # MS Word documents.  We'll retain the HTML files in /usr/doc.
 ( cd $PKG/usr/doc
   find . -name "*.pdf" -exec rm -f {} \; )
 
-# Apply no-clobber fix to conffiles:
-( cd $PKG/etc/cups
-  echo "DocumentRoot /usr/doc/cups-$VERSION/cups/" >>cupsd.conf
-  for file in * ; do
-    if [ -f $file ]; then
-      mv $file $file.new
-    fi
-  done )
-
-# Strip stuff:
-find $PKG | xargs file | grep -e "executable" -e "shared object" \
-  | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
-
-# Use symlinks to certain binaries so that CUPS and LPRng can coexist:
-SUFFIX=cups
-for file in \
-usr/bin/cancel \
-usr/bin/lp \
-usr/bin/lpq \
-usr/bin/lpr \
-usr/bin/lprm \
-usr/bin/lpstat \
-usr/sbin/lpc ; do
-  ( cd $PKG
-    mv ${file} ${file}-${SUFFIX}
-    ( cd `dirname ${file}` ; ln -sf `basename ${file}`-${SUFFIX} `basename ${file}` )
-  )
+mkdir -p $PKG/usr/doc/$NAME-$VERSION
+cp -a AUTHORS COPYING ChangeLog Credits MANIFEST README TODO \
+$PKG/usr/doc/$NAME-$VERSION
+cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild
+
+#----------------------------------------------------------------------
+
+if [ -d $PKG/usr/share/man ];then
+mkdir -p $PKG/usr/man
+mv $PKG/usr/share/man/* $PKG/usr/man
+rm -rf $PKG/usr/share/man
+fi
+find $PKG/usr/man -type f -exec gzip -9 {} \;
+
+if [ -d $PKG/usr/share/info ];then
+mkdir -p $PKG/usr/info
+mv $PKG/usr/share/info/* $PKG/usr/info
+rm -rf $PKG/usr/share/info
+fi 
+find $PKG/usr/info -type f -exec gzip -9 {} \;
+
+mkdir -p $PKG/install
+if [ -d $PKG/usr/info ];then
+cat >> $PKG/install/doinst.sh << EOF
+CWD=\$(pwd)
+cd usr/info
+if [ -f dir ];then
+    rm dir
+fi
+if [ -f dir.gz ];then
+    rm dir.gz
+fi
+for i in *.info.gz;do
+    install-info \$i dir
 done
-# Now fix the associated man pages:
-mv $PKG/usr/man/man1/cancel.1.gz $PKG/usr/man/man1/cancel-${SUFFIX}.1.gz
-mv $PKG/usr/man/man1/lp.1.gz $PKG/usr/man/man1/lp-${SUFFIX}.1.gz
-mv $PKG/usr/man/man1/lpq.1.gz $PKG/usr/man/man1/lpq-${SUFFIX}.1.gz
-mv $PKG/usr/man/man1/lpr.1.gz $PKG/usr/man/man1/lpr-${SUFFIX}.1.gz
-mv $PKG/usr/man/man1/lprm.1.gz $PKG/usr/man/man1/lprm-${SUFFIX}.1.gz
-mv $PKG/usr/man/man1/lpstat.1.gz $PKG/usr/man/man1/lpstat-${SUFFIX}.1.gz
-mv $PKG/usr/man/man8/lpc.8.gz $PKG/usr/man/man8/lpc-${SUFFIX}.8.gz
-( cd $PKG/usr/man/man1
-  ln -sf cancel-${SUFFIX}.1.gz cancel.1.gz
-  ln -sf lp-${SUFFIX}.1.gz lp.1.gz
-  ln -sf lpq-${SUFFIX}.1.gz lpq.1.gz
-  ln -sf lpr-${SUFFIX}.1.gz lpr.1.gz
-  ln -sf lprm-${SUFFIX}.1.gz lprm.1.gz
-  ln -sf lpstat-${SUFFIX}.1.gz lpstat.1.gz
-)
-( cd $PKG/usr/man/man8
-  ln -sf lpc-${SUFFIX}.8.gz lpc.8.gz
+cd \$CWD
+EOF
+fi
+
+# Add schemas install to the doinst.sh if schemas are found.
+if [ -d $PKG/etc/gconf/schemas ];then
+# Make sure we have gconftool installed
+echo "if [ -x usr/bin/gconftool-2 ]; then" >> $PKG/install/doinst.sh
+( cd $PKG/etc/gconf/schemas
+for schema in *.schemas; do
+ # Install schemas
+ echo "GCONF_CONFIG_SOURCE=\"xml::etc/gconf/gconf.xml.defaults\" \
+   usr/bin/gconftool-2 --makefile-install-rule \
+   etc/gconf/schemas/${schema} >/dev/null 2>&1" \
+   >> $PKG/install/doinst.sh
+done;
 )
+# Finish off gconf block
+echo "fi" >> $PKG/install/doinst.sh
+fi
+
+
+#if there is a slack-desc in src dir use it
+if test -f $CWD/slack-desc; then
+cp $CWD/slack-desc $RELEASEDIR/slack-desc
+else
+# This creates the white space in front of "handy-ruler" in slack-desc below.
+
+LENGTH=$(expr length "$NAME")
+SPACES=0
+SHIM=""
+until [ "$SPACES" = "$LENGTH" ]; do
+SHIM="$SHIM "
+let SPACES=$SPACES+1
+done
+
+# Fill in the package summary between the () below.
+# Then package the description, License, Author and Website.
+# There may be no more then 11 $NAME: lines in a valid slack-desc.
+
+cat > $RELEASEDIR/slack-desc << EOF
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.  Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in.  You must
+# make exactly 11 lines for the formatting to be correct.  It's also
+# customary to leave one space after the ':'.
+
+$SHIM|-----handy-ruler------------------------------------------------------|
+$NAME: $NAME ()
+$NAME:
+$NAME: 
+$NAME: 
+$NAME: 
+$NAME: 
+$NAME:
+$NAME:
+$NAME: License: GPL
+$NAME: Authors: 
+$NAME: Website: 
 
-# Add the doinst.sh that installs the .new conffiles:
-zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
+EOF
+fi
+cat >> $RELEASEDIR/slack-desc << EOF
+
+
+
+#----------------------------------------
+BUILDDATE: $(date)
+PACKAGER:  $VL_PACKAGER
+HOST:      $(uname -srm)
+DISTRO:    $(cat /etc/vector-version)
+CFLAGS:    $CFLAGS
+LDFLAGS:   $LDFLAGS
+CONFIGURE: $(awk "/\\$\ \.\/configure\ /" $TMP/$DIRNAME/config.log)
+
+EOF
 
-# Build the package:
+cat $RELEASEDIR/slack-desc > $PKG/install/slack-desc
+
+#STRIPPING
+#------------------------------------------------------------------------------------------------------------------
 cd $PKG
-requiredbuilder -v -y -s $RELEASEDIR $PKG
-makepkg -c n -l y $RELEASEDIR/$NAME-$VERSION-$ARCH-$BUILD.txz
+echo " "
+echo "Stripping...."
+echo " "
+find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
+#------------------------------------------------------------------------------------------------------------------
+
+
+#FINISH PACKAGE
+#--------------------------------------------------------------
+echo "Finding dependencies..."
+ADD="$ADDRB" EXCLUDE="$EXRB" requiredbuilder -v -y -s $RELEASEDIR $PKG
+echo "Creating package $NAME-$VERSION-$ARCH-$BUILD.txz"
+makepkg -l y -c n $RELEASEDIR/$NAME-$VERSION-$ARCH-$BUILD.txz
 
-rm -rf $TMP
+cd $CWD
+echo "Cleaning up temp files..." && rm -rf $TMP
+echo "Package Complete"
 fi
+#--------------------------------------------------------------
+
+# vim: set tabstop=4 shiftwidth=4 foldmethod=marker : ##

var/vabs/cups/src/cups.fix_broken_locking.diff.gz

Binary file removed.

var/vabs/cups/src/doinst.sh

+config() {
+  NEW="$1"
+  OLD="`dirname $NEW`/`basename $NEW .new`"
+  # If there's no config file by that name, mv it over:
+  if [ ! -r $OLD ]; then
+    mv $NEW $OLD
+  elif [ "`cat $OLD | md5sum`" = "`cat $NEW | md5sum`" ]; then # toss the redundant copy
+    rm $NEW
+  fi
+  # Otherwise, we leave the .new copy for the admin to consider...
+}
+for file in etc/cups/*.new ; do
+  config $file
+done
+config etc/dbus-1/system.d/cups.conf.new
+
+# This file will just have to go.  It appeared for a while during a -current
+# devel period and has never been part of a stable release.
+#config etc/modprobe.d/cups.blacklist.usblp.conf.new
+rm -f etc/modprobe.d/cups.blacklist.usblp.conf.new
+rm -f etc/modprobe.d/cups.blacklist.usblp.conf
+
+# Leave any new rc.cups with the same permissions as the old one:
+# This is a kludge, but it's because there's no --reference option
+# on busybox's 'chmod':
+if [ -e etc/rc.d/rc.cups ]; then
+  if [ -x etc/rc.d/rc.cups ]; then
+    chmod 755 etc/rc.d/rc.cups.new
+  else
+    chmod 644 etc/rc.d/rc.cups.new
+  fi
+fi
+# Then config() it:
+config etc/rc.d/rc.cups.new

var/vabs/cups/src/doinst.sh.gz

Binary file removed.

var/vabs/cups/src/patches/avahi-missing-in-conditionals.patch

+diff -uraN cups/scheduler/client.c cups-new/scheduler/client.c
+--- cups/scheduler/client.c	2012-05-25 15:28:49.000000000 +0200
++++ cups-new/scheduler/client.c	2012-08-04 20:13:17.082220961 +0200
+@@ -4021,7 +4021,7 @@
+ 	    !strncmp(host, "[::1]:", 6));
+   }
+ 
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+  /*
+   * Check if the hostname is something.local (Bonjour); if so, allow it.
+   */
+@@ -4040,7 +4040,7 @@
+ 	      !_cups_strcasecmp(end, ".local.") ||
+ 	      !_cups_strncasecmp(end, ".local.:", 8)))
+     return (1);
+-#endif /* HAVE_DNSSD */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
+ 
+  /*
+   * Check if the hostname is an IP address...
+@@ -4101,7 +4101,7 @@
+     }
+   }
+ 
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+   for (a = (cupsd_alias_t *)cupsArrayFirst(DNSSDAlias);
+        a;
+        a = (cupsd_alias_t *)cupsArrayNext(DNSSDAlias))
+@@ -4126,7 +4126,7 @@
+         return (1);
+     }
+   }
+-#endif /* HAVE_DNSSD */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
+ 
+  /*
+   * Check for interface hostname matches...
+diff -uraN cups/scheduler/conf.c cups-new/scheduler/conf.c
+--- cups/scheduler/conf.c	2012-05-25 15:28:49.000000000 +0200
++++ cups-new/scheduler/conf.c	2012-08-04 20:15:49.830978405 +0200
+@@ -89,9 +89,9 @@
+ {
+   { "AccessLog",		&AccessLog,		CUPSD_VARTYPE_STRING },
+   { "AutoPurgeJobs", 		&JobAutoPurge,		CUPSD_VARTYPE_BOOLEAN },
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+   { "BrowseDNSSDSubTypes",	&DNSSDSubTypes,		CUPSD_VARTYPE_STRING },
+-#endif /* HAVE_DNSSD */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
+   { "BrowseWebIF",		&BrowseWebIF,		CUPSD_VARTYPE_BOOLEAN },
+   { "Browsing",			&Browsing,		CUPSD_VARTYPE_BOOLEAN },
+   { "CacheDir",			&CacheDir,		CUPSD_VARTYPE_STRING },
+@@ -735,9 +735,9 @@
+   Browsing                 = CUPS_DEFAULT_BROWSING;
+   DefaultShared            = CUPS_DEFAULT_DEFAULT_SHARED;
+ 
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+   cupsdSetString(&DNSSDSubTypes, "_cups,_print");
+-#endif /* HAVE_DNSSD */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
+ 
+   cupsdSetString(&LPDConfigFile, CUPS_DEFAULT_LPD_CONFIG_FILE);
+   cupsdSetString(&SMBConfigFile, CUPS_DEFAULT_SMB_CONFIG_FILE);
+diff -uraN cups/scheduler/ipp.c cups-new/scheduler/ipp.c
+--- cups/scheduler/ipp.c	2012-05-25 15:28:49.000000000 +0200
++++ cups-new/scheduler/ipp.c	2012-08-04 20:13:17.086220978 +0200
+@@ -4813,7 +4813,7 @@
+     ippAddDate(con->response, IPP_TAG_PRINTER, "printer-current-time",
+                ippTimeToDate(curtime));
+ 
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+   if (!ra || cupsArrayFind(ra, "printer-dns-sd-name"))
+   {
+     if (printer->reg_name)
+@@ -4823,7 +4823,7 @@
+       ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_NOVALUE,
+                    "printer-dns-sd-name", 0);
+   }
+-#endif /* HAVE_DNSSD */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
+ 
+   if (!ra || cupsArrayFind(ra, "printer-error-policy"))
+     ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_NAME,
+diff -uraN cups/scheduler/main.c cups-new/scheduler/main.c
+--- cups/scheduler/main.c	2012-05-25 15:28:49.000000000 +0200
++++ cups-new/scheduler/main.c	2012-08-04 20:13:17.090221001 +0200
+@@ -781,9 +781,9 @@
+       * Got an error from select!
+       */
+ 
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+       cupsd_printer_t	*p;		/* Current printer */
+-#endif /* HAVE_DNSSD */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
+ 
+ 
+       if (errno == EINTR)		/* Just interrupted by a signal */
+@@ -824,13 +824,13 @@
+ 			job->print_pipes[0], job->print_pipes[1],
+ 			job->back_pipes[0], job->back_pipes[1]);
+ 
+-#ifdef HAVE_DNSSD
++#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
+       for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
+ 	   p;
+ 	   p = (cupsd_printer_t *)cupsArrayNext(Printers))
+         cupsdLogMessage(CUPSD_LOG_EMERG, "printer[%s] reg_name=\"%s\"", p->name,
+ 	                p->reg_name ? p->reg_name : "(null)");
+-#endif /* HAVE_DNSSD */
++#endif /* HAVE_DNSSD || HAVE_AVAHI */
+ 
+       break;
+     }

var/vabs/cups/src/patches/cups-avahi-1-config.patch

-diff -up cups-1.5.0/config.h.in.avahi-1-config cups-1.5.0/config.h.in
---- cups-1.5.0/config.h.in.avahi-1-config	2011-06-16 21:12:16.000000000 +0100
-+++ cups-1.5.0/config.h.in	2011-08-05 15:04:09.535759988 +0100
-@@ -390,6 +390,13 @@
- 
- 
- /*
-+ * Do we have Avahi for DNS Service Discovery?
-+ */
-+
-+#undef HAVE_AVAHI
-+
-+
-+/*
-  * Do we have <sys/ioctl.h>?
-  */
- 
-diff -up cups-1.5.0/config-scripts/cups-dnssd.m4.avahi-1-config cups-1.5.0/config-scripts/cups-dnssd.m4
---- cups-1.5.0/config-scripts/cups-dnssd.m4.avahi-1-config	2011-05-12 06:21:56.000000000 +0100
-+++ cups-1.5.0/config-scripts/cups-dnssd.m4	2011-08-05 15:04:09.525760307 +0100
-@@ -23,6 +23,21 @@ AC_ARG_WITH(dnssd-includes, [  --with-dn
- DNSSDLIBS=""
- DNSSD_BACKEND=""
- 
-+AC_ARG_ENABLE(avahi, [  --enable-avahi          turn on DNS Service Discovery support, default=no],
-+	      [if test x$enable_avahi = xyes; then
-+		       AC_MSG_CHECKING(for Avahi)
-+		       if $PKGCONFIG --exists avahi-client; then
-+			       AC_MSG_RESULT(yes)
-+			       CFLAGS="$CFLAGS `$PKGCONFIG --cflags avahi-client`"
-+			       DNSSDLIBS="`$PKGCONFIG --libs avahi-client`"
-+			       DNSSD_BACKEND="dnssd"
-+			       AC_DEFINE(HAVE_AVAHI)
-+			       enable_dnssd=no
-+		       else
-+			       AC_MSG_RESULT(no)
-+		       fi
-+	       fi])
-+
- if test x$enable_dnssd != xno; then
- 	AC_CHECK_HEADER(dns_sd.h, [
- 		case "$uname" in

var/vabs/cups/src/patches/cups-avahi-2-backend.patch

-diff -up cups-1.5.2/backend/dnssd.c.avahi-2-backend cups-1.5.2/backend/dnssd.c
---- cups-1.5.2/backend/dnssd.c.avahi-2-backend	2012-02-06 11:09:08.318644741 +0100
-+++ cups-1.5.2/backend/dnssd.c	2012-02-06 11:09:08.326644641 +0100
-@@ -15,14 +15,21 @@
-  *
-  * Contents:
-  *
-+ *   next_txt_record()       - Get next TXT record from a cups_txt_records_t.
-+ *   parse_txt_record_pair() - Read key/value pair in cups_txt_records_t.
-  *   main()                  - Browse for printers.
-  *   browse_callback()       - Browse devices.
-  *   browse_local_callback() - Browse local devices.
-  *   compare_devices()       - Compare two devices.
-  *   exec_backend()          - Execute the backend that corresponds to the
-  *                             resolved service name.
-+ *   device_type()           - Get DNS-SD type enumeration from string.
-  *   get_device()            - Create or update a device.
-  *   query_callback()        - Process query data.
-+ *   avahi_client_callback() - Avahi client callback function.
-+ *   avahi_query_callback()  - Avahi query callback function.
-+ *   avahi_browse_callback() - Avahi browse callback function.
-+ *   find_device()           - Find a device from its name and domain.
-  *   sigterm_handler()       - Handle termination signals...
-  *   unquote()               - Unquote a name string.
-  */
-@@ -33,7 +40,18 @@
- 
- #include "backend-private.h"
- #include <cups/array.h>
--#include <dns_sd.h>
-+#ifdef HAVE_DNSSD
-+#  include <dns_sd.h>
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+#  include <avahi-client/client.h>
-+#  include <avahi-client/lookup.h>
-+#  include <avahi-common/simple-watch.h>
-+#  include <avahi-common/domain.h>
-+#  include <avahi-common/error.h>
-+#  include <avahi-common/malloc.h>
-+#define kDNSServiceMaxDomainName AVAHI_DOMAIN_NAME_MAX
-+#endif /* HAVE_AVAHI */
- 
- 
- /*
-@@ -53,7 +71,12 @@ typedef enum
- 
- typedef struct
- {
-+#ifdef HAVE_DNSSD
-   DNSServiceRef	ref;			/* Service reference for resolve */
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+  int		resolved;		/* Did we resolve the device? */
-+#endif /* HAVE_AVAHI */
-   char		*name,			/* Service name */
- 		*domain,		/* Domain name */
- 		*fullName,		/* Full name */
-@@ -65,6 +88,20 @@ typedef struct
- 		sent;			/* Did we list the device? */
- } cups_device_t;
- 
-+typedef struct
-+{
-+  char key[256];
-+  char value[256];
-+
-+#ifdef HAVE_DNSSD
-+  const uint8_t *data;
-+  const uint8_t *datanext;
-+  const uint8_t *dataend;
-+#else /* HAVE_AVAHI */
-+  AvahiStringList *txt;
-+#endif /* HAVE_DNSSD */
-+} cups_txt_records_t;
-+
- 
- /*
-  * Local globals...
-@@ -78,6 +115,7 @@ static int		job_canceled = 0;
-  * Local functions...
-  */
- 
-+#ifdef HAVE_DNSSD
- static void		browse_callback(DNSServiceRef sdRef,
- 			                DNSServiceFlags flags,
- 				        uint32_t interfaceIndex,
-@@ -93,12 +131,6 @@ static void		browse_local_callback(DNSSe
- 					      const char *regtype,
- 					      const char *replyDomain,
- 					      void *context);
--static int		compare_devices(cups_device_t *a, cups_device_t *b);
--static void		exec_backend(char **argv);
--static cups_device_t	*get_device(cups_array_t *devices,
--			            const char *serviceName,
--			            const char *regtype,
--				    const char *replyDomain);
- static void		query_callback(DNSServiceRef sdRef,
- 			               DNSServiceFlags flags,
- 				       uint32_t interfaceIndex,
-@@ -107,9 +139,118 @@ static void		query_callback(DNSServiceRe
- 				       uint16_t rrclass, uint16_t rdlen,
- 				       const void *rdata, uint32_t ttl,
- 				       void *context);
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+static void		avahi_client_callback (AvahiClient *client,
-+					       AvahiClientState state,
-+					       void *context);
-+static void		avahi_browse_callback (AvahiServiceBrowser *browser,
-+					       AvahiIfIndex interface,
-+					       AvahiProtocol protocol,
-+					       AvahiBrowserEvent event,
-+					       const char *serviceName,
-+					       const char *regtype,
-+					       const char *replyDomain,
-+					       AvahiLookupResultFlags flags,
-+					       void *context);
-+#endif /* HAVE_AVAHI */
-+
-+static cups_device_t *	find_device (cups_array_t *devices,
-+				     cups_txt_records_t *txt,
-+				     cups_device_t *dkey);
-+static int		compare_devices(cups_device_t *a, cups_device_t *b);
-+static void		exec_backend(char **argv);
-+static cups_device_t	*get_device(cups_array_t *devices,
-+			            const char *serviceName,
-+			            const char *regtype,
-+				    const char *replyDomain);
- static void		sigterm_handler(int sig);
- static void		unquote(char *dst, const char *src, size_t dstsize);
- 
-+#ifdef HAVE_AVAHI
-+static AvahiSimplePoll *simple_poll = NULL;
-+static int avahi_got_callback;
-+#endif /* HAVE_AVAHI */
-+
-+
-+/*
-+ * 'next_txt_record()' - Get next TXT record from a cups_txt_records_t.
-+ */
-+
-+static cups_txt_records_t *
-+next_txt_record (cups_txt_records_t *txt)
-+{
-+#ifdef HAVE_DNSSD
-+  txt->data = txt->datanext;
-+#else /* HAVE_AVAHI */
-+  txt->txt = avahi_string_list_get_next (txt->txt);
-+  if (txt->txt == NULL)
-+    return NULL;
-+#endif /* HAVE_DNSSD */
-+
-+  return txt;
-+}
-+
-+
-+/*
-+ * 'parse_txt_record_pair()' - Read key/value pair in cups_txt_records_t.
-+ */
-+
-+static int
-+parse_txt_record_pair (cups_txt_records_t *txt)
-+{
-+#ifdef HAVE_DNSSD
-+  uint8_t	datalen;
-+  uint8_t	*data = txt->data;
-+  char		*ptr;
-+
-+ /*
-+  * Read a key/value pair starting with an 8-bit length.  Since the
-+  * length is 8 bits and the size of the key/value buffers is 256, we
-+  * don't need to check for overflow...
-+  */
-+
-+  datalen = *data++;
-+  if (!datalen || (data + datalen) >= txt->dataend)
-+    return NULL;
-+  txt->datanext = data + datalen;
-+
-+  for (ptr = txt->key; data < txt->datanext && *data != '='; data ++)
-+    *ptr++ = *data;
-+  *ptr = '\0';
-+
-+  if (data < txt->datanext && *data == '=')
-+  {
-+    data++;
-+
-+    if (data < datanext)
-+      memcpy (txt->value, data, txt->datanext - data);
-+    value[txt->datanext - data] = '\0';
-+  }
-+  else
-+    return 1;
-+#else /* HAVE_AVAHI */
-+  char *key, *value;
-+  size_t len;
-+  avahi_string_list_get_pair (txt->txt, &key, &value, &len);
-+  if (len > sizeof (txt->value) - 1)
-+    len = sizeof (txt->value) - 1;
-+
-+  memcpy (txt->value, value, len);
-+  txt->value[len] = '\0';
-+  len = strlen (key);
-+  if (len > sizeof (txt->key) - 1)
-+    len = sizeof (txt->key) - 1;
-+
-+  memcpy (txt->key, key, len);
-+  txt->key[len] = '\0';
-+  avahi_free (key);
-+  avahi_free (value);
-+#endif /* HAVE_AVAHI */
-+
-+  return 0;
-+}
-+
- 
- /*
-  * 'main()' - Browse for printers.
-@@ -120,6 +261,13 @@ main(int  argc,				/* I - Number of comm
-      char *argv[])			/* I - Command-line arguments */
- {
-   const char	*name;			/* Backend name */
-+  cups_array_t	*devices;		/* Device array */
-+  cups_device_t	*device;		/* Current device */
-+  char		uriName[1024];		/* Unquoted fullName for URI */
-+#ifdef HAVE_DNSSD
-+  int		fd;			/* Main file descriptor */
-+  fd_set	input;			/* Input set for select() */
-+  struct timeval timeout;		/* Timeout for select() */
-   DNSServiceRef	main_ref,		/* Main service reference */
- 		fax_ipp_ref,		/* IPP fax service reference */
- 		ipp_ref,		/* IPP service reference */
-@@ -133,12 +281,11 @@ main(int  argc,				/* I - Number of comm
- 		pdl_datastream_ref,	/* AppSocket service reference */
- 		printer_ref,		/* LPD service reference */
- 		riousbprint_ref;	/* Remote IO service reference */
--  int		fd;			/* Main file descriptor */
--  fd_set	input;			/* Input set for select() */
--  struct timeval timeout;		/* Timeout for select() */
--  cups_array_t	*devices;		/* Device array */
--  cups_device_t	*device;		/* Current device */
--  char		uriName[1024];		/* Unquoted fullName for URI */
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+  AvahiClient	*client;
-+  int		error;
-+#endif /* HAVE_AVAHI */
- #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
-   struct sigaction action;		/* Actions for POSIX signals */
- #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
-@@ -198,6 +345,49 @@ main(int  argc,				/* I - Number of comm
-   * Browse for different kinds of printers...
-   */
- 
-+#ifdef HAVE_AVAHI
-+  if ((simple_poll = avahi_simple_poll_new ()) == NULL)
-+  {
-+    perror ("ERROR: Unable to create avahi simple poll object");
-+    return (1);
-+  }
-+
-+  client = avahi_client_new (avahi_simple_poll_get (simple_poll),
-+			     0, avahi_client_callback, NULL, &error);
-+  if (!client)
-+  {
-+    perror ("DEBUG: Unable to create avahi client");
-+    return (0);
-+  }
-+
-+  avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+			     AVAHI_PROTO_UNSPEC,
-+			     "_fax-ipp._tcp", NULL, 0,
-+			     avahi_browse_callback, devices);
-+  avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+			     AVAHI_PROTO_UNSPEC,
-+			     "_ipp._tcp", NULL, 0,
-+			     avahi_browse_callback, devices);
-+  avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+			     AVAHI_PROTO_UNSPEC,
-+			     "_ipp-tls._tcp", NULL, 0,
-+			     avahi_browse_callback, devices);
-+  avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+			     AVAHI_PROTO_UNSPEC,
-+			     "_pdl-datastream._tcp",
-+			     NULL, 0,
-+			     avahi_browse_callback,
-+			     devices);
-+  avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+			     AVAHI_PROTO_UNSPEC,
-+			     "_printer._tcp", NULL, 0,
-+			     avahi_browse_callback, devices);
-+  avahi_service_browser_new (client, AVAHI_IF_UNSPEC,
-+			     AVAHI_PROTO_UNSPEC,
-+			     "_riousbprint._tcp", NULL, 0,
-+			     avahi_browse_callback, devices);
-+#endif /* HAVE_AVAHI */
-+#ifdef HAVE_DNSSD
-   if (DNSServiceCreateConnection(&main_ref) != kDNSServiceErr_NoError)
-   {
-     perror("ERROR: Unable to create service connection");
-@@ -258,6 +448,7 @@ main(int  argc,				/* I - Number of comm
-   riousbprint_ref = main_ref;
-   DNSServiceBrowse(&riousbprint_ref, kDNSServiceFlagsShareConnection, 0,
-                    "_riousbprint._tcp", NULL, browse_callback, devices);
-+#endif /* HAVE_DNSSD */
- 
-  /*
-   * Loop until we are killed...
-@@ -265,6 +456,9 @@ main(int  argc,				/* I - Number of comm
- 
-   while (!job_canceled)
-   {
-+    int announce = 0;
-+
-+#ifdef HAVE_DNSSD
-     FD_ZERO(&input);
-     FD_SET(fd, &input);
- 
-@@ -284,11 +478,35 @@ main(int  argc,				/* I - Number of comm
-     }
-     else
-     {
-+      announce = 1;
-+    }
-+#else /* HAVE_AVAHI */
-+    int r;
-+    avahi_got_callback = 0;
-+    r = avahi_simple_poll_iterate (simple_poll, 1);
-+    if (r != 0 && r != EINTR)
-+    {
-+     /*
-+      * We've been told to exit the loop.  Perhaps the connection to
-+      * avahi failed.
-+      */
-+
-+      break;
-+    }
-+
-+    if (avahi_got_callback)
-+      announce = 1;
-+#endif /* HAVE_DNSSD */
-+
-+    if (announce)
-+    {
-      /*
-       * Announce any devices we've found...
-       */
- 
-+#ifdef HAVE_DNSSD
-       DNSServiceErrorType status;	/* DNS query status */
-+#endif /* HAVE_DNSSD */
-       cups_device_t *best;		/* Best matching device */
-       char	device_uri[1024];	/* Device URI */
-       int	count;			/* Number of queries */
-@@ -302,6 +520,7 @@ main(int  argc,				/* I - Number of comm
-         if (device->sent)
- 	  sent ++;
- 
-+#ifdef HAVE_DNSSD
-         if (device->ref)
- 	  count ++;
- 
-@@ -333,14 +552,23 @@ main(int  argc,				/* I - Number of comm
- 	      count ++;
-           }
- 	}
--	else if (!device->sent)
-+	else
-+#endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+	if (!device->resolved)
-+	  continue;
-+        else
-+#endif /* HAVE_AVAHI */
-+	if (!device->sent)
- 	{
-+#ifdef HAVE_DNSSD
- 	 /*
- 	  * Got the TXT records, now report the device...
- 	  */
- 
- 	  DNSServiceRefDeallocate(device->ref);
- 	  device->ref = 0;
-+#endif /* HAVE_DNSSD */
- 
-           if (!best)
- 	    best = device;
-@@ -401,6 +629,7 @@ main(int  argc,				/* I - Number of comm
- }
- 
- 
-+#ifdef HAVE_DNSSD
- /*
-  * 'browse_callback()' - Browse devices.
-  */
-@@ -489,6 +718,7 @@ browse_local_callback(
- 	  device->fullName);
-   device->sent = 1;
- }
-+#endif /* HAVE_DNSSD */
- 
- 
- /*
-@@ -569,6 +799,41 @@ exec_backend(char **argv)		/* I - Comman
- 
- 
- /*
-+ * 'device_type()' - Get DNS-SD type enumeration from string.
-+ */
-+
-+static int
-+device_type (const char *regtype)
-+{
-+#ifdef HAVE_AVAHI
-+  if (!strcmp(regtype, "_ipp._tcp"))
-+    return (CUPS_DEVICE_IPP);
-+  else if (!strcmp(regtype, "_ipps._tcp") ||
-+	   !strcmp(regtype, "_ipp-tls._tcp"))
-+    return (CUPS_DEVICE_IPPS);
-+  else if (!strcmp(regtype, "_fax-ipp._tcp"))
-+    return (CUPS_DEVICE_FAX_IPP);
-+  else if (!strcmp(regtype, "_printer._tcp"))
-+    return (CUPS_DEVICE_PDL_DATASTREAM);
-+#else
-+  if (!strcmp(regtype, "_ipp._tcp."))
-+    return (CUPS_DEVICE_IPP);
-+  else if (!strcmp(regtype, "_ipps._tcp.") ||
-+	   !strcmp(regtype, "_ipp-tls._tcp."))
-+    return (CUPS_DEVICE_IPPS);
-+  else if (!strcmp(regtype, "_fax-ipp._tcp."))
-+    return (CUPS_DEVICE_FAX_IPP);
-+  else if (!strcmp(regtype, "_printer._tcp."))
-+    return (CUPS_DEVICE_PRINTER);
-+  else if (!strcmp(regtype, "_pdl-datastream._tcp."))
-+    return (CUPS_DEVICE_PDL_DATASTREAM);
-+#endif /* HAVE_AVAHI */
-+
-+  return (CUPS_DEVICE_RIOUSBPRINT);
-+}
-+
-+
-+/*
-  * 'get_device()' - Create or update a device.
-  */
- 
-@@ -589,20 +854,7 @@ get_device(cups_array_t *devices,	/* I -
-   */
- 
-   key.name = (char *)serviceName;
--
--  if (!strcmp(regtype, "_ipp._tcp."))
--    key.type = CUPS_DEVICE_IPP;
--  else if (!strcmp(regtype, "_ipps._tcp.") ||
--	   !strcmp(regtype, "_ipp-tls._tcp."))
--    key.type = CUPS_DEVICE_IPPS;
--  else if (!strcmp(regtype, "_fax-ipp._tcp."))
--    key.type = CUPS_DEVICE_FAX_IPP;
--  else if (!strcmp(regtype, "_printer._tcp."))
--    key.type = CUPS_DEVICE_PRINTER;
--  else if (!strcmp(regtype, "_pdl-datastream._tcp."))
--    key.type = CUPS_DEVICE_PDL_DATASTREAM;
--  else
--    key.type = CUPS_DEVICE_RIOUSBPRINT;
-+  key.type = device_type (regtype);
- 
-   for (device = cupsArrayFind(devices, &key);
-        device;
-@@ -622,8 +874,14 @@ get_device(cups_array_t *devices,	/* I -
-         free(device->domain);
- 	device->domain = strdup(replyDomain);
- 
-+#ifdef HAVE_DNSSD
- 	DNSServiceConstructFullName(fullName, device->name, regtype,
- 	                            replyDomain);
-+#else /* HAVE_AVAHI */
-+	avahi_service_name_join (fullName, kDNSServiceMaxDomainName,
-+				 serviceName, regtype, replyDomain);
-+#endif /* HAVE_DNSSD */
-+
- 	free(device->fullName);
- 	device->fullName = strdup(fullName);
-       }
-@@ -643,6 +901,9 @@ get_device(cups_array_t *devices,	/* I -
-   device->domain   = strdup(replyDomain);
-   device->type     = key.type;
-   device->priority = 50;
-+#ifdef HAVE_AVAHI
-+  device->resolved = 0;
-+#endif /* HAVE_AVAHI */
- 
-   cupsArrayAdd(devices, device);
- 
-@@ -650,13 +911,20 @@ get_device(cups_array_t *devices,	/* I -
-   * Set the "full name" of this service, which is used for queries...
-   */
- 
-+#ifdef HAVE_DNSSD
-   DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain);
-+#else /* HAVE_AVAHI */
-+  avahi_service_name_join (fullName, kDNSServiceMaxDomainName,
-+			   serviceName, regtype, replyDomain);
-+#endif /* HAVE_DNSSD */
-+
-   device->fullName = strdup(fullName);
- 
-   return (device);
- }
- 
- 
-+#ifdef HAVE_DNSSD
- /*
-  * 'query_callback()' - Process query data.
-  */
-@@ -680,7 +948,7 @@ query_callback(
- 		*ptr;			/* Pointer into string */
-   cups_device_t	dkey,			/* Search key */
- 		*device;		/* Device */
--
-+  cups_txt_records_t txt;
- 
-   fprintf(stderr, "DEBUG2: query_callback(sdRef=%p, flags=%x, "
-                   "interfaceIndex=%d, errorCode=%d, fullName=\"%s\", "
-@@ -714,94 +982,233 @@ query_callback(
-   if ((ptr = strstr(name, "._")) != NULL)
-     *ptr = '\0';
- 
--  if (strstr(fullName, "_ipp._tcp."))
--    dkey.type = CUPS_DEVICE_IPP;
--  else if (strstr(fullName, "_ipps._tcp.") ||
--           strstr(fullName, "_ipp-tls._tcp."))
--    dkey.type = CUPS_DEVICE_IPPS;
--  else if (strstr(fullName, "_fax-ipp._tcp."))
--    dkey.type = CUPS_DEVICE_FAX_IPP;
--  else if (strstr(fullName, "_printer._tcp."))
--    dkey.type = CUPS_DEVICE_PRINTER;
--  else if (strstr(fullName, "_pdl-datastream._tcp."))
--    dkey.type = CUPS_DEVICE_PDL_DATASTREAM;
-+  dkey.type = device_type (fullName);
-+
-+  txt.data = rdata;
-+  txt.dataend = rdata + rdlen;
-+  device = find_device ((cups_array_t *) context, &txt, &dkey);
-+  if (!device)
-+    fprintf(stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName);
-+}
-+#endif /* HAVE_DNSSD */
-+
-+
-+#ifdef HAVE_AVAHI
-+/*
-+ * 'avahi_client_callback()' - Avahi client callback function.
-+ */
-+
-+static void
-+avahi_client_callback(AvahiClient *client,
-+		      AvahiClientState state,
-+		      void *context)
-+{
-+ /*
-+  * If the connection drops, quit.
-+  */
-+
-+  if (state == AVAHI_CLIENT_FAILURE)
-+  {
-+    fprintf (stderr, "ERROR: Avahi connection failed\n");
-+    avahi_simple_poll_quit (simple_poll);
-+  }
-+}
-+
-+
-+/*
-+ * 'avahi_query_callback()' - Avahi query callback function.
-+ */
-+
-+static void
-+avahi_query_callback(AvahiServiceResolver *resolver,
-+		     AvahiIfIndex interface,
-+		     AvahiProtocol protocol,
-+		     AvahiResolverEvent event,
-+		     const char *name,
-+		     const char *type,
-+		     const char *domain,
-+		     const char *host_name,
-+		     const AvahiAddress *address,
-+		     uint16_t port,
-+		     AvahiStringList *txt,
-+		     AvahiLookupResultFlags flags,
-+		     void *context)
-+{
-+  AvahiClient		*client;
-+  cups_device_t		key,
-+			*device;
-+  char			uqname[1024],
-+			*ptr;
-+  cups_txt_records_t	txtr;
-+
-+  client = avahi_service_resolver_get_client (resolver);
-+  if (event != AVAHI_RESOLVER_FOUND)
-+  {
-+    if (event == AVAHI_RESOLVER_FAILURE)
-+    {
-+      fprintf (stderr, "ERROR: %s\n",
-+	       avahi_strerror (avahi_client_errno (client)));
-+    }
-+
-+    avahi_service_resolver_free (resolver);
-+    return;
-+  }
-+
-+ /*
-+  * Set search key for device.
-+  */
-+
-+  key.name = uqname;
-+  unquote (uqname, name, sizeof (uqname));
-+  if ((ptr = strstr(name, "._")) != NULL)
-+    *ptr = '\0';
-+
-+  key.domain = (char *) domain;
-+  key.type = device_type (type);
-+
-+ /*
-+  * Find the device and the the TXT information.
-+  */
-+
-+  txtr.txt = txt;
-+  device = find_device ((cups_array_t *) context, &txtr, &key);
-+  if (device)
-+  {
-+   /*
-+    * Let the main loop know to announce the device.
-+    */
-+
-+    device->resolved = 1;
-+    avahi_got_callback = 1;
-+  }
-   else
--    dkey.type = CUPS_DEVICE_RIOUSBPRINT;
-+    fprintf (stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", name);
-+
-+  avahi_service_resolver_free (resolver);
-+}
-+
-+
-+/*
-+ * 'avahi_browse_callback()' - Avahi browse callback function.
-+ */
-+
-+static void
-+avahi_browse_callback(AvahiServiceBrowser *browser,
-+		      AvahiIfIndex interface,
-+		      AvahiProtocol protocol,
-+		      AvahiBrowserEvent event,
-+		      const char *name,
-+		      const char *type,
-+		      const char *domain,
-+		      AvahiLookupResultFlags flags,
-+		      void *context)
-+{
-+  AvahiClient *client = avahi_service_browser_get_client (browser);
-+
-+  switch (event)
-+  {
-+  case AVAHI_BROWSER_FAILURE:
-+    fprintf (stderr, "ERROR: %s\n",
-+	     avahi_strerror (avahi_client_errno (client)));
-+    avahi_simple_poll_quit (simple_poll);
-+    return;
-+
-+  case AVAHI_BROWSER_NEW:
-+   /*
-+    * This object is new on the network.
-+    */
-+
-+    if (flags & AVAHI_LOOKUP_RESULT_LOCAL)
-+    {
-+     /*
-+      * This comes from the local machine so ignore it.
-+      */
-+
-+      fprintf (stderr, "DEBUG: ignoring local service %s\n", name);
-+    }
-+    else
-+    {
-+     /*
-+      * Create a device entry for it if it doesn't yet exist.
-+      */
-+
-+      get_device ((cups_array_t *)context, name, type, domain);
-+
-+     /*
-+      * Now look for a TXT entry.
-+      */
-+
-+      if (avahi_service_resolver_new (client, interface, protocol,
-+				      name, type, domain,
-+				      AVAHI_PROTO_UNSPEC, 0,
-+				      avahi_query_callback, context) == NULL)
-+      {
-+	fprintf (stderr, "ERROR: failed to resolve service %s: %s\n",
-+		 name, avahi_strerror (avahi_client_errno (client)));
-+      }
-+    }
-+
-+    break;
-+
-+  case AVAHI_BROWSER_REMOVE:
-+  case AVAHI_BROWSER_ALL_FOR_NOW:
-+  case AVAHI_BROWSER_CACHE_EXHAUSTED:
-+    break;
-+  }
-+}
-+#endif /* HAVE_AVAHI */
-+
- 
--  for (device = cupsArrayFind(devices, &dkey);
-+/*
-+ * 'find_device()' - Find a device from its name and domain.
-+ */
-+
-+static cups_device_t *
-+find_device (cups_array_t *devices,
-+	     cups_txt_records_t *txt,
-+	     cups_device_t *dkey)
-+{
-+  cups_device_t	*device;
-+  char		*ptr;
-+
-+  for (device = cupsArrayFind(devices, dkey);
-        device;
-        device = cupsArrayNext(devices))
-   {
--    if (_cups_strcasecmp(device->name, dkey.name) ||
--        _cups_strcasecmp(device->domain, dkey.domain))
-+    if (_cups_strcasecmp(device->name, dkey->name) ||
-+        _cups_strcasecmp(device->domain, dkey->domain))
-     {
-       device = NULL;
-       break;
-     }
--    else if (device->type == dkey.type)
-+    else if (device->type == dkey->type)
-     {
-      /*
-       * Found it, pull out the priority and make and model from the TXT
-       * record and save it...
-       */
- 
--      const uint8_t	*data,		/* Pointer into data */
--			*datanext,	/* Next key/value pair */
--			*dataend;	/* End of entire TXT record */
--      uint8_t		datalen;	/* Length of current key/value pair */
--      char		key[256],	/* Key string */
--			value[256],	/* Value string */
--			make_and_model[512],
-+      char		make_and_model[512],
- 				      	/* Manufacturer and model */
- 			model[256],	/* Model */
--			device_id[2048];/* 1284 device ID */
--
-+			device_id[2048]; /* 1284 device ID */
- 
-       device_id[0]      = '\0';
-       make_and_model[0] = '\0';
- 
-       strcpy(model, "Unknown");
- 
--      for (data = rdata, dataend = data + rdlen;
--           data < dataend;
--           data = datanext)
-+      for (;;)
-       {
--       /*
--        * Read a key/value pair starting with an 8-bit length.  Since the
--	* length is 8 bits and the size of the key/value buffers is 256, we
--	* don't need to check for overflow...
--	*/
--
--        datalen = *data++;
--
--        if (!datalen || (data + datalen) > dataend)
--	  break;
--
--        datanext = data + datalen;
--
--        for (ptr = key; data < datanext && *data != '='; data ++)
--	  *ptr++ = *data;
--	*ptr = '\0';
-+	char *key;
-+	char *value;
- 
--	if (data < datanext && *data == '=')
--	{
--	  data ++;
--
--	  if (data < datanext)
--	    memcpy(value, data, datanext - data);
--	  value[datanext - data] = '\0';
-+	if (parse_txt_record_pair (txt))
-+	  goto next;
- 
--	  fprintf(stderr, "DEBUG2: query_callback: \"%s=%s\".\n",
--	          key, value);
--	}
--	else
--	{
--	  fprintf(stderr, "DEBUG2: query_callback: \"%s\" with no value.\n",
--	          key);
--	  continue;
--	}
--
--        if (!_cups_strncasecmp(key, "usb_", 4))
-+	key = txt->key;
-+	value = txt->value;
-+        if (!strncasecmp(key, "usb_", 4))
- 	{
- 	 /*
- 	  * Add USB device ID information...
-@@ -856,6 +1263,10 @@ query_callback(
- 	  if (device->type == CUPS_DEVICE_PRINTER)
- 	    device->sent = 1;
- 	}
-+
-+      next:
-+	if (next_txt_record (txt) == NULL)
-+	  break;
-       }
- 
-       if (device->device_id)
-@@ -912,11 +1323,9 @@ query_callback(
-     }
-   }
- 
--  if (!device)
--    fprintf(stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName);
-+  return device;
- }
- 
--
- /*
-  * 'sigterm_handler()' - Handle termination signals...
-  */
-diff -up cups-1.5.2/cups/http-support.c.avahi-2-backend cups-1.5.2/cups/http-support.c
---- cups-1.5.2/cups/http-support.c.avahi-2-backend	2011-09-26 20:46:46.000000000 +0200
-+++ cups-1.5.2/cups/http-support.c	2012-02-06 11:09:08.327644629 +0100
-@@ -43,6 +43,10 @@
-  *   http_copy_decode()   - Copy and decode a URI.
-  *   http_copy_encode()   - Copy and encode a URI.
-  *   http_resolve_cb()    - Build a device URI for the given service name.
-+ *   avahi_resolve_uri_client_cb()
-+ *                        - Avahi client callback for resolving URI.
-+ *   avahi_resolve_uri_resolver_cb()
-+ *                        - Avahi resolver callback for resolving URI.
-  */
- 
- /*
-@@ -60,6 +64,11 @@
- #    include <sys/select.h>
- #  endif /* WIN32 */
- #endif /* HAVE_DNSSD */
-+#ifdef HAVE_AVAHI
-+#  include <avahi-client/client.h>
-+#  include <avahi-client/lookup.h>
-+#  include <avahi-common/simple-watch.h>
-+#endif /* HAVE_AVAHI */
- 
- 
- /*
-@@ -127,6 +136,24 @@ static void DNSSD_API	http_resolve_cb(DN
- 					void *context);
- #endif /* HAVE_DNSSD */
- 
-+#ifdef HAVE_AVAHI
-+static void	avahi_resolve_uri_client_cb(AvahiClient *client,
-+					    AvahiClientState state,
-+					    void *simple_poll);
-+static void	avahi_resolve_uri_resolver_cb(AvahiServiceResolver *resolver,
-+					      AvahiIfIndex interface,
-+					      AvahiProtocol protocol,
-+					      AvahiResolverEvent event,
-+					      const char *name,
-+					      const char *type,
-+					      const char *domain,
-+					      const char *host_name,
-+					      const AvahiAddress *address,
-+					      uint16_t port,
-+					      AvahiStringList *txt,
-+					      AvahiLookupResultFlags flags,
-+					      void *context);
-+#endif /* HAVE_AVAHI */
- 
- /*
-  * 'httpAssembleURI()' - Assemble a uniform resource identifier from its
-@@ -1431,6 +1458,9 @@ _httpResolveURI(
- 
-   if (strstr(hostname, "._tcp"))
-   {
-+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
-+    char		*regtype,	/* Pointer to type in hostname */
-+			*domain;	/* Pointer to domain in hostname */
- #ifdef HAVE_DNSSD
- #  ifdef WIN32
- #    pragma comment(lib, "dnssd.lib")
-@@ -1449,6 +1479,17 @@ _httpResolveURI(
-     fd_set		input_set;	/* Input set for select() */
-     struct timeval	stimeout;	/* Timeout value for select() */
- #endif /* HAVE_POLL */
-+#else /* HAVE_AVAHI */
-+    AvahiSimplePoll	*simple_poll;
-+    AvahiClient		*client;
-+    int			error;
-+    struct
-+    {
-+      AvahiSimplePoll	*poll;
-+      _http_uribuf_t	uribuf;
-+    } user_data;
-+#endif /* HAVE_DNSSD */
-+
- 
-     if (options & _HTTP_RESOLVE_STDERR)
-       fprintf(stderr, "DEBUG: Resolving \"%s\"...\n", hostname);
-@@ -1485,9 +1526,16 @@ _httpResolveURI(
-     if (domain)
-       *domain++ = '\0';
- 
-+#ifdef HAVE_DNSSD
-     uribuf.buffer   = resolved_uri;
-     uribuf.bufsize  = resolved_size;
-     uribuf.options  = options;
-+#else
-+    user_data.uribuf.buffer = resolved_uri;
-+    user_data.uribuf.bufsize = resolved_size;
-+    user_data.uribuf.options = options;
-+#endif
-+
-     resolved_uri[0] = '\0';
- 
-     DEBUG_printf(("6_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
-@@ -1501,6 +1549,7 @@ _httpResolveURI(
- 
-     uri = NULL;
- 
-+#ifdef HAVE_DNSSD
-     if (DNSServiceCreateConnection(&ref) == kDNSServiceErr_NoError)
-     {
-       localref = ref;
-@@ -1608,6 +1657,36 @@ _httpResolveURI(
- 
-       DNSServiceRefDeallocate(ref);
-     }
-+#else /* HAVE_AVAHI */
-+    if ((simple_poll = avahi_simple_poll_new ()) != NULL)
-+    {
-+      if ((client = avahi_client_new (avahi_simple_poll_get (simple_poll),
-+				      0, avahi_resolve_uri_client_cb,
-+				      &simple_poll, &error)) != NULL)
-+      {
-+	user_data.poll = simple_poll;
-+	if (avahi_service_resolver_new (client, AVAHI_IF_UNSPEC,
-+					AVAHI_PROTO_UNSPEC, hostname,
-+					regtype, domain, AVAHI_PROTO_UNSPEC, 0,
-+					avahi_resolve_uri_resolver_cb,
-+					&user_data) != NULL)
-+	{
-+	  avahi_simple_poll_loop (simple_poll);
-+
-+	 /*
-+	  * Collect the result.
-+	  */
-+
-+	  if (resolved_uri[0])
-+	    uri = resolved_uri;
-+	}
-+
-+	avahi_client_free (client);
-+      }
-+
-+      avahi_simple_poll_free (simple_poll);
-+    }
-+#endif /* HAVE_DNSSD */
- 
-     if (options & _HTTP_RESOLVE_STDERR)
-     {
-@@ -1619,13 +1698,13 @@ _httpResolveURI(
-       fputs("STATE: -connecting-to-device,offline-report\n", stderr);
-     }
- 
--#else
-+#else /* HAVE_DNSSD || HAVE_AVAHI */
-    /*
-     * No DNS-SD support...
-     */
- 
-     uri = NULL;
--#endif /* HAVE_DNSSD */
-+#endif /* HAVE_DNSSD || HAVE_AVAHI */
- 
-     if ((options & _HTTP_RESOLVE_STDERR) && !uri)
-       _cupsLangPrintFilter(stderr, "ERROR", _("Unable to find printer."));
-@@ -1914,6 +1993,116 @@ http_resolve_cb(
- #endif /* HAVE_DNSSD */
- 
- 
-+#ifdef HAVE_AVAHI
-+/*
-+ * 'avahi_resolve_uri_client_cb()' - Avahi client callback for resolving URI.
-+ */
-+
-+static void
-+avahi_resolve_uri_client_cb (AvahiClient *client,
-+			     AvahiClientState state,
-+			     void *simple_poll)
-+{
-+  DEBUG_printf(("avahi_resolve_uri_client_callback(client=%p, state=%d, "
-+		"simple_poll=%p)\n", client, state, simple_poll));
-+
-+  /*
-+   * If the connection drops, quit.
-+   */
-+
-+  if (state == AVAHI_CLIENT_FAILURE)
-+    avahi_simple_poll_quit (simple_poll);
-+}
-+
-+
-+/*
-+ * 'avahi_resolve_uri_resolver_cb()' - Avahi resolver callback for resolving
-+ *                                     URI.
-+ */
-+
-+static void
-+avahi_resolve_uri_resolver_cb (AvahiServiceResolver *resolver,
-+			       AvahiIfIndex interface,
-+			       AvahiProtocol protocol,
-+			       AvahiResolverEvent event,
-+			       const char *name,
-+			       const char *type,
-+			       const char *domain,
-+			       const char *host_name,
-+			       const AvahiAddress *address,
-+			       uint16_t port,
-+			       AvahiStringList *txt,
-+			       AvahiLookupResultFlags flags,
-+			       void *context)
-+{
-+  const char		*scheme;	/* URI scheme */
-+  char			rp[256];	/* Remote printer */
-+  AvahiStringList	*pair;
-+  char			*value;
-+  size_t		valueLen = 0;
-+  char			addr[AVAHI_ADDRESS_STR_MAX];
-+  struct
-+  {
-+    AvahiSimplePoll	*poll;
-+    _http_uribuf_t	uribuf;
-+  }		*poll_uribuf = context;
-+
-+  DEBUG_printf(("avahi_resolve_uri_resolver_callback(resolver=%p, "
-+		"interface=%d, protocol=%d, event=%d, name=\"%s\", "
-+		"type=\"%s\", domain=\"%s\", host_name=\"%s\", address=%p, "
-+		"port=%d, txt=%p, flags=%d, context=%p)\n",
-+		resolver, interface, protocol, event, name, type, domain,
-+		host_name, address, port, txt, flags, context));
-+
-+  if (event != AVAHI_RESOLVER_FOUND)
-+  {
-+    avahi_service_resolver_free (resolver);
-+    avahi_simple_poll_quit (poll_uribuf->poll);
-+    return;
-+  }
-+
-+ /*
-+  * Figure out the scheme from the full name...
-+  */
-+
-+  if (strstr(type, "_ipp."))
-+    scheme = "ipp";
-+  else if (strstr(type, "_printer."))
-+    scheme = "lpd";
-+  else if (strstr(type, "_pdl-datastream."))
-+    scheme = "socket";
-+  else
-+    scheme = "riousbprint";
-+
-+ /*
-+  * Extract the "remote printer key from the TXT record...
-+  */
-+
-+  if ((pair = avahi_string_list_find (txt, "rp")) != NULL)
-+  {
-+    avahi_string_list_get_pair (pair, NULL, &value, &valueLen);
-+    rp[0] = '/';
-+    memcpy (rp + 1, value, valueLen);
-+    rp[valueLen + 1] = '\0';
-+  }
-+  else
-+    rp[0] = '\0';
-+
-+ /*
-+  * Assemble the final device URI...
-+  */
-+
-+  avahi_address_snprint (addr, AVAHI_ADDRESS_STR_MAX, address);
-+  httpAssembleURI(HTTP_URI_CODING_ALL, poll_uribuf->uribuf.buffer,
-+		  poll_uribuf->uribuf.bufsize, scheme, NULL,
-+		  addr, port, rp);
-+  DEBUG_printf(("avahi_resolve_uri_resolver_callback: Resolved URI is \"%s\"\n",
-+		poll_uribuf->uribuf.buffer));
-+  avahi_simple_poll_quit (poll_uribuf->poll);
-+}
-+#endif /* HAVE_AVAHI */
-+
-+
- /*
-  * End of "$Id: http-support.c 10017 2011-09-26 18:46:46Z mike $".
-  */

var/vabs/cups/src/patches/cups-avahi-3-timeouts.patch

-diff -up cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts cups-1.5.0/scheduler/cupsd.h
---- cups-1.5.0/scheduler/cupsd.h.avahi-3-timeouts	2011-05-11 23:17:34.000000000 +0100
-+++ cups-1.5.0/scheduler/cupsd.h	2011-10-07 13:20:41.522867324 +0100
-@@ -140,6 +140,15 @@ extern const char *cups_hstrerror(int);
- 
- typedef void (*cupsd_selfunc_t)(void *data);
- 
-+#ifdef HAVE_AVAHI
-+/*
-+ * Timeout callback function type...
-+ */
-+
-+typedef struct _cupsd_timeout_s cupsd_timeout_t;
-+typedef void (*cupsd_timeoutfunc_t)(cupsd_timeout_t *timeout, void *data);
-+#endif /* HAVE_AVAHI */
-+
- 
- /*
-  * Globals...
-@@ -173,6 +182,11 @@ VAR int			Launchd		VALUE(0);
- 					/* Running from launchd */
- #endif /* HAVE_LAUNCH_H */
- 
-+#ifdef HAVE_AVAHI
-+VAR cups_array_t *Timeouts;		/* Timed callbacks for main loop */
-+#endif /* HAVE_AVAHI */
-+
-+
- 
- /*
-  * Prototypes...
-@@ -242,6 +256,20 @@ extern void		cupsdStopSelect(void);
- extern void		cupsdStartServer(void);
- extern void		cupsdStopServer(void);
- 
-+#ifdef HAVE_AVAHI
-+extern void     cupsdInitTimeouts(void);
-+extern cupsd_timeout_t *cupsdAddTimeout (const struct timeval *tv,
-+					 cupsd_timeoutfunc_t cb,
-+					 void *data);
-+extern cupsd_timeout_t *cupsdNextTimeout (long *delay);
-+extern void     cupsdRunTimeout (cupsd_timeout_t *timeout);
-+extern void     cupsdUpdateTimeout (cupsd_timeout_t *timeout,
-+				    const struct timeval *tv);
-+extern void     cupsdRemoveTimeout (cupsd_timeout_t *timeout);
-+#endif /* HAVE_AVAHI */
-+
-+extern int	cupsdRemoveFile(const char *filename);
-+
- 
- /*
-  * End of "$Id: cupsd.h 9766 2011-05-11 22:17:34Z mike $".
-diff -up cups-1.5.0/scheduler/main.c.avahi-3-timeouts cups-1.5.0/scheduler/main.c
---- cups-1.5.0/scheduler/main.c.avahi-3-timeouts	2011-10-07 13:20:36.875954675 +0100
-+++ cups-1.5.0/scheduler/main.c	2011-10-07 13:20:41.524867282 +0100
-@@ -146,6 +146,10 @@ main(int  argc,				/* I - Number of comm
-   int			launchd_idle_exit;
- 					/* Idle exit on select timeout? */
- #endif	/* HAVE_LAUNCHD */
-+#ifdef HAVE_AVAHI
-+  cupsd_timeout_t	*tmo;		/* Next scheduled timed callback */
-+  long			tmo_delay;	/* Time before it must be called */
-+#endif /* HAVE_AVAHI */
- 
- 
- #ifdef HAVE_GETEUID
-@@ -535,6 +539,14 @@ main(int  argc,				/* I - Number of comm
- 
-   httpInitialize();
- 
-+#ifdef HAVE_AVAHI
-+ /*
-+  * Initialize timed callback structures.
-+  */
-+
-+  cupsdInitTimeouts();
-+#endif /* HAVE_AVAHI */
-+
-   cupsdStartServer();
- 
-  /*
-@@ -874,6 +886,16 @@ main(int  argc,				/* I - Number of comm
-     }
- #endif /* __APPLE__ */
- 
-+#ifdef HAVE_AVAHI
-+   /*
-+    * If a timed callback is due, run it.
-+    */
-+
-+    tmo = cupsdNextTimeout (&tmo_delay);
-+    if (tmo && tmo_delay == 0)
-+      cupsdRunTimeout (tmo);
-+#endif /* HAVE_AVAHI */
-+
- #ifndef __APPLE__
-    /*
-     * Update the network interfaces once a minute...
-@@ -1787,6 +1809,10 @@ select_timeout(int fds)			/* I - Number
-   cupsd_job_t		*job;		/* Job information */
-   cupsd_subscription_t	*sub;		/* Subscription information */
-   const char		*why;		/* Debugging aid */
-+#ifdef HAVE_AVAHI
-+  cupsd_timeout_t	*tmo;		/* Timed callback */
-+  long			tmo_delay;	/* Seconds before calling it */
-+#endif /* HAVE_AVAHI */
- 
- 
-  /*
-@@ -1829,6 +1855,19 @@ select_timeout(int fds)			/* I - Number
-   }
- #endif /* __APPLE__ */
- 
-+#ifdef HAVE_AVAHI
-+ /*
-+  * See if there are any scheduled timed callbacks to run.
-+  */
-+
-+  tmo = cupsdNextTimeout (&tmo_delay);
-+  if (tmo)
-+  {
-+    timeout = tmo_delay;
-+    why = "run a timed callback";
-+  }
-+#endif /* HAVE_AVAHI */
-+
-  /*
-   * Check whether we are accepting new connections...
-   */
-diff -up cups-1.5.0/scheduler/Makefile.avahi-3-timeouts cups-1.5.0/scheduler/Makefile
---- cups-1.5.0/scheduler/Makefile.avahi-3-timeouts	2011-10-07 13:20:36.955953170 +0100
-+++ cups-1.5.0/scheduler/Makefile	2011-10-07 13:20:41.521867343 +0100
-@@ -39,7 +39,8 @@ CUPSDOBJS =	\
- 		server.o \
- 		statbuf.o \
- 		subscriptions.o \
--		sysman.o
-+		sysman.o \
-+		timeout.o
- LIBOBJS =	\
- 		filter.o \
- 		mime.o \
-diff -up cups-1.5.0/scheduler/timeout.c.avahi-3-timeouts cups-1.5.0/scheduler/timeout.c
---- cups-1.5.0/scheduler/timeout.c.avahi-3-timeouts	2011-10-07 13:20:41.525867259 +0100
-+++ cups-1.5.0/scheduler/timeout.c	2011-10-07 13:20:41.525867259 +0100
-@@ -0,0 +1,235 @@
-+/*
-+ * "$Id$"
-+ *
-+ *   Timeout functions for the Common UNIX Printing System (CUPS).
-+ *
-+ *   Copyright (C) 2010, 2011 Red Hat, Inc.
-+ *   Authors:
-+ *     Tim Waugh <twaugh@redhat.com>
-+ *
-+ *   Redistribution and use in source and binary forms, with or without
-+ *   modification, are permitted provided that the following conditions
-+ *   are met:
-+ *
-+ *   Redistributions of source code must retain the above copyright
-+ *   notice, this list of conditions and the following disclaimer.
-+ *
-+ *   Redistributions in binary form must reproduce the above copyright
-+ *   notice, this list of conditions and the following disclaimer in the
-+ *   documentation and/or other materials provided with the distribution.
-+ *
-+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-+ *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-+ *   COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-+ *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-+ *   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-+ *   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-+ *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-+ *   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-+ *   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-+ *   OF THE POSSIBILITY OF SUCH DAMAGE.
-+ *
-+ * Contents:
-+ *
-+ *   cupsdInitTimeouts()  - Initialise timeout structure.
-+ *   cupsdAddTimeout()    - Add a timed callback.
-+ *   cupsdNextTimeout()   - Find the next enabled timed callback.
-+ *   cupsdUpdateTim