#!/bin/sh

. config/options
$SCRIPTS/unpack linux

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

if [ "$2" = initramfs ]; then
  mkdir -p $INSTALL/$2
  cp -PR $PKG_BUILD/_install-$2/* $INSTALL/$2

  cp $PKG_DIR/scripts/init.$2 $INSTALL/$2
fi

if [ "$2" = system ]; then
  cp -PR $PKG_BUILD/_install-$2/* $INSTALL
  mkdir -p $INSTALL/bin
  ln -sf /bin/sh $INSTALL/bin/bash

  mkdir -p $INSTALL/etc
  cp $PKG_DIR/config/passwd $INSTALL/etc
  cp $PKG_DIR/config/group $INSTALL/etc

  mkdir -p $INSTALL/usr/share/udhcpc
  cp $PKG_DIR/scripts/udhcp.script $INSTALL/usr/share/udhcpc/default.script

  mkdir -p $INSTALL/sbin
  cp $PKG_DIR/scripts/init.system $INSTALL/sbin/init.system

  # acpid specific
  mkdir -p $INSTALL/etc/acpi/PWRF
  cp $PKG_DIR/scripts/acpi_powerbtn $INSTALL/etc/acpi/PWRF/00000080

fi
