wok-6.x view linux/receipt @ rev 12558
linux: compress modules with xz (be kmod compatible)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Apr 28 14:44:50 2012 +0200 (2012-04-28) |
parents | bff65eb88e5a |
children | c4884f4da7e8 |
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 xz 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"
103 [ -x /usr/bin/cook ] && echo "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 #
114 # Arch x86_64
115 #
116 [ ! -x /usr/bin/cook ] && report step "Make bzImage64 without modules first"
117 [ -x /usr/bin/cook ] && echo "Building x86_64 Kernel"
119 # Build bzImage64 without modules first
120 cp -f $stuff/$PACKAGE-slitaz.config64 .config
121 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
123 # We can't keep every driver in staging
124 sed -i -e 's/^CONFIG_RTL8192/#&/' \
125 -e 's/^CONFIG_R8187SE/#&/' \
126 -e 's/^CONFIG_RT2870/#&/' .config
127 yes '' | make ARCH=x86_64 oldconfig
128 if [ -x /usr/bin/cook ]; then
129 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
130 elif [ -x /usr/bin/tazwok ]; then
131 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || { report close-bloc; return 1; }
132 fi
133 [ -d $PWD/_pkg ] || mkdir -p $DESTDIR/linux64
134 mv arch/x86/boot/bzImage $DESTDIR/linux64
135 mv System.map System.map-without-modules64
137 [ ! -x /usr/bin/cook ] && report step "Now build bzImage64 with modules"
139 # Build bzImage64 with modules
140 cp -f $stuff/$PACKAGE-slitaz.config64 .config
141 #make ARCH=x86_64 oldconfig
142 ln .config $WOK/$PACKAGE/slitaz/config64
143 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
144 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
145 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
146 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
147 if [ -x /usr/bin/cook ]; then
148 [ -s arch/x86/boot/bzImage ] || return 1
149 elif [ -x /usr/bin/tazwok ]; then
150 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
151 fi
152 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
153 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz
154 ln System.map System.map-modules64
155 ln Module.symvers Module.symvers-modules64
157 #
158 # Standard kernel
159 #
160 [ ! -x /usr/bin/cook ] && report step "Make bzImage without modules first"
161 [ -x /usr/bin/cook ] && echo "Building standard kernel..."
163 # Build bzImage without modules first
164 cp -f $stuff/$PACKAGE-slitaz.config .config
165 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
167 # We can't keep every driver in staging
168 sed -i -e 's/^CONFIG_RTL8192/#&/' \
169 -e 's/^CONFIG_R8187SE/#&/' \
170 -e 's/^CONFIG_RT2870/#&/' .config
171 yes '' | make oldconfig
172 if [ -x /usr/bin/cook ]; then
173 make -j 4 bzImage || exit 1
174 elif [ -x /usr/bin/tazwok ]; then
175 make -j 4 bzImage || { report close-bloc; return 1; }
176 fi
177 [ -d $DESTDIR ] || mkdir -p $DESTDIR
178 mv arch/x86/boot/bzImage $DESTDIR
179 mv System.map System.map-without-modules
181 [ ! -x /usr/bin/cook ] && report step "Now build bzImage with modules"
183 # Build bzImage with modules
184 cp -f $stuff/$PACKAGE-slitaz.config .config
185 #make oldconfig
186 ln .config $WOK/$PACKAGE/source/slitaz/config
187 make -j 4 bzImage &&
188 make -j 4 modules &&
189 make INSTALL_MOD_PATH=$DESTDIR modules_install &&
190 make INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
191 if [ -x /usr/bin/cook ]; then
192 [ -s arch/x86/boot/bzImage ] || return 1
193 elif [ -x /usr/bin/tazwok ]; then
194 [ -s arch/x86/boot/bzImage ] || { report close-bloc; return 1; }
195 fi
196 mkdir -p $DESTDIR/boot 2> /dev/null
197 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
199 [ ! -x /usr/bin/cook ] && report step "Compressing all modules"
201 # Compress all modules.
202 $stuff/gztazmod.sh $DESTDIR/lib/modules/$KBASEVER-slitaz
203 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$KBASEVER-slitaz
204 ln System.map System.map-modules
205 ln Module.symvers Module.symvers-modules
207 if [ ! -x /usr/bin/cook ]; then
208 report close-bloc
209 fi
210 }
212 # Rules to gen a SliTaz package suitable for Tazpkg.
213 genpkg_rules()
214 {
215 export PACKAGE VERSION
216 local path
217 cp -a $_pkg/boot $fs
218 # Compress all modules.
219 $stuff/gztazmod.sh $_pkg/lib/modules/$KBASEVER-slitaz
220 path=$fs/lib/modules/$KBASEVER-slitaz/kernel
221 mkdir -p $path
222 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/mo* \
223 $fs/lib/modules/$KBASEVER-slitaz
224 # Get the base modules
225 export src
226 export _pkg
227 mkdir -p $WOK/$PACKAGE/source/tmp
228 $stuff/list_modules.sh \
229 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
230 while read module; do
231 dir=$(dirname $module)
232 [ -d $path/$dir ] || mkdir -p $path/$dir
233 cp -a $_pkg/lib/modules/$KBASEVER-slitaz/kernel/$module $path/$dir
234 done < $WOK/$PACKAGE/source/tmp/modules.list
235 # Remove unresolved links
236 rm -f $fs/lib/modules/$KBASEVER-slitaz/build
237 rm -f $fs/lib/modules/$KBASEVER-slitaz/source
238 # Cook all packages with a kernel module
239 for i in $(cd $WOK; grep -l 'tazwok cook linux$' */receipt)
240 do
241 echo tazwok cook ${i%/receipt}
242 done
243 # Fixed modules.dep to use right path
244 # saves 100kb of space too
245 sed -i "s|$_pkg||g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
246 sed -i "s|99.98.$KBASEVER-slitaz|$KBASEVER-slitaz|g" $fs/lib/modules/$KBASEVER-slitaz/modules.dep
247 # Check and echo any module in kernel .config that's not added to
248 # one of linux-* pkgs
249 $stuff/check_modules.sh
250 }
252 # Pre and post install commands for Tazpkg.
253 post_install()
254 {
255 echo "Processing post-install commands..."
256 chroot "$1/" depmod -a $KBASEVER-slitaz
257 # GRUB stuff.
258 if [ -f "$1/boot/grub/menu.lst" ]; then
259 root_dev=`cat $1/boot/grub/menu.lst | grep root= | sed 's/.*root=\([^ ]*\).*/\1/' | head -n 1`
260 grub_dev=`cat $1/boot/grub/menu.lst | grep "root (" | head -n 1`
261 # Add new kernel entry in case of upgrade for installed system.
262 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
263 cat >> $1/boot/grub/menu.lst << EOT
265 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
266 $grub_dev
267 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
268 EOT
269 fi
270 # Display information message.
271 cat <<EOT
272 ----
273 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
275 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
276 $grub_dev
277 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
278 ----
279 EOT
280 fi
281 }