wok-current view linux/receipt @ rev 20124
w3m: use imlib2
author | Xander Ziiryanoff <psychomaniak@xakep.ru> |
---|---|
date | Sun Oct 15 01:56:59 2017 +0200 (2017-10-15) |
parents | 58fd2812d1bf |
children | ffc20f9bd49f |
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.2.71"
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 $PACKAGE-CVE-2016-5696.u
227 aufs3-base.patch
228 aufs3-standalone.patch
229 aufs3-loopback.patch
230 aufs3-mmap.patch
231 channel-negative-one-maxim.patch
232 mac80211.compat08082009.wl_frag+ack_v1.patch
233 $PACKAGE-CVE-2016-5195.u
234 EOT
236 # Mrproper and lguest
237 echo "Make kernel proper and then build lguest..."
238 make mrproper
239 cd Documentation/virtual/lguest
240 make lguest || return 1
241 cd $src
243 #
244 # Arch x86_64: TODO have a real cross environment
245 #
246 if [ ! "$nox64" ]; then
247 echo "Compiling: x86_64 Kernel"
249 # Build bzImage64 without modules first
250 if [ ! "$nonomods" ]; then
251 cp -f $stuff/$PACKAGE-slitaz.config64 .config
252 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
253 # We can't keep every driver in staging ???
254 sed -i -e 's/^CONFIG_RTL8192/#&/' \
255 -e 's/^CONFIG_R8187SE/#&/' \
256 -e 's/^CONFIG_RT2870/#&/' .config
257 echo -e "\n* Configure bzImage64 without modules...\n"
258 yes '' | make ARCH=x86_64 oldconfig
259 echo -e "\n* Building bzImage64 without modules...\n"
260 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
261 [ -d $DESTDIR ] || mkdir -p $DESTDIR/linux64
262 mv arch/x86/boot/bzImage $DESTDIR/linux64
263 mv System.map System.map-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 Module.symvers Module.symvers-modules64
283 else
284 echo "* Skipping: x86_64 Kernel..."
285 fi
287 #
288 # Linux Arch i386 - GCC arch i486
289 #
290 echo "Compiling: i386 Kernel..."
292 # Build bzImage without modules first
293 if [ ! "$nonomods" ]; then
294 cp -f $stuff/$PACKAGE-slitaz.config .config
295 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
296 # We can't keep every driver in staging ???
297 sed -i -e 's/^CONFIG_RTL8192/#&/' \
298 -e 's/^CONFIG_R8187SE/#&/' \
299 -e 's/^CONFIG_RT2870/#&/' .config
300 echo -e "\n* Configure bzImage without modules...\n"
301 yes '' | make ARCH=i386 oldconfig
302 echo -e "\n* Building bzImage without modules...\n"
303 make ARCH=i386 -j 4 bzImage || exit 1
304 [ -d $DESTDIR ] || mkdir -p $DESTDIR
305 mv arch/x86/boot/bzImage $DESTDIR
306 mv System.map System.map-without-modules
307 fi
309 # Build bzImage with modules
310 cp -f $stuff/$PACKAGE-slitaz.config .config
311 echo -e "\n* Configure bzImage with modules...\n"
312 yes '' | make ARCH=i386 oldconfig
313 ln .config $WOK/$PACKAGE/source/slitaz/config
314 echo -e "\n* Building bzImage with modules...\n"
315 make ARCH=i386 -j 4 bzImage &&
316 make ARCH=i386 -j 4 modules &&
317 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
318 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
319 [ -s arch/x86/boot/bzImage ] || return 1
320 mkdir -p $DESTDIR/boot 2> /dev/null
321 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
322 KVERSION=$VERSION-slitaz
323 install_module_headers $DESTDIR
325 # Compress all modules.
326 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
327 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
328 else
329 return 1
330 fi
331 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
332 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
333 fi
334 ln System.map System.map-modules
335 ln Module.symvers Module.symvers-modules
336 }
338 # Rules to gen a SliTaz package suitable for Tazpkg.
339 genpkg_rules()
340 {
341 case "$ARCH" in
342 arm)
343 echo "Packing: ARM Kernel"
344 cp -a $install/* $fs
345 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
346 return 0 ;;
347 x86_64)
348 echo "TODO: use default or custom x86_64 packing"
349 return 0 ;;
350 esac
352 export PACKAGE VERSION
353 local path
354 cp -a $install/boot $fs
356 # Compress all modules.
357 path=$fs/lib/modules/$VERSION-slitaz/kernel
358 mkdir -p $path
360 # Get the base modules
361 export src install
362 mkdir -p $WOK/$PACKAGE/source/tmp
363 # Warning stuff/list_modules.sh must find the generated modules.list
364 $stuff/list_modules.sh \
365 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
366 while read module; do
367 dir=$(dirname $module)
368 [ -d $path/$dir ] || mkdir -p $path/$dir
369 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
370 done < $WOK/$PACKAGE/source/tmp/modules.list
372 # Remove unresolved links
373 rm -f $fs/lib/modules/$VERSION-slitaz/build
374 rm -f $fs/lib/modules/$VERSION-slitaz/source
376 # We only need module.{order,builtin} because other map files are
377 # generated by depmod in post_install
378 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
379 $install/lib/modules/$VERSION-slitaz/modules.builtin \
380 $fs/lib/modules/$VERSION-slitaz
382 # Pack all packages with a kernel module
383 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt); do
384 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
385 cook ${i%/receipt}
386 done
388 # Check any module in kernel .config that's not added to a linux-* pkgs
389 # and remove aufs patches: we dont need them in HG wok.
390 $stuff/check_modules.sh
391 rm -f $stuff/aufs3-*
392 }
394 # Pre and post install commands for Tazpkg.
395 post_install()
396 {
397 chroot "$root/" depmod -a $VERSION-slitaz
399 # Handle multiarch installation
400 case "$SLITAZ_ARCH" in
401 arm)
402 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
403 echo "Modules: /lib/modules/$VERSION-slitaz"
404 return 0 ;;
405 esac
407 # GRUB stuff.
408 if [ -f "$1/boot/grub/menu.lst" ]; then
409 # Current root device
410 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
411 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
412 # Use device.map to find grub device number
413 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
414 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
416 # Add and clean kernel entries in case of upgrade for installed system.
417 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
419 # Clean the old entry
420 # TODO: old vmlinuz file is removed but the entry is still there.
421 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
423 # Add the new entry
424 cat >> "$1/boot/grub/menu.lst" << EOT
426 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
427 $grub_dev
428 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
429 EOT
430 # Make it the default entry
431 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
432 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
433 fi
435 # Display information message.
436 cat <<EOT
438 ----
439 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
441 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
442 $grub_dev
443 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
444 ----
445 EOT
446 fi
447 true
448 }