New versions available for testing here:
http://www.murga-linux.com/puppy/viewtopic.php?t=51552
TODO
Generate firmware module dependencies dynamically from either /etc/modules/firmware.dep or /etc/modules/firmware.dep.$(uname -r)
Build a list of modules that may not be loaded and still wanted (+gui)
Make it easier to integrate into remaster script.
Remove unneeded modules and firmware
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
Remove unneeded modules and firmware
Last edited by technosaurus on Thu 21 Jan 2010, 03:09, edited 4 times in total.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
Progress update:
lsmod > tmp #puts raw ouput in file mods
sed -i "1,1 d" tmp #removes the header line
sed -i "s/ /\*\) /g" tmp #can be .ko or .ko.gz & maybe others
cut -d " " -f 1 tmp > mods #removes all but the first column
sed -i "s/_/?/g" mods #replaces the _ with ? so that - and . will not give false evaluation
echo *) rm $FILE;; >>mods
while {recurse directories in /lib/modules/ --***NEED to CODE still***---}
case $FILE in
. $PATHTO/mods
esac
cp -a /lib/modules $DESTDIR/lib/modules
dir2sfs $DESTDIR
Now you have a case condition for each module that does nothing - can add stuff to steps 3 & 4 if we later find we need to do something on the fly (perhaps cp $FILE $DEST/lib/modules....), but for now will just use the final *) to delete the modules that do not match
lsmod > tmp #puts raw ouput in file mods
sed -i "1,1 d" tmp #removes the header line
sed -i "s/ /\*\) /g" tmp #can be .ko or .ko.gz & maybe others
cut -d " " -f 1 tmp > mods #removes all but the first column
sed -i "s/_/?/g" mods #replaces the _ with ? so that - and . will not give false evaluation
echo *) rm $FILE;; >>mods
while {recurse directories in /lib/modules/ --***NEED to CODE still***---}
case $FILE in
. $PATHTO/mods
esac
cp -a /lib/modules $DESTDIR/lib/modules
dir2sfs $DESTDIR
Now you have a case condition for each module that does nothing - can add stuff to steps 3 & 4 if we later find we need to do something on the fly (perhaps cp $FILE $DEST/lib/modules....), but for now will just use the final *) to delete the modules that do not match
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
Code: Select all
#!/bin/bash
CWD=$(pwd)
# set this to the name of a temp dir:
TMP=/tmp/mymodules
# create the module directory in the TMP dir:
mkdir -p $TMP
# get the version of your kernel
KVERS=$(uname -r)
lsmod |tail +2 |cut -f1 -d' ' > $CWD/mods
cd /
for module in $(cat $CWD/mods) ; do
# uncomment the first and comment the second one to just see the list
# find lib/modules/$KVERS -type f -name "$module*\.o"
find lib/modules/$KVERS -type f -name "$module*\.o" -exec cp --parents {} $TMP/ \;
done
depmod -b $TMP/lib/modules/$KVERS -e -F /path/to/kernel/System.map
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
Yeah! it builds now - thanks for the assist amigo - now time to remaster and reboot
Code: Select all
#!/bin/sh
. /etc/DISTRO_SPECS #gets $DISTRO* variables
KERNELVER=$(uname -r) # get the version of your kernel
PREFIX1CHAR="`echo -n "$DISTRO_FILE_PREFIX" | cut -c 1`"
KERNEL3CHARS="`echo -n "$KERNELVER" | tr -d '.' | tr -d '\-' | tr -d '[a-z]' | rev | cut -c 1,2,3 | rev`"
ZDIR="z${PREFIX1CHAR}${DISTRO_VERSION}${KERNEL3CHARS}"
# set this to the name of a temp dir:
TMPDIR=/mnt/shm/$ZDIR
# create the module directory in the TMP dir:
mkdir -p $TMPDIR
lsmod |tail +2 |cut -f1 -d' ' > $TMPDIR/mods #just a list of modules
sed -i "s/_/?/g" $TMPDIR/mods #replaces the _ with ? so that - and . will not give false evaluation
cd /
for module in $(cat $TMPDIR/mods) ; do
# uncomment the first and comment the second one to just see the list
# find lib/modules/$KVERS -type f -name "$module*\.o"
find lib/modules/$KVERS -type f -name "$module*" -exec cp --parents {} $TMPDIR/ \;
done
mv /lib/modules /lib/modules~ # can't force a link over a directory
ln -s -f $TMPDIR/lib/modules /lib #use link so busybox depmod works
depmod #-b $TMPDIR/lib/modules/$KERNELVER -e -F /path/to/kernel/System.map
rm $TMPDIR/mods #cleanup
dir2sfs $TMPDIR
mv $TMPDIR"_"$DISTRO_VERSION.sfs ~/$ZDIR.sfs #move to $HOME
mv $TMPDIR"_"$DISTRO_VERSION.sfs-md5.txt ~/$ZDIR.sfs-md5.txt #move to $HOME
rm -rf $TMPDIR
rm -rf /lib/modules
mv /lib/modules~ /lib/modules
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
cool, the firmware deps are in /etc/modules/firmware.dep and /etc/modules/firmware$(uname -r).dep - that should help with code to reduce some of the firmware dependencies
I hard-coded it for now for testing, but it seems that it would be possible to build the "case ... esac" for the firmware directly from firmware.dep using sed and cut
NOTES for adding dynamic creation:
sed to
replace ".ko," with |
replace ".ko" with )
cut
using : to separate firmware from modules and -s to remove comments
cut -d ":" -f 1 for firmware
cut -d ":" -f 2 for modules
then go line by line using echo to build the commands
echo $moduledeps" echo "$firmware" >>$TMPDIR/fw;;"
I hard-coded it for now for testing, but it seems that it would be possible to build the "case ... esac" for the firmware directly from firmware.dep using sed and cut
NOTES for adding dynamic creation:
sed to
replace ".ko," with |
replace ".ko" with )
cut
using : to separate firmware from modules and -s to remove comments
cut -d ":" -f 1 for firmware
cut -d ":" -f 2 for modules
then go line by line using echo to build the commands
echo $moduledeps" echo "$firmware" >>$TMPDIR/fw;;"
- Attachments
-
- zdrv_cutter-0.2.pet
- (2.02 KiB) Downloaded 587 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].