wok view linux/receipt @ rev 20169

Add linux-dev
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Jan 16 11:15:42 2018 +0100 (2018-01-16)
parents ffc20f9bd49f
children e564e12169b9
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.2.98"
5 CATEGORY="base-system"
6 SHORT_DESC="The Linux kernel and modules."
7 MAINTAINER="devel@slitaz.org"
8 LICENSE="GPL2"
9 TARBALL="$PACKAGE-$VERSION.tar.xz"
10 WEB_SITE="http://www.kernel.org/"
11 WGET_URL="http://www.kernel.org/pub/linux/kernel/v3.0/$TARBALL"
12 HOST_ARCH="i486 arm x86_64"
14 DEPENDS="kmod"
15 BUILD_DEPENDS="slitaz-toolchain perl git xz lzma patch kmod \
16 uclibc-cross-compiler-x86_64"
18 #
19 # The Linux receipt handle cross compilation. For x86_64 we actually use
20 # the uclibc-cross-compiler-x86_64 and for ARM we use a real cross env.
21 # Please discuss any change and keep it simple, dont play with VERSION
22 # string or Kernel SUBLEVEL because depmod and Pankso dont like that!
23 #
24 # The receipt also handle some cook options for faster build:
25 # --nox64 : Skip the x86_64 cross compilation
26 # --nonomods : Skip bzImage without modules build
27 #
29 # Aufs enable chroot
30 AUFS_NOT_RAMFS="uclibc-cross-compiler-x86_64 is not compatible with aufs+tmpfs 8("
32 # Handle multiarch compilation. Less bdeps when cross-compiling for ARM
33 case "$ARCH" in
34 arm) BUILD_DEPENDS="xz" ;;
35 x86_64) BUILD_DEPENDS="xz" ;;
36 esac
38 # Handle multiarch installation. ARM use Busybox modutils, so avoid any
39 # deps on kmod. SLITAZ_ARCH can have also custom post_install commands
40 if [ -f $root/etc/slitaz/slitaz.conf ]; then
41 . $root/etc/slitaz/slitaz.conf
42 case "$SLITAZ_ARCH" in
43 arm) DEPENDS="" ;;
44 esac
45 fi
47 install_module_headers()
48 {
49 local path
50 path=usr/src/linux-$KVERSION
51 mkdir -p $1/lib/modules/$KVERSION
52 ln -sf /$path $1/lib/modules/$KVERSION/build
53 install -D -m644 $src/Makefile \
54 $1/$path/Makefile
55 install -D -m644 $src/kernel/Makefile \
56 $1/$path/kernel/Makefile
57 install -D -m644 $src/.config \
58 $1/$path/.config
59 mkdir -p $1/$path/include
61 for i in acpi asm-generic config crypto drm generated linux math-emu \
62 media net pcmcia scsi sound trace video xen; do
63 cp -a $src/include/$i $1/$path/include/
64 done
66 # copy arch includes for external modules
67 mkdir -p $1/$path/arch/x86
68 cp -a $src/arch/x86/include $1/$path/arch/x86/
70 # copy files necessary for later builds, like nvidia and vmware
71 cp -a $src/Module.symvers $1/$path/Module.symvers
72 cp -a $src/scripts $1/$path
73 # fix permissions on scripts dir
74 chmod og-w -R $1/$path/scripts
75 mkdir -p $1/$path/.tmp_versions
77 mkdir -p $1/$path/arch/x86/kernel
78 cp -a $src/arch/x86/Makefile $1/$path/arch/x86/
79 cp -a $src/arch/x86/Makefile_32.cpu $1/$path/arch/x86/
80 cp -a $src/arch/x86/kernel/asm-offsets.s $1/$path/arch/x86/kernel/
82 # add headers for lirc package
83 mkdir -p $1/$path/drivers/media/video
84 cp -a $src/drivers/media/video/*.h $1/$path/drivers/media/video/
86 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 ; do
87 mkdir -p $1/$path/drivers/media/video/$i
88 cp -a $src/drivers/media/video/$i/*.h $1/$path/drivers/media/video/$i
89 done
91 # add docbook makefile
92 install -D -m644 $src/Documentation/DocBook/Makefile \
93 $1/$path/Documentation/DocBook/Makefile
95 # add dm headers
96 mkdir -p $1/$path/drivers/md
97 cp -a $src/drivers/md/*.h $1/$path/drivers/md
99 # add inotify.h
100 mkdir -p $1/$path/include/linux
101 cp -a $src/include/linux/inotify.h $1/$path/include/linux/
103 # add wireless headers
104 mkdir -p $1/$path/net/mac80211/
105 cp -a $src/net/mac80211/*.h $1/$path/net/mac80211/
107 # add dvb headers for external modules
108 # in reference to:
109 # http://bugs.archlinux.org/task/9912
110 mkdir -p $1/$path/drivers/media/dvb/dvb-core
111 cp -a $src/drivers/media/dvb/dvb-core/*.h $1/$path/drivers/media/dvb/dvb-core/
113 # add dvb headers for external modules
114 # in reference to:
115 # http://bugs.archlinux.org/task/11194
116 if [ -d $src/include/config/dvb/ ]; then
117 mkdir -p $1/$path/include/config/dvb/
118 cp $src/include/config/dvb/*.h $1/$path/include/config/dvb/
119 fi
121 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
122 # in reference to:
123 # http://bugs.archlinux.org/task/13146
124 mkdir -p $1/$path/drivers/media/dvb/frontends/
125 cp -a $src/drivers/media/dvb/frontends/lgdt330x.h $1/$path/drivers/media/dvb/frontends/
126 cp -a $src/drivers/media/video/msp3400-driver.h $1/$path/drivers/media/dvb/frontends/
128 # add dvb headers
129 # in reference to:
130 # http://bugs.archlinux.org/task/20402
131 mkdir -p $1/$path/drivers/media/dvb/dvb-usb
132 cp -a $src/drivers/media/dvb/dvb-usb/*.h $1/$path/drivers/media/dvb/dvb-usb/
133 mkdir -p $1/$path/drivers/media/dvb/frontends
134 cp -a $src/drivers/media/dvb/frontends/*.h $1/$path/drivers/media/dvb/frontends/
135 mkdir -p $1/$path/drivers/media/common/tuners
136 cp -a $src/drivers/media/common/tuners/*.h $1/$path/drivers/media/common/tuners/
138 # add xfs and shmem for aufs building
139 mkdir -p $1/$path/fs/xfs
140 mkdir -p $1/$path/mm
141 cp -a $src/fs/xfs/xfs_sb.h $1/$path/fs/xfs/xfs_sb.h
143 # copy in Kconfig files
144 for i in $(find . -name "Kconfig*"); do
145 mkdir -p $1/$path/$(echo $i | sed 's|/Kconfig.*||')
146 cp -a $src/$i $1/$path/$i
147 done
149 chown -R root.root $1/$path
150 find $1/$path -type d -exec chmod 755 {} \;
151 # remove unneeded architectures
152 rm -rf $1/$path/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}
153 }
155 # Rules to configure and make the package.
156 compile_rules()
157 {
158 if [ -f "/usr/share/boot/initrd" ]; then
159 cp /usr/share/boot/initrd initrd.cpio
160 fi
162 # Handle cross compilation
163 case "$ARCH" in
164 arm)
165 echo "Compiling: $ARCH Kernel"
166 make mrproper
167 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
168 cp -f $stuff/$ARCH/linux-arm.config .config
169 yes '' | make ARCH=$ARCH oldconfig
170 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
171 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
172 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
173 INSTALL_MOD_PATH=$DESTDIR modules_install &&
174 mkdir -p $DESTDIR/boot &&
175 cp -a arch/arm/boot/zImage \
176 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
177 #$stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
178 return 0 ;;
179 x86_64)
180 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
181 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
182 return 0 ;;
183 esac
185 # Check for Aufs and get source/patches if needed
186 echo "Checking for Aufs packages..."
187 AUFSVER=$(grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g')
188 AUFSDIR="$WOK/aufs/source/aufs-${AUFSVER}"
189 if [ ! -d "$AUFSDIR" ]; then
190 [ ! -f "$SRC/aufs-${AUFSVER}.tar.bz2" ] && cook aufs --getsrc
191 mkdir -p $WOK/aufs/source/
192 echo "Extracting: aufs-${AUFSVER}.tar.bz2"
193 tar xjf $SRC/aufs-${AUFSVER}.tar.bz2 -C $WOK/aufs/source/
194 fi
196 echo "cook:linux" > $command
198 echo "Copying Aufs files and patches..."
199 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
200 cp -a $AUFSDIR/aufs3-*.patch $stuff
202 # SliTaz db stuff
203 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz
204 mkdir -p $WOK/$PACKAGE/source/slitaz
205 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
206 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
207 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
209 # Apply patches
210 echo "Applying patches..."
211 while read patch_file; do
212 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
213 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
214 if [ -f done.$patch_file ]; then
215 echo "Skipping $patch_file" && continue
216 fi
217 echo "Apply $patch_file"
218 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
219 touch done.$patch_file
220 done <<EOT
221 $PACKAGE-diff.u
222 $PACKAGE-header.u
223 $PACKAGE-freeinitrd.u
224 $PACKAGE-subroot.u
225 $PACKAGE-romfs.u
226 aufs3-base.patch
227 aufs3-standalone.patch
228 aufs3-loopback.patch
229 aufs3-mmap.patch
230 channel-negative-one-maxim.patch
231 mac80211.compat08082009.wl_frag+ack_v1.patch
232 EOT
234 # Mrproper and lguest
235 echo "Make kernel proper and then build lguest..."
236 make mrproper
237 cd Documentation/virtual/lguest
238 make lguest || return 1
239 cd $src
241 #
242 # Arch x86_64: TODO have a real cross environment
243 #
244 if [ ! "$nox64" ]; then
245 echo "Compiling: x86_64 Kernel"
247 # Build bzImage64 without modules first
248 if [ ! "$nonomods" ]; then
249 cp -f $stuff/$PACKAGE-slitaz.config64 .config
250 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
251 # We can't keep every driver in staging ???
252 sed -i -e 's/^CONFIG_RTL8192/#&/' \
253 -e 's/^CONFIG_R8187SE/#&/' \
254 -e 's/^CONFIG_RT2870/#&/' .config
255 echo -e "\n* Configure bzImage64 without modules...\n"
256 yes '' | make ARCH=x86_64 oldconfig
257 echo -e "\n* Building bzImage64 without modules...\n"
258 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
259 [ -d $DESTDIR ] || mkdir -p $DESTDIR/linux64
260 mv arch/x86/boot/bzImage $DESTDIR/linux64
261 mv System.map System.map-without-modules64
262 mv vmlinux vmlinux-without-modules64
263 mv .config config-without-modules64
264 fi
266 # Build bzImage64 with modules
267 cp -f $stuff/$PACKAGE-slitaz.config64 .config
268 echo -e "\n* Configure bzImage64 with modules...\n"
269 yes '' | make ARCH=x86_64 oldconfig
270 echo -e "\n* Building bzImage64 with modules...\n"
271 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
272 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
273 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
274 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
275 ln .config $WOK/$PACKAGE/source/slitaz/config64
276 [ -s arch/x86/boot/bzImage ] || return 1
277 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
278 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz64
279 KVERSION=$VERSION-slitaz64
280 install_module_headers $DESTDIR/linux64
281 ln System.map System.map-modules64
282 ln vmlinux vmlinux-modules64
283 ln Module.symvers Module.symvers-modules64
284 else
285 echo "* Skipping: x86_64 Kernel..."
286 fi
288 #
289 # Linux Arch i386 - GCC arch i486
290 #
291 echo "Compiling: i386 Kernel..."
293 # Build bzImage without modules first
294 if [ ! "$nonomods" ]; then
295 cp -f $stuff/$PACKAGE-slitaz.config .config
296 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
297 # We can't keep every driver in staging ???
298 sed -i -e 's/^CONFIG_RTL8192/#&/' \
299 -e 's/^CONFIG_R8187SE/#&/' \
300 -e 's/^CONFIG_RT2870/#&/' .config
301 echo -e "\n* Configure bzImage without modules...\n"
302 yes '' | make ARCH=i386 oldconfig
303 echo -e "\n* Building bzImage without modules...\n"
304 make ARCH=i386 -j 4 bzImage || exit 1
305 [ -d $DESTDIR ] || mkdir -p $DESTDIR
306 mv arch/x86/boot/bzImage $DESTDIR
307 mv System.map System.map-without-modules
308 mv vmlinux vmlinux-without-modules
309 mv .config config-without-modules
310 fi
312 # Build bzImage with modules
313 cp -f $stuff/$PACKAGE-slitaz.config .config
314 echo -e "\n* Configure bzImage with modules...\n"
315 yes '' | make ARCH=i386 oldconfig
316 ln .config $WOK/$PACKAGE/source/slitaz/config
317 echo -e "\n* Building bzImage with modules...\n"
318 make ARCH=i386 -j 4 bzImage &&
319 make ARCH=i386 -j 4 modules &&
320 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
321 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
322 [ -s arch/x86/boot/bzImage ] || return 1
323 mkdir -p $DESTDIR/boot 2> /dev/null
324 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
325 KVERSION=$VERSION-slitaz
326 install_module_headers $DESTDIR
328 # Compress all modules.
329 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
330 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
331 else
332 return 1
333 fi
334 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
335 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
336 fi
337 ln System.map System.map-modules
338 ln vmlinux vmlinux-modules
339 ln Module.symvers Module.symvers-modules
340 }
342 # Rules to gen a SliTaz package suitable for Tazpkg.
343 genpkg_rules()
344 {
345 case "$ARCH" in
346 arm)
347 echo "Packing: ARM Kernel"
348 cp -a $install/* $fs
349 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
350 return 0 ;;
351 x86_64)
352 echo "TODO: use default or custom x86_64 packing"
353 return 0 ;;
354 esac
356 export PACKAGE VERSION
357 local path
358 cp -a $install/boot $fs
360 # Compress all modules.
361 path=$fs/lib/modules/$VERSION-slitaz/kernel
362 mkdir -p $path
364 # Get the base modules
365 export src install
366 mkdir -p $WOK/$PACKAGE/source/tmp
367 # Warning stuff/list_modules.sh must find the generated modules.list
368 $stuff/list_modules.sh \
369 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
370 while read module; do
371 dir=$(dirname $module)
372 [ -d $path/$dir ] || mkdir -p $path/$dir
373 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
374 done < $WOK/$PACKAGE/source/tmp/modules.list
376 # Remove unresolved links
377 rm -f $fs/lib/modules/$VERSION-slitaz/build
378 rm -f $fs/lib/modules/$VERSION-slitaz/source
380 # We only need module.{order,builtin} because other map files are
381 # generated by depmod in post_install
382 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
383 $install/lib/modules/$VERSION-slitaz/modules.builtin \
384 $fs/lib/modules/$VERSION-slitaz
386 # Pack all packages with a kernel module
387 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt); do
388 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
389 cook ${i%/receipt}
390 done
392 # Check any module in kernel .config that's not added to a linux-* pkgs
393 # and remove aufs patches: we dont need them in HG wok.
394 $stuff/check_modules.sh
395 rm -f $stuff/aufs3-*
396 }
398 # Pre and post install commands for Tazpkg.
399 post_install()
400 {
401 chroot "$root/" depmod -a $VERSION-slitaz
403 # Handle multiarch installation
404 case "$SLITAZ_ARCH" in
405 arm)
406 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
407 echo "Modules: /lib/modules/$VERSION-slitaz"
408 return 0 ;;
409 esac
411 # GRUB stuff.
412 if [ -f "$1/boot/grub/menu.lst" ]; then
413 # Current root device
414 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
415 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
416 # Use device.map to find grub device number
417 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
418 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
420 # Add and clean kernel entries in case of upgrade for installed system.
421 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
423 # Clean the old entry
424 # TODO: old vmlinuz file is removed but the entry is still there.
425 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
427 # Add the new entry
428 cat >> "$1/boot/grub/menu.lst" << EOT
430 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
431 $grub_dev
432 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
433 EOT
434 # Make it the default entry
435 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
436 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
437 fi
439 # Display information message.
440 cat <<EOT
442 ----
443 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
445 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
446 $grub_dev
447 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
448 ----
449 EOT
450 fi
451 true
452 }