wok-6.x view linux/receipt @ rev 20165

Up linux (3.2.98) including KPTI to fix Meltdown security vulnerability
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jan 10 15:30:44 2018 +0100 (2018-01-10)
parents c76d35a1ca0b
children 6ebbd98ea342
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 fi
264 # Build bzImage64 with modules
265 cp -f $stuff/$PACKAGE-slitaz.config64 .config
266 echo -e "\n* Configure bzImage64 with modules...\n"
267 yes '' | make ARCH=x86_64 oldconfig
268 echo -e "\n* Building bzImage64 with modules...\n"
269 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
270 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
271 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
272 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
273 ln .config $WOK/$PACKAGE/source/slitaz/config64
274 [ -s arch/x86/boot/bzImage ] || return 1
275 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
276 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz64
277 KVERSION=$VERSION-slitaz64
278 install_module_headers $DESTDIR/linux64
279 ln System.map System.map-modules64
280 ln Module.symvers Module.symvers-modules64
281 else
282 echo "* Skipping: x86_64 Kernel..."
283 fi
285 #
286 # Linux Arch i386 - GCC arch i486
287 #
288 echo "Compiling: i386 Kernel..."
290 # Build bzImage without modules first
291 if [ ! "$nonomods" ]; then
292 cp -f $stuff/$PACKAGE-slitaz.config .config
293 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
294 # We can't keep every driver in staging ???
295 sed -i -e 's/^CONFIG_RTL8192/#&/' \
296 -e 's/^CONFIG_R8187SE/#&/' \
297 -e 's/^CONFIG_RT2870/#&/' .config
298 echo -e "\n* Configure bzImage without modules...\n"
299 yes '' | make ARCH=i386 oldconfig
300 echo -e "\n* Building bzImage without modules...\n"
301 make ARCH=i386 -j 4 bzImage || exit 1
302 [ -d $DESTDIR ] || mkdir -p $DESTDIR
303 mv arch/x86/boot/bzImage $DESTDIR
304 mv System.map System.map-without-modules
305 fi
307 # Build bzImage with modules
308 cp -f $stuff/$PACKAGE-slitaz.config .config
309 echo -e "\n* Configure bzImage with modules...\n"
310 yes '' | make ARCH=i386 oldconfig
311 ln .config $WOK/$PACKAGE/source/slitaz/config
312 echo -e "\n* Building bzImage with modules...\n"
313 make ARCH=i386 -j 4 bzImage &&
314 make ARCH=i386 -j 4 modules &&
315 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
316 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
317 [ -s arch/x86/boot/bzImage ] || return 1
318 mkdir -p $DESTDIR/boot 2> /dev/null
319 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
320 KVERSION=$VERSION-slitaz
321 install_module_headers $DESTDIR
323 # Compress all modules.
324 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
325 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
326 else
327 return 1
328 fi
329 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
330 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
331 fi
332 ln System.map System.map-modules
333 ln Module.symvers Module.symvers-modules
334 }
336 # Rules to gen a SliTaz package suitable for Tazpkg.
337 genpkg_rules()
338 {
339 case "$ARCH" in
340 arm)
341 echo "Packing: ARM Kernel"
342 cp -a $install/* $fs
343 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
344 return 0 ;;
345 x86_64)
346 echo "TODO: use default or custom x86_64 packing"
347 return 0 ;;
348 esac
350 export PACKAGE VERSION
351 local path
352 cp -a $install/boot $fs
354 # Compress all modules.
355 path=$fs/lib/modules/$VERSION-slitaz/kernel
356 mkdir -p $path
358 # Get the base modules
359 export src install
360 mkdir -p $WOK/$PACKAGE/source/tmp
361 # Warning stuff/list_modules.sh must find the generated modules.list
362 $stuff/list_modules.sh \
363 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
364 while read module; do
365 dir=$(dirname $module)
366 [ -d $path/$dir ] || mkdir -p $path/$dir
367 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
368 done < $WOK/$PACKAGE/source/tmp/modules.list
370 # Remove unresolved links
371 rm -f $fs/lib/modules/$VERSION-slitaz/build
372 rm -f $fs/lib/modules/$VERSION-slitaz/source
374 # We only need module.{order,builtin} because other map files are
375 # generated by depmod in post_install
376 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
377 $install/lib/modules/$VERSION-slitaz/modules.builtin \
378 $fs/lib/modules/$VERSION-slitaz
380 # Pack all packages with a kernel module
381 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt); do
382 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
383 cook ${i%/receipt}
384 done
386 # Check any module in kernel .config that's not added to a linux-* pkgs
387 # and remove aufs patches: we dont need them in HG wok.
388 $stuff/check_modules.sh
389 rm -f $stuff/aufs3-*
390 }
392 # Pre and post install commands for Tazpkg.
393 post_install()
394 {
395 chroot "$root/" depmod -a $VERSION-slitaz
397 # Handle multiarch installation
398 case "$SLITAZ_ARCH" in
399 arm)
400 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
401 echo "Modules: /lib/modules/$VERSION-slitaz"
402 return 0 ;;
403 esac
405 # GRUB stuff.
406 if [ -f "$1/boot/grub/menu.lst" ]; then
407 # Current root device
408 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
409 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
410 # Use device.map to find grub device number
411 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
412 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
414 # Add and clean kernel entries in case of upgrade for installed system.
415 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
417 # Clean the old entry
418 # TODO: old vmlinuz file is removed but the entry is still there.
419 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
421 # Add the new entry
422 cat >> "$1/boot/grub/menu.lst" << EOT
424 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
425 $grub_dev
426 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
427 EOT
428 # Make it the default entry
429 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
430 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
431 fi
433 # Display information message.
434 cat <<EOT
436 ----
437 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
439 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
440 $grub_dev
441 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
442 ----
443 EOT
444 fi
445 true
446 }