#!/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

add_group cdrom 11
add_group dialout 18
add_group disk 6
add_group floppy 19
add_group kmem 9
add_group lp 7
add_group tape 33
add_group tty 5
add_group video 39

# install udev

mkdir -p $INSTALL/usr/bin
  cp $PKG_BUILD/udevadm $INSTALL/usr/bin

mkdir -p $INSTALL/lib
  cp -PR $PKG_BUILD/.libs/libsystemd-daemon.so* $INSTALL/lib
  cp -PR $PKG_BUILD/.libs/libudev.so* $INSTALL/lib
  cp -PR $PKG_BUILD/.libs/libgudev*.so* $INSTALL/lib
  rm -rf $INSTALL/lib/libgudev*.*T

mkdir -p $INSTALL/lib/systemd
  cp $PKG_BUILD/systemd-udevd $INSTALL/lib/systemd

  cp $PKG_BUILD/.libs/accelerometer $INSTALL/lib/udev
  cp $PKG_BUILD/.libs/cdrom_id $INSTALL/lib/udev
  cp $PKG_BUILD/.libs/v4l_id $INSTALL/lib/udev

  for i in ata_id collect scsi_id; do
    cp $PKG_BUILD/$i $INSTALL/lib/udev
  done
  cp $PKG_BUILD/mtd_probe $INSTALL/lib/udev

  cp $PKG_BUILD/keymap $INSTALL/lib/udev
  cp $PKG_BUILD/src/udev/keymap/findkeyboards $INSTALL/lib/udev
  cp $PKG_BUILD/src/udev/keymap/keyboard-force-release.sh $INSTALL/lib/udev
mkdir -p $INSTALL/lib/udev/keymaps
  cp $PKG_BUILD/keymaps/* $INSTALL/lib/udev/keymaps
mkdir -p $INSTALL/lib/udev/keymaps/force-release
  cp $PKG_BUILD/keymaps-force-release/* $INSTALL/lib/udev/keymaps/force-release

mkdir -p $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/rules/*.rules $INSTALL/lib/udev/rules.d
  rm -rf $INSTALL/lib/udev/rules.d/80-net-name-slot.rules
  rm -rf $INSTALL/lib/udev/rules.d/99-systemd.rules
  cp $PKG_BUILD/src/udev/keymap/*.rules $INSTALL/lib/udev/rules.d


mkdir -p $INSTALL/lib/udev/hwdb.d
  cp $PKG_BUILD/hwdb/*.hwdb $INSTALL/lib/udev/hwdb.d

mkdir -p $INSTALL/etc/udev
  cp $PKG_BUILD/src/udev/udev.conf $INSTALL/etc/udev
  ln -sf /dev/rules.d $INSTALL/etc/udev/rules.d

mkdir -p $INSTALL/usr/config
  cp -R $PKG_DIR/config/*.sample $INSTALL/usr/config

# reserved for installing systemd

