fix error to not only use a running kernel
[grml-terminalserver.git] / modcalc
1 #!/bin/sh
2 # "modtest"
3 #
4
5 # written by Michael Gebetsroither (michael.geb@gmx.at)
6 #
7 # 11.04.2005    - initial release (Michael Gebetsroither)
8 #
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License
12 # as published by the Free Software Foundation; either version 2
13 # of the License, or (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, look at
22 # http://www.gnu.org/licenses/gpl.txt, or write to the Free Software
23 # Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 # MA  02111-1307, USA.
25
26 TMP=`mktemp`
27
28 MODULES_=$(awk '/ethernet/{print $3}' /lib/discover/pci.lst |sort |uniq |xargs)
29 MODULES_DEP_="$1"
30
31 if [[ "$1" == "" ]]; then
32   echo "you have to give me the path to your modules.dep" >&2
33   exit 1
34 fi
35
36 #for i in $MODULES_; do
37 #  awk -F: '{if($1~/'"$i"'/) {print $1}}' /lib/modules/$KERNEL_VERSION_/modules.dep
38 #done > $TMP
39
40 for i in $MODULES_; do
41   #awk -F: '{if($1~/'"$i"'/) {print $2}}' /lib/modules/$KERNEL_VERSION_/modules.dep
42   tmp_=`awk -F: '{if($1~/'"$i".ko'/) {print $0}}' $MODULES_DEP_`
43   echo "1-${tmp_%%:*}"
44   echo "${tmp_#*:}" |xargs -n1 echo |sed 's/://'
45 done \
46 | sort | uniq | while read module relax; do
47   if [ -n "$module" ]; then
48     #echo "cp $module" "INITRD/modules/net/00_${module##*/}"
49     echo -n "$module" >> $TMP
50     echo -n "$relax" >> $TMP
51     echo >> $TMP
52   fi
53 done
54
55 #for i in $MODULES_; do
56 #  tmp_=`awk -F: '{if($1~/'"$i".ko'/) {print $0}}' /lib/modules/$KERNEL_VERSION_/modules.dep`
57 #  echo first-match-$i--${tmp_%%:*}
58 #  echo ${tmp_#*:} |xargs -n1 echo
59 #  tmp_=''
60 #done \
61 #|while read module relax; do
62 #  echo "module=\"$module\"  relax=\"$relax\""
63 #done
64
65 cat $TMP |sort |uniq
66 rm $TMP