wok-current view linux/receipt @ rev 12291

linux: fix adding entry in grub menu.lst
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 15 20:53:12 2012 +0200 (2012-04-15)
parents 34cbbdb49f40
children 04df72fcbe66
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.2.14"
5 KBASEVER="${VERSION:0:3}"
6 CATEGORY="base-system"
7 SHORT_DESC="The Linux kernel and modules."
8 MAINTAINER="devel@slitaz.org"
9 TARBALL="$PACKAGE-$KBASEVER.tar.xz"
10 WEB_SITE="http://www.kernel.org/"
11 WGET_URL="http://www.kernel.org/pub/linux/kernel/v3.0/$TARBALL"
12 CONFIG_FILES="/lib/modules/$KBASEVER-slitaz/modules.dep"
14 DEPENDS="depmod"
15 BUILD_DEPENDS="slitaz-toolchain perl git lzma patch uclibc-cross-compiler-x86_64"
16 [ "$KBASEVER" != "$VERSION" ] && PATCH="http://www.kernel.org/pub/linux/kernel/v3.0/patch-$VERSION.xz"
18 # Rules to configure and make the package.
19 compile_rules()
20 {
21 cd $src
22 # this is code to help update the kernel version faster
23 #for i in $(grep -l 'WANTED="linux"' $WOK/*/receipt)
24 #do
25 # sed -i 's|VERSION="OLDVERSION"|VERSION="NEWVERSION"|g' $i
26 #done
28 [ ! -x /usr/bin/cook ] && report open-bloc
30 # Check for Aufs and cook it if unbuilt.
31 echo "Checking for Aufs packages..."
32 _AUFSVER=`grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g'`
33 if [ -x /usr/bin/cook ]; then
34 # Give info an redirect to /dev/null since aufs got it own log.
35 AUFSDIR=$WOK/aufs/source/aufs-${_AUFSVER}
36 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
37 #echo "Cook: aufs $_AUFSVER"
38 cook aufs --getsrc
39 mkdir -p $WOK/aufs/source/
40 tar xjf $SRC/aufs-${_AUFSVER}.tar.bz2 -C $WOK/aufs/source/
41 elif [ -x /usr/bin/tazwok ]; then
42 # we just need aufs source. Also cooking now is a bad idea since it
43 # needs linux-module-headers. The one your cooking not the one from the web.
44 AUFSDIR=$WOK/aufs/aufs-${_AUFSVER}
45 [ -d "$AUFSDIR" ] && rm -rf $AUFSDIR
46 tazwok get-src aufs --target=$AUFSDIR || { report close-bloc; return 1; }
47 fi
48 echo "cook:linux" > $command
50 echo "Copying Aufs files and patches..."
51 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
52 cp -a $AUFSDIR/aufs3-*.patch $stuff
54 # SliTaz db
55 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz 2> /dev/null
56 mkdir -p $WOK/$PACKAGE/source/slitaz
57 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
58 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
59 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
61 # Apply patches
62 echo "Applying patches..."
63 while read patch_file; do
64 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
65 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
66 if [ -f done.$patch_file ]; then
67 echo "Skipping $patch_file"
68 continue
69 fi
70 echo "Apply $patch_file"
71 if [ -x /usr/bin/cook ]; then
72 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
73 elif [ -x /usr/bin/tazwok ]; then
74 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || { report close-bloc; return 1; }
75 fi
76 touch done.$patch_file
77 done <<EOT
78 $PACKAGE-diff.u
79 $PACKAGE-header.u
80 $PACKAGE-freeinitrd.u
81 aufs3-base.patch
82 aufs3-standalone.patch
83 aufs3-loopback.patch
84 aufs3-proc_map.patch
85 channel-negative-one-maxim.patch
86 mac80211.compat08082009.wl_frag+ack_v1.patch
87 EOT
89 if [ "$KBASEVER" != "$VERSION" ]; then
90 if [ -f $SOURCES_REPOSITORY/$(basename $PATCH) ]; then
91 xzcat $SOURCES_REPOSITORY/$(basename $PATCH) | patch -Np1
92 touch done.patch-$VERSION
93 else
94 wget $PATCH -O $SRC/$(basename $PATCH)
95 xzcat $SRC/$(basename $PATCH) | patch -Np1
96 touch done.patch-$VERSION
97 fi
98 fi
100 sed -i 's|SUBLEVEL =.*|SUBLEVEL =|g' Makefile
102 [ ! -x /usr/bin/cook ] && report step "Make kernel proper and then build lguest"
104 make mrproper
105 cd Documentation/virtual/lguest
106 if [ -x /usr/bin/cook ]; then
107 make lguest || return 1
108 elif [ -x /usr/bin/tazwok ]; then
109 make lguest || { report close-bloc; return 1; }
110 fi
111 cd $src
113 [ ! -x /usr/bin/cook ] && report step "Make bzImage without modules first"
115 # Build bzImage without modules first
116 cp -f $stuff/$PACKAGE-slitaz.config .config
117 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
119 # We can't keep every driver in staging
120 sed -i -e 's/^CONFIG_RTL8192/#&/' \
121 -e 's/^CONFIG_R8187SE/#&/' \
122 -e 's/^CONFIG_RT2870/#&/' .config
123 yes '' | make oldconfig
124 if [ -x /usr/bin/cook ]; then
125 make -j 4 bzImage || exit 1
126 elif [ -x /usr/bin/tazwok ]; then
127 make -j 4 bzImage || { report close-bloc; return 1; }
128 fi
129 [ -d $DESTDIR ] || mkdir -p $DESTDIR
130 mv arch/x86/boot/bzImage $DESTDIR
131 mv System.map System.map-without-modules
133 [ ! -x /usr/bin/cook ] && report step "Now build bzImage with modules"
135 # Build bzImage with modules
136 cp -f $stuff/$PACKAGE-slitaz.config .config
137 #make oldconfig
138 ln .config $WOK/$PACKAGE/source/slitaz/config
139 make -j 4 bzImage &&
140 make -j 4 modules &&
141 make INSTALL_MOD_PATH=$DESTDIR modules_install &&
142 make INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
143 if [ -x /usr/bin/cook ]; then
144 [ -s arch/x86/boot/bzImage ] || return 1
145 elif [ -x /usr/bin/tazwok ]; then
146 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
147 fi
148 mkdir -p $DESTDIR/boot 2> /dev/null
149 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
151 [ ! -x /usr/bin/cook ] && report step "Make bzImage64 without modules first"
153 # Build bzImage64 without modules first
154 cp -f $stuff/$PACKAGE-$VERSION-slitaz.config64 .config
155 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
157 # We can't keep every driver in staging
158 sed -i -e 's/^CONFIG_RTL8192/#&/' \
159 -e 's/^CONFIG_R8187SE/#&/' \
160 -e 's/^CONFIG_RT2870/#&/' .config
161 yes '' | make ARCH=x86_64 oldconfig
162 if [ -x /usr/bin/cook ]; then
163 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
164 elif [ -x /usr/bin/tazwok ]; then
165 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || { report close-bloc; return 1; }
166 fi
167 [ -d $PWD/_pkg ] || mkdir -p $DESTDIR/linux64
168 mv arch/x86/boot/bzImage $DESTDIR/linux64
169 mv System.map System.map-without-modules64
171 [ ! -x /usr/bin/cook ] && report step "Now build bzImage64 with modules"
173 # Build bzImage64 with modules
174 cp -f $stuff/$PACKAGE-$VERSION-slitaz.config64 .config
175 #make ARCH=x86_64 oldconfig
176 ln .config $WOK/$PACKAGE/slitaz/config64
177 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
178 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
179 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
180 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
181 if [ -x /usr/bin/cook ]; then
182 [ -s arch/x86/boot/bzImage ] || return 1
183 elif [ -x /usr/bin/tazwok ]; then
184 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
185 fi
186 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
187 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz
188 ln System.map System.map-modules64
189 ln Module.symvers Module.symvers-modules64
191 [ ! -x /usr/bin/cook ] && report step "Compressing all modules"
193 # Compress all modules.
194 $stuff/gztazmod.sh $DESTDIR/lib/modules/$KBASEVER-slitaz
195 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$KBASEVER-slitaz
196 ln System.map System.map-modules
197 ln Module.symvers Module.symvers-modules
199 if [ ! -x /usr/bin/cook ]; then
200 report close-bloc
201 fi
202 }
204 # Rules to gen a SliTaz package suitable for Tazpkg.
205 genpkg_rules()
206 {
207 local path
208 cp -a $_pkg/boot $fs
209 # Compress all modules.
210 #$stuff/gztazmod.sh $_pkg/lib/modules/$KBASEVER-slitaz
211 path=$fs/lib/modules/$KBASEVER-slitaz/kernel
212 mkdir -p $path
213 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/mo* \
214 $fs/lib/modules/$KBASEVER-slitaz
215 # Get the base modules
216 export src
217 export _pkg
218 mkdir -p $WOK/$PACKAGE/source/tmp
219 $stuff/list_modules.sh \
220 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
221 while read module; do
222 dir=$(dirname $module)
223 [ -d $path/$dir ] || mkdir -p $path/$dir
224 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/kernel/$module $path/$dir
225 done < $WOK/$PACKAGE/source/tmp/modules.list
226 # Remove unresolved links
227 rm -f $fs/lib/modules/$KBASEVER-slitaz/build
228 rm -f $fs/lib/modules/$KBASEVER-slitaz/source
229 # Cook all packages with a kernel module
230 for i in $(cd $WOK; grep -l 'tazwok cook linux$' */receipt)
231 do
232 echo tazwok cook ${i%/receipt}
233 done
234 # Fixed modules.dep to use right path
235 # saves 100kb of space too
236 sed -i "s|$_pkg||g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
237 sed -i "s|99.98.$KBASEVER-slitaz|$KBASEVER-slitaz|g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
238 # Check and echo any module in kernel .config that's not added to
239 # one of linux-* pkgs
240 $stuff/check_modules.sh
241 }
243 # Pre and post install commands for Tazpkg.
244 post_install()
245 {
246 echo "Processing post-install commands..."
247 chroot "$1/" depmod -a $KBASEVER-slitaz
248 # GRUB stuff.
249 if [ -f "$1/boot/grub/menu.lst" ]; then
250 root_dev=`cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1`
251 grub_dev=`cat $1/boot/grub/menu.lst | grep "root (" | head -n 1`
252 # Add new kernel entry in case of upgrade for installed system.
253 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
254 cat >> $1/boot/grub/menu.lst << EOT
256 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
257 $grub_dev
258 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
259 EOT
260 fi
261 # Display information message.
262 cat <<EOT
263 ----
264 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
266 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
267 $grub_dev
268 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
269 ----
270 EOT
271 fi
272 }