#!/bin/sh

. config/options

$SCRIPTS/install module-init-tools

RAMFS_DRV_SUBSYSTEMS="ata ide scsi"

PKG_DIR=`find $PACKAGES -type d -name $1`
VER=`ls $PKG_BUILD/modules/lib/modules`

mkdir -p $INSTALL/lib/modules/$VER
  cp -r $PKG_BUILD/modules/* $INSTALL
  rm -f $INSTALL/lib/modules/$VER/modules.*

$ROOT/$TOOLCHAIN/bin/depmod -b $INSTALL -v $VER > /dev/null

for i in `ls $INSTALL/lib/modules/*/modules.* | grep -v modules.dep | grep -v modules.alias | grep -v modules.symbols`; do
  rm -f $i
done

# copy kernel firmwares (if present)
mkdir -p $INSTALL/lib/firmware
  [ -d $PKG_BUILD/modules/lib/firmware ] && \
    cp -rf $PKG_BUILD/modules/lib/firmware/* $INSTALL/lib/firmware || true

mkdir -p $INSTALL/etc
  cp $PKG_DIR/config/modules $INSTALL/etc

mkdir -p $INSTALL/etc/modprobe.d

$SCRIPTS/install linux-firmware
