Gentoo Archives: gentoo-dev

From: Peter Ruskin <Peter.Ruskin@×××××××××.com>
To: gentoo-dev@g.o
Subject: Re: [gentoo-dev] kernelmod-rebuild-0.1
Date: Thu, 04 Dec 2003 13:30:38
Message-Id: 200312041930.31980.Peter.Ruskin@dsl.pipex.com
In Reply to: Re: [gentoo-dev] kernelmod-rebuild-0.1 by Paul Varner
1 On Thursday 04 Dec 2003 17:15, Paul Varner wrote:
2 > I am aware of that and the first comment in the script says that it
3 > evolved from the simple script 'emerge -v `qpkg -I -nc -f
4 > /lib/modules`'
5
6 Here's my kernel build script that includes this:
7
8 ##################################################
9 #!/bin/sh
10 # /usr/local/bin/build-kernel
11
12 # start this script from the kernel source directory,
13 # for example /usr/src/linux-2.4.20-xfs-r2
14 # ...test for that...
15 grep -q "Linux kernel" ./README
16 if [ "$(echo $?)" != "0" ] ; then
17 echo "ERROR: You don't appear to be in a kernel source directory"
18 echo
19 exit 1
20 fi
21
22 # remove symlink
23 if [ "$( file ../linux | grep 'symbolic link' )" != "" ]; then
24 rm -f ../linux
25 fi
26
27 # This kernel variable produces something like "-2.4.20-xfs-r2"
28 kernel=$(pwd | cut -dx -f2-9)
29
30 # make symlink
31 cd ..
32 ln -sf linux${kernel} linux
33 ln -sf . ../linux
34
35 cd linux${kernel}
36
37 # comment these 3 lines if you don't need mrproper
38 #cp .config ..
39 #make mrproper
40 #cp ../.config .
41
42 # check timestamp of .config
43 CONFTIME=$(ls -l .config | awk '{print $6,$7,$8}')
44
45 # use old if you told it to, or preferably xconfig if it can, else
46 # menuconfig.
47 if [ "$1" == "old" ]; then
48 make oldconfig
49 else
50 make xconfig
51 [ $(echo $?) -eq 0 ] || make menuconfig
52 fi
53
54 if [ "$(ls -l .config | awk '{print $6,$7}')" == "$CONFTIME" ] ; then
55 echo
56 echo " .config file unchanged...aborting"
57 exit 0
58 fi
59
60 # NOTE** make dep not required for 2.6 kernels
61 PATCHLEVEL=$(grep 'PATCHLEVEL =' /usr/src/linux/Makefile | \
62 cut -d= -f2 | cut -d' ' -f2)
63 if [ ${PATCHLEVEL} -gt 5 ]; then
64 make clean
65 if [ $(echo $?) -ne 0 ] ; then
66 echo
67 echo " make clean failed"
68 exit 1
69 fi
70 else
71 make dep clean
72 if [ $(echo $?) -ne 0 ] ; then
73 echo
74 echo " make dep clean failed"
75 exit 1
76 fi
77 fi
78
79 make bzImage
80 if [ $(echo $?) -ne 0 ] ; then
81 echo
82 echo " make bzImage failed"
83 exit 1
84 fi
85
86 make modules
87 if [ $(echo $?) -ne 0 ] ; then
88 echo
89 echo " make modules failed"
90 exit 1
91 fi
92
93 make modules_install
94 if [ $(echo $?) -ne 0 ] ; then
95 echo
96 echo " make modules_install failed"
97 exit 1
98 fi
99
100 [ "$(grep boot /etc/mtab)" == "" ] && mount /boot
101 cp arch/i386/boot/bzImage /boot/vmlinuz$kernel
102 cp System.map /boot/System.map$kernel
103 cp .config /boot/.config$kernel
104 sync
105
106 # if just rebuilding booted kernel...
107 if [[ "-$(uname -r)" == "$kernel" ]] ; then
108 if [ ${PATCHLEVEL} -gt 5 ]; then
109 env AUTOCLEAN="no" ACCEPT_KEYWORDS="~x86" \
110 emerge -v $(qpkg -I -nc -f /lib/modules | \
111 grep -v i2c | grep -v lm-sensors)
112 else
113 env AUTOCLEAN="no" ACCEPT_KEYWORDS="~x86" \
114 emerge -v $(qpkg -I -nc -f /lib/modules)
115 fi
116 else
117 echo
118 # build-kernel-2 contains the first if clause above
119 echo "Run build-kernel-2 after next reboot to"
120 echo "update lm_sensors, nvidia-kernel, etc."
121 fi
122
123 echo
124 echo " All done. Now edit /boot/grub/grub.conf and reboot"
125 ##################################################
126
127 Peter
128 --
129 ======================================================================
130 Gentoo Linux: Portage 2.0.49-r18 (default-x86-1.4, gcc-3.2.3,
131 glibc-2.3.2-r3, 2.6.0-test11-gentoo-r1-win4lin) i686 AMD Athlon(tm) XP
132 3200+
133 ======================================================================
134
135
136 --
137 gentoo-dev@g.o mailing list