Re: How to force "make modules_install" to install elsewhere

Wakko Warner (wakko@animx.eu.org)
Thu, 22 Apr 1999 20:59:42 -0400


--neYutvxvOLaeuPCA
Content-Type: text/plain; charset=us-ascii

This is from 2.2.3's make file:

#
# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
# relocations required by build roots. This is not defined in the
# makefile but the arguement can be passed to make if needed.
#

I'm assuming that a:
make INSTALL_MOD_PATH=/home/customer/spa/kernel modules_install
will install to /home/customer/spa/kernel/lib/modules

I took the modules_install rule out of the kernel and made a shell script to
read the make file for the version (needs awk) and install the mods into a
specified dir (it makes <dir>/<kernel version> if need be)... See attached
file.

Anyone thing I'm wrong on this? Feed back is welcome... Too negative of
feedback is /dev/null'd

> I'm building kernels on a server right now that are for other machines.
> Currently, I'm doing everything up to "make modules", and then I cd into
> /lib/modules, rename the currently running module dir, and then do the
> final "make modules_install" and then move the module dir that just
> installed into another dir prior to tarballing it all up. Then after
> that, I rename the running module dir back to it's proper place.
>
> This is of course a nasty hack, and should a module need to load while I'm
> doing this, I'm going to have problems.
>
> So, my question is this:
>
> How do I tell "make modules_install" to install the modules to an
> alternate arbitrary directory of my choosing. One such as:
>
> /home/customer/spa/kernel/lib/modules
>
> I've examined the top level makefile, and it doesn't appear that it is
> possible to have modules install elsewhere without hacking the file.
>
> Can someone please tell me how to do this, or how to modify the existing
> kernel Makefile to allow a parameter to specify where modules are
> installed? Another option is a script which runs instead which does:
>
> make dep
> make clean
> make zImage
> make modules
>
> then does a custom modules install to a specified location.
>
> Any help with this would be greatly appreciated.
>
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/

--neYutvxvOLaeuPCA
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=kmodinst

#!/bin/sh
DIR=$1;

check_dirs=(Documentation arch drivers fs include init kernel lib mm net scripts)
kernel_dir=1

for my_dir in "$check_dirs";do
[ ! -d $my_dir ] && kernel_dir=0;
done

if [ "$kernel_dir" != "1" ];then
echo "You are not in a kernel source directory, can't install modules"
exit 1
fi

if [ ! -d modules ];then
echo "There are no modules for this kernel, did you compile it?"
echo "If so, did you compile module support?"
exit 1
fi

if [ ! -f "Makefile" ];then
echo "Makefile not found, can't get KERNEL version"
exit 1
fi

# Don't even ask!
KERNELRELEASE="`awk '{x++;if(x>4){exit};v[x]=$3}END{print v[1]"."v[2]"."v[3] v[4]}'<Makefile`"

if [ -z "$KERNELRELEASE" ];then
echo "Makefile appears invalid... Maybe something's wrong?"
exit 1
fi

if [ -n "$DIR" ];then
MODLIB=$DIR/$KERNELRELEASE
else
MODLIB=/lib/modules/$KERNELRELEASE
fi

MODDIR=modules
MODULES=""
inst_mod() {
These=""
for file in `cat $1`; do
These="$These $MODDIR/$file"
# echo $These
done
# These="`cat $1`"
MODULES="$MODULES $These"
mkdir -p $MODLIB/$2
cp $These $MODLIB/$2
echo Installing `echo $1|sed 's,^.*/,,;s/\.//'` modules under $MODLIB/$2
}
mkdir -p $MODLIB

[ -f $MODDIR/BLOCK_MODULES ] && inst_mod $MODDIR/BLOCK_MODULES block
[ -f $MODDIR/NET_MODULES ] && inst_mod $MODDIR/NET_MODULES net
[ -f $MODDIR/IPV4_MODULES ] && inst_mod $MODDIR/IPV4_MODULES ipv4
[ -f $MODDIR/IPV6_MODULES ] && inst_mod $MODDIR/IPV6_MODULES ipv6
[ -f $MODDIR/SCSI_MODULES ] && inst_mod $MODDIR/SCSI_MODULES scsi
[ -f $MODDIR/FS_MODULES ] && inst_mod $MODDIR/FS_MODULES fs
[ -f $MODDIR/NLS_MODULES ] && inst_mod $MODDIR/NLS_MODULES fs
[ -f $MODDIR/CDROM_MODULES ] && inst_mod $MODDIR/CDROM_MODULES cdrom
[ -f $MODDIR/HAM_MODULES ] && inst_mod $MODDIR/HAM_MODULES net
[ -f $MODDIR/SOUND_MODULES ] && inst_mod $MODDIR/SOUND_MODULES sound
[ -f $MODDIR/VIDEO_MODULES ] && inst_mod $MODDIR/VIDEO_MODULES video
[ -f $MODDIR/FC4_MODULES ] && inst_mod $MODDIR/FC4_MODULES fc4
[ -f $MODDIR/IRDA_MODULES ] && inst_mod $MODDIR/IRDA_MODULES net

ls $MODDIR/*.o > $MODLIB/.allmods
echo $MODULES | tr ' ' '\n' | sort | comm -23 $MODLIB/.allmods - | sed 's,^.*/,,' > $MODLIB/.misc
if [ -s $MODLIB/.misc ]; then
inst_mod $MODLIB/.misc misc
fi
rm -f $MODLIB/.misc $MODLIB/.allmods

--neYutvxvOLaeuPCA--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/