#!/bin/sh

. config/options $1

# add_user pulse x 499 498 "PulseAudio System Daemon" "/var/run/pulse" "/bin/sh"
# add_group pulse 498
# add_group pulse-access 497

mkdir -p $INSTALL/etc/dbus-1/system.d
  cp $PKG_BUILD/src/daemon/pulseaudio-system.conf $INSTALL/etc/dbus-1/system.d
  sed -e 's%user="pulse"%user="root"%g' -i $INSTALL/etc/dbus-1/system.d/pulseaudio-system.conf

mkdir -p $INSTALL/etc
  cp $PKG_DIR/config/asound.conf $INSTALL/etc

mkdir -p $INSTALL/etc/alsa
  cp $PKG_DIR/config/pulse-default.conf $INSTALL/etc/alsa

mkdir -p $INSTALL/etc/pulse
  cp $PKG_BUILD/src/client.conf $INSTALL/etc/pulse
  cp $PKG_BUILD/src/daemon.conf $INSTALL/etc/pulse
#  cp $PKG_BUILD/src/default.pa $INSTALL/etc/pulse
  cp $PKG_DIR/config/default.pa $INSTALL/etc/pulse
  cp $PKG_BUILD/src/system.pa $INSTALL/etc/pulse

mkdir -p $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/src/modules/alsa/mixer/profile-sets/90-pulseaudio.rules $INSTALL/lib/udev/rules.d

mkdir -p $INSTALL/usr/bin
  cp $PKG_BUILD/src/.libs/pacat $INSTALL/usr/bin
  cp $PKG_BUILD/src/.libs/pacmd $INSTALL/usr/bin
  cp $PKG_BUILD/src/.libs/pactl $INSTALL/usr/bin
  ln -sf pactl $INSTALL/usr/bin/pamon
  ln -sf pactl $INSTALL/usr/bin/paplay
  ln -sf pactl $INSTALL/usr/bin/parec
  ln -sf pactl $INSTALL/usr/bin/parecord
  cp $PKG_BUILD/src/.libs/pasuspender $INSTALL/usr/bin
  cp $PKG_BUILD/src/.libs/pax11publish $INSTALL/usr/bin
  cp $PKG_BUILD/src/.libs/pulseaudio $INSTALL/usr/bin
#  cp $PKG_BUILD/src/start-pulseaudio-x11 $INSTALL/usr/bin

mkdir -p $INSTALL/usr/lib
  cp -P $PKG_BUILD/src/.libs/libpulse*.so* $INSTALL/usr/lib
  rm -rf $INSTALL/usr/lib/libpulse*.so*T

mkdir -p $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libalsa-util.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libavahi-wrap.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libcli.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libprotocol-cli.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libprotocol-esound.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libprotocol-http.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libprotocol-native.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libprotocol-simple.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/libraop.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/librtp.so $INSTALL/usr/lib/pulse
  cp -P $PKG_BUILD/src/.libs/module-*.so $INSTALL/usr/lib/pulse

mkdir -p $INSTALL/usr/share/pulseaudio/alsa-mixer/paths
  cp $PKG_BUILD/src/modules/alsa/mixer/paths/* $INSTALL/usr/share/pulseaudio/alsa-mixer/paths

mkdir -p $INSTALL/usr/share/pulseaudio/alsa-mixer/profile-sets
  cp $PKG_BUILD/src/modules/alsa/mixer/profile-sets/*.conf $INSTALL/usr/share/pulseaudio/alsa-mixer/profile-sets
