#!/bin/sh

. config/options $1

mkdir -p $INSTALL/etc/dbus-1/system.d
  cp -P $PKG_BUILD/data/org.freedesktop.PolicyKit1.conf $INSTALL/etc/dbus-1/system.d

mkdir -p $INSTALL/etc/polkit-1/localauthority
  echo "chmod 700 $INSTALL/etc/polkit-1/localauthority" >> $FAKEROOT_SCRIPT

mkdir -p $INSTALL/etc/polkit-1/localauthority/10-vendor.d
mkdir -p $INSTALL/etc/polkit-1/localauthority/20-org.d
mkdir -p $INSTALL/etc/polkit-1/localauthority/30-site.d
mkdir -p $INSTALL/etc/polkit-1/localauthority/50-local.d
mkdir -p $INSTALL/etc/polkit-1/localauthority/90-mandatory.d

mkdir -p $INSTALL/etc/polkit-1/localauthority.conf.d
  cp -P $PKG_BUILD/src/polkitbackend/50-localauthority.conf $INSTALL/etc/polkit-1/localauthority.conf.d

mkdir -p $INSTALL/etc/polkit-1/nullbackend.conf.d
  cp -P $PKG_BUILD/src/nullbackend/50-nullbackend.conf $INSTALL/etc/polkit-1/nullbackend.conf.d

mkdir -p $INSTALL/usr/bin
  cp -P $PKG_BUILD/src/programs/.libs/pkaction $INSTALL/usr/bin
  cp -P $PKG_BUILD/src/programs/.libs/pkcheck $INSTALL/usr/bin
  cp -P $PKG_BUILD/src/programs/.libs/pkexec $INSTALL/usr/bin
    echo "chmod 4755 $INSTALL/usr/bin/pkexec" >> $FAKEROOT_SCRIPT

mkdir -p $INSTALL/usr/lib
  cp -P $PKG_BUILD/src/polkitagent/.libs/libpolkit-agent-1.so* $INSTALL/usr/lib
  rm -rf $INSTALL/usr/lib/libpolkit-agent-1.so*T
  cp -P $PKG_BUILD/src/polkitbackend/.libs/libpolkit-backend-1.so* $INSTALL/usr/lib
  rm -rf $INSTALL/usr/lib/libpolkit-backend-1.so*T
  cp -P $PKG_BUILD/src/polkit/.libs/libpolkit-gobject-1.so* $INSTALL/usr/lib

mkdir -p $INSTALL/usr/lib/polkit-1/extensions
  cp -P $PKG_BUILD/src/nullbackend/.libs/*.so $INSTALL/usr/lib/polkit-1/extensions
  cp -P $PKG_BUILD/src/programs/.libs/*.so $INSTALL/usr/lib/polkit-1/extensions

mkdir -p $INSTALL/usr/lib/polkit-1
  cp -P $PKG_BUILD/src/polkitagent/.libs/polkit-agent-helper-1 $INSTALL/usr/lib/polkit-1
    echo "chmod 4755 $INSTALL/usr/lib/polkit-1/polkit-agent-helper-1" >> $FAKEROOT_SCRIPT
  cp -P $PKG_BUILD/src/polkitd/.libs/polkitd $INSTALL/usr/lib/polkit-1

mkdir -p $INSTALL/usr/share/dbus-1/system-services
  cp -P $PKG_BUILD/data/org.freedesktop.PolicyKit1.service $INSTALL/usr/share/dbus-1/system-services

mkdir -p $INSTALL/usr/share/polkit-1/actions
  cp -P $PKG_BUILD/actions/org.freedesktop.policykit.policy $INSTALL/usr/share/polkit-1/actions
