#!/bin/sh

. config/options

$SCRIPTS/install libnl
$SCRIPTS/install dbus
$SCRIPTS/install udev
$SCRIPTS/install Python
$SCRIPTS/install dbus-python
$SCRIPTS/install pygobject
#$SCRIPTS/install bluez
$SCRIPTS/install wpa_supplicant

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

add_user system x 430 430 "service" "/var/run/connman" "/bin/sh"
add_group system 430

mkdir -p $INSTALL/usr/sbin
  cp -P $PKG_BUILD/src/connmand $INSTALL/usr/sbin

mkdir -p $INSTALL/usr/bin
  cp -P $PKG_BUILD/client/cmc $INSTALL/usr/bin
  chmod +x $INSTALL/usr/bin/cmc

mkdir -p $INSTALL/usr/lib/connman/plugins
  cp -P $PKG_BUILD/plugins/.libs/*.so $INSTALL/usr/lib/connman/plugins

mkdir -p $INSTALL/usr/lib/connman/scripts
  cp -P $PKG_BUILD/scripts/udhcpc-script $INSTALL/usr/lib/connman/scripts

mkdir -p $INSTALL/etc/dbus-1/system.d
  cp -P $PKG_BUILD/src/connman.conf $INSTALL/etc/dbus-1/system.d

if [ "$DEVTOOLS" = yes ]; then
  mkdir -p $INSTALL/usr/bin/connman
    cp $PKG_BUILD/tools/addr-test $INSTALL/usr/bin/connman
    cp $PKG_BUILD/tools/dbus-test $INSTALL/usr/bin/connman
    cp $PKG_BUILD/tools/polkit-test $INSTALL/usr/bin/connman
    cp $PKG_BUILD/tools/portal-test $INSTALL/usr/bin/connman
    cp $PKG_BUILD/tools/supplicant-test $INSTALL/usr/bin/connman
    cp $PKG_BUILD/tools/tap-test $INSTALL/usr/bin/connman
    cp $PKG_BUILD/tools/wifi-scan $INSTALL/usr/bin/connman

  mkdir -p $INSTALL/usr/lib/connman/test
    cp $PKG_BUILD/test/* $INSTALL/usr/lib/connman/test
fi
