wok view linux/receipt @ rev 20295

Add python-humanize, python-pyajam, python-paho-mqtt
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 25 16:08:37 2018 +0200 (2018-04-25)
parents 36656a030ec4
children fa77ea692592
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.16.55"
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="https://cdn.kernel.org/pub/linux/kernel/v${VERSION%%.*}.x/$TARBALL"
12 HOST_ARCH="i486 arm x86_64"
14 DEPENDS="kmod"
15 BUILD_DEPENDS="perl git xz lzma patch kmod uclibc-cross-compiler-x86_64 bc \
16 sysfsutils-dev libtool glib-dev libwrap libwrap-dev udev-dev"
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 cp -a $src/include/* $1/$path/include/
62 rm -f $1/$path/include/Kbuild
64 # copy arch includes for external modules
65 mkdir -p $1/$path/arch/x86
66 cp -a $src/arch/x86/include $1/$path/arch/x86/
68 # copy files necessary for later builds, like nvidia and vmware
69 cp -a $src/Module.symvers $1/$path/Module.symvers
70 cp -a $src/scripts $1/$path
71 # fix permissions on scripts dir
72 chmod og-w -R $1/$path/scripts
73 mkdir -p $1/$path/.tmp_versions
75 mkdir -p $1/$path/arch/x86/kernel
76 cp -a $src/arch/x86/Makefile $1/$path/arch/x86/
77 cp -a $src/arch/x86/Makefile_32.cpu $1/$path/arch/x86/
78 cp -a $src/arch/x86/kernel/asm-offsets.s $1/$path/arch/x86/kernel/
80 # add headers for lirc package
81 mkdir -p $1/$path/drivers/media
82 ( cd $src/drivers/media ; find i2c -name '*.h' | cpio -o -H newc ) | \
83 ( cd $1/$path/drivers/media ; cpio -idmu )
85 # add docbook makefile
86 install -D -m644 $src/Documentation/DocBook/Makefile \
87 $1/$path/Documentation/DocBook/Makefile
89 # add dm headers
90 mkdir -p $1/$path/drivers/md
91 cp -a $src/drivers/md/*.h $1/$path/drivers/md
93 # add inotify.h
94 mkdir -p $1/$path/include/linux
95 cp -a $src/include/linux/inotify.h $1/$path/include/linux/
97 # add wireless headers
98 mkdir -p $1/$path/net/mac80211/
99 cp -a $src/net/mac80211/*.h $1/$path/net/mac80211/
101 # add dvb headers for external modules
102 # in reference to:
103 # http://bugs.archlinux.org/task/9912
104 mkdir -p $1/$path/drivers/media/dvb-core
105 cp -a $src/drivers/media/dvb-core/*.h $1/$path/drivers/media/dvb-core/
107 # add dvb headers for external modules
108 # in reference to:
109 # http://bugs.archlinux.org/task/11194
110 if [ -d $src/include/config/dvb/ ]; then
111 mkdir -p $1/$path/include/config/dvb/
112 cp $src/include/config/dvb/*.h $1/$path/include/config/dvb/
113 fi
115 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
116 # in reference to:
117 # http://bugs.archlinux.org/task/13146
118 mkdir -p $1/$path/drivers/media/dvb-frontends/
119 cp -a $src/drivers/media/dvb-frontends/lgdt330x.h $1/$path/drivers/media/dvb-frontends/
120 cp -a $src/drivers/media/i2c/msp3400-driver.h $1/$path/drivers/media/dvb-frontends/
122 # add dvb headers
123 # in reference to:
124 # http://bugs.archlinux.org/task/20402
125 mkdir -p $1/$path/drivers/media/usb/dvb-usb
126 cp -a $src/drivers/media/usb/dvb-usb/*.h $1/$path/drivers/media/usb/dvb-usb/
127 mkdir -p $1/$path/drivers/media/dvb-frontends
128 cp -a $src/drivers/media/dvb-frontends/*.h $1/$path/drivers/media/dvb-frontends/
129 mkdir -p $1/$path/drivers/media/tuners
130 cp -a $src/drivers/media/tuners/*.h $1/$path/drivers/media/tuners/
132 # add xfs and shmem for aufs building
133 mkdir -p $1/$path/fs/xfs
134 mkdir -p $1/$path/mm
135 cp -a $src/fs/xfs/xfs_sb.h $1/$path/fs/xfs/xfs_sb.h
136 cp -a $src/fs/*.h $1/$path/fs/
138 # copy in Kconfig files
139 for i in $(find . -name "Kconfig*"); do
140 mkdir -p $1/$path/$(echo $i | sed 's|/Kconfig.*||')
141 cp -a $src/$i $1/$path/$i
142 done
144 chown -R root.root $1/$path
145 find $1/$path -type d -exec chmod 755 {} \;
146 # remove unneeded architectures
147 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}
148 }
150 # Rules to configure and make the package.
151 compile_rules()
152 {
153 if [ -f "/usr/share/boot/initrd" ]; then
154 cp /usr/share/boot/initrd initrd.cpio
155 fi
157 # Handle cross compilation
158 case "$ARCH" in
159 arm)
160 echo "Compiling: $ARCH Kernel"
161 make mrproper
162 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
163 cp -f $stuff/$ARCH/linux-arm.config .config
164 yes '' | make ARCH=$ARCH oldconfig
165 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
166 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
167 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
168 INSTALL_MOD_PATH=$DESTDIR modules_install &&
169 mkdir -p $DESTDIR/boot &&
170 cp -a arch/arm/boot/zImage \
171 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
172 #$stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
173 return 0 ;;
174 x86_64)
175 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
176 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
177 return 0 ;;
178 esac
180 # Check for Aufs and get source/patches if needed
181 echo "Checking for Aufs packages..."
182 AUFSVER=$(grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g')
183 AUFSDIR="$WOK/aufs/source/aufs-${AUFSVER}"
184 if [ ! -d "$AUFSDIR" ]; then
185 [ ! -f "$SRC/aufs-${AUFSVER}.tar.bz2" ] && cook aufs --getsrc
186 mkdir -p $WOK/aufs/source/
187 echo "Extracting: aufs-${AUFSVER}.tar.bz2"
188 tar xjf $SRC/aufs-${AUFSVER}.tar.bz2 -C $WOK/aufs/source/
189 fi
191 echo "cook:linux" > $command
193 echo "Copying Aufs files and patches..."
194 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
196 # Use fixed patchs from stuff
197 cp -a $AUFSDIR/aufs3-*.patch $stuff
199 # SliTaz db stuff
200 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz
201 mkdir -p $WOK/$PACKAGE/source/slitaz
202 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
203 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
204 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
206 # Apply patches
207 echo "Applying patches..."
208 while read patch_file; do
209 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
210 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
211 if [ -f done.$patch_file ]; then
212 echo "Skipping $patch_file" && continue
213 fi
214 echo "Apply $patch_file"
215 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
216 touch done.$patch_file
217 done <<EOT
218 $PACKAGE-diff.u
219 $PACKAGE-freeinitrd.u
220 $PACKAGE-subroot.u
221 $PACKAGE-romfs.u
222 aufs3-base.patch
223 aufs3-standalone.patch
224 aufs3-loopback.patch
225 aufs3-mmap.patch
226 EOT
228 # Mrproper and lguest
229 echo "Make kernel proper and then build lguest..."
230 make mrproper
231 cd tools/lguest
232 make lguest || return 1
234 echo "Build usbip..."
235 cd $src/drivers/staging/usbip/userspace
236 ./autogen.sh
237 ./configure CFLAGS="$CFLAGS -Wno-error=uninitialized" \
238 --with-usbids-dir=/usr/share/misc \
239 --mandir=/usr/share/man $CONFIGURE_ARGS &&
240 make && make DESTDIR=$DESTDIR/usbip install || return 1
242 cd $src
244 #
245 # Arch x86_64: TODO have a real cross environment
246 #
247 if [ ! "$nox64" ]; then
248 echo "Compiling: x86_64 Kernel"
250 # Build bzImage64 without modules first
251 if [ ! "$nonomods" ]; then
252 [ -d $DESTDIR/linux64 ] || mkdir -p $DESTDIR/linux64 ||
253 return 1
254 cp -f $stuff/$PACKAGE-slitaz.config64 .config
255 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
256 echo -e "\n* Configure bzImage64 without modules...\n"
257 yes '' | make ARCH=x86_64 oldconfig
258 echo -e "\n* Building bzImage64 without modules...\n"
259 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
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 cp .config config-modules64
285 else
286 echo "* Skipping: x86_64 Kernel..."
287 fi
289 #
290 # Linux Arch i386 - GCC arch i486
291 #
292 echo "Compiling: i386 Kernel..."
294 # Build bzImage without modules first
295 if [ ! "$nonomods" ]; then
296 cp -f $stuff/$PACKAGE-slitaz.config .config
297 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .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 mv vmlinux vmlinux-without-modules
306 mv .config config-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 vmlinux vmlinux-modules
336 ln Module.symvers Module.symvers-modules
337 cp .config config-modules
338 }
340 # Rules to gen a SliTaz package suitable for Tazpkg.
341 genpkg_rules()
342 {
343 case "$ARCH" in
344 arm)
345 echo "Packing: ARM Kernel"
346 cp -a $install/* $fs
347 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
348 return 0 ;;
349 x86_64)
350 echo "TODO: use default or custom x86_64 packing"
351 return 0 ;;
352 esac
354 export PACKAGE VERSION
355 local path
356 cp -a $install/boot $fs
358 # Compress all modules.
359 path=$fs/lib/modules/$VERSION-slitaz/kernel
360 mkdir -p $path
362 # Get the base modules
363 export src install
364 mkdir -p $WOK/$PACKAGE/source/tmp
365 # Warning stuff/list_modules.sh must find the generated modules.list
366 $stuff/list_modules.sh \
367 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
368 while read module; do
369 dir=$(dirname $module)
370 [ -d $path/$dir ] || mkdir -p $path/$dir
371 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
372 done < $WOK/$PACKAGE/source/tmp/modules.list
374 # Remove unresolved links
375 rm -f $fs/lib/modules/$VERSION-slitaz/build
376 rm -f $fs/lib/modules/$VERSION-slitaz/source
378 # We only need module.{order,builtin} because other map files are
379 # generated by depmod in post_install
380 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
381 $install/lib/modules/$VERSION-slitaz/modules.builtin \
382 $fs/lib/modules/$VERSION-slitaz
384 # Pack all packages with a kernel module
385 sed -i "/^$PACKAGE\$/d" $CACHE/broken 2>/dev/null || true
386 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt); do
387 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
388 cook ${i%/receipt}
389 done
391 # Check any module in kernel .config that's not added to a linux-* pkgs
392 # and remove aufs patches: we dont need them in HG wok.
393 $stuff/check_modules.sh
395 # Keep fixed patches !
396 #rm -f $stuff/aufs3-*
397 }
399 # Pre and post install commands for Tazpkg.
400 post_install()
401 {
402 chroot "$root/" depmod -a $VERSION-slitaz
404 # Handle multiarch installation
405 case "$SLITAZ_ARCH" in
406 arm)
407 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
408 echo "Modules: /lib/modules/$VERSION-slitaz"
409 return 0 ;;
410 esac
412 # GRUB stuff.
413 if [ -f "$1/boot/grub/menu.lst" ]; then
414 # Current root device
415 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
416 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
417 # Use device.map to find grub device number
418 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
419 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
421 # Add and clean kernel entries in case of upgrade for installed system.
422 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
424 # Clean the old entry
425 # TODO: old vmlinuz file is removed but the entry is still there.
426 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
428 # Add the new entry
429 cat >> "$1/boot/grub/menu.lst" << EOT
431 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
432 $grub_dev
433 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
434 EOT
435 # Make it the default entry
436 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
437 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
438 fi
440 # Display information message.
441 cat <<EOT
443 ----
444 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
446 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
447 $grub_dev
448 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
449 ----
450 EOT
451 fi
452 true
453 }