#!/bin/sh

. config/options

$SCRIPTS/install expat
$SCRIPTS/install libdaemon
$SCRIPTS/install dbus

PKG_DIR=`find $PACKAGES -type d -name $1`

add_user avahi x 495 495 "avahi-daemon" "/var/run/avahi-daemon" "/bin/sh"
add_group avahi 495

add_user avahiautoipd x 496 496 "avahi-autoipd" "/var/lib/avahi-autoipd" "/bin/sh"
add_group avahiautoipd 496

mkdir -p $INSTALL/usr/sbin
  cp -PR $PKG_BUILD/avahi-autoipd/avahi-autoipd $INSTALL/usr/sbin
  cp -PR $PKG_BUILD/avahi-daemon/.libs/avahi-daemon $INSTALL/usr/sbin
  cp -PR $PKG_BUILD/avahi-dnsconfd/.libs/avahi-dnsconfd $INSTALL/usr/sbin

mkdir -p $INSTALL/usr/lib
  cp -PR $PKG_BUILD/avahi-common/.libs/*.so*[.0-9] $INSTALL/usr/lib/
  cp -PR $PKG_BUILD/avahi-core/.libs/*.so*[.0-9] $INSTALL/usr/lib/
  cp -PR $PKG_BUILD/avahi-client/.libs/*.so*[.0-9] $INSTALL/usr/lib/

mkdir -p $INSTALL/etc/avahi
  cp -PR $PKG_BUILD/avahi-autoipd/avahi-autoipd.action $INSTALL/etc/avahi
  cp -PR $PKG_BUILD/avahi-daemon/avahi-daemon.conf $INSTALL/etc/avahi

mkdir -p $INSTALL/etc/avahi/services
  cp -PR $PKG_BUILD/avahi-daemon/sftp-ssh.service $INSTALL/etc/avahi/services
  cp -PR $PKG_BUILD/avahi-daemon/ssh.service $INSTALL/etc/avahi/services
  cp -PR $PKG_DIR/config/http.service $INSTALL/etc/avahi/services
  cp -PR $PKG_DIR/config/samba.service $INSTALL/etc/avahi/services

mkdir -p $INSTALL/etc/dbus-1/system.d
  cp -PR $PKG_BUILD/avahi-daemon/avahi-dbus.conf $INSTALL/etc/dbus-1/system.d

mkdir -p $INSTALL/usr/share/avahi
  cp -PR $PKG_BUILD/service-type-database/service-types $INSTALL/usr/share/avahi
  cp -PR $PKG_BUILD/avahi-daemon/avahi-service.dtd $INSTALL/usr/share/avahi

mkdir -p $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/ServiceTypeBrowser.introspect $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/HostNameResolver.introspect $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/EntryGroup.introspect $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/ServiceBrowser.introspect $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/Server.introspect $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/DomainBrowser.introspect $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/ServiceResolver.introspect $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/RecordBrowser.introspect $INSTALL/usr/share/avahi/introspection
  cp -PR $PKG_BUILD/avahi-daemon/AddressResolver.introspect $INSTALL/usr/share/avahi/introspection

mkdir -p $INSTALL/usr/share/udhcpc
  cp $PKG_DIR/scripts/udhcp-avahi.script $INSTALL/usr/share/udhcpc/default.script

