#!/bin/sh

################################################################################
#      This file is part of OpenELEC - http://www.openelec.tv
#      Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
#
#  This Program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with OpenELEC.tv; see the file COPYING.  If not, write to
#  the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
#  http://www.gnu.org/copyleft/gpl.html
################################################################################

. 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

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
