The time now is Sat 25 May 2013, 01:45
All times are UTC - 4 |
| Author |
Message |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Sun 17 Jan 2010, 23:33 Post subject:
Remove unneeded modules and firmware Subject description: only what you need for your system |
|
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.
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
Last edited by technosaurus on Wed 20 Jan 2010, 23:09; edited 4 times in total
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Mon 18 Jan 2010, 20:23 Post subject:
|
|
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
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
amigo
Joined: 02 Apr 2007 Posts: 1759
|
Posted: Tue 19 Jan 2010, 16:07 Post subject:
|
|
| Code: | #!/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
|
You'll need to run depmod on the created directory so that the module symbol tables are created.
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Tue 19 Jan 2010, 21:53 Post subject:
|
|
Yeah! it builds now - thanks for the assist amigo - now time to remaster and reboot
| Code: | #!/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 |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
technosaurus

Joined: 18 May 2008 Posts: 3843
|
Posted: Wed 20 Jan 2010, 21:11 Post subject:
|
|
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;;"
| Description |
|

Download |
| Filename |
zdrv_cutter-0.2.pet |
| Filesize |
2.02 KB |
| Downloaded |
217 Time(s) |
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
|
|
Back to top
|
|
 |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|
[ Time: 0.0470s ][ Queries: 13 (0.0046s) ][ GZIP on ] |