wok view linux/receipt @ rev 22345

tcc, unfs3: race condition
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Nov 17 20:40:16 2019 +0100 (2019-11-17)
parents 99a7a1e955d4
children 324b3fa82b76
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="https://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/linux-aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g')
183 AUFSSRCDIR="$WOK/linux-aufs/source"
184 AUFSDIR="$AUFSSRCDIR/linux-aufs-${AUFSVER}"
185 if [ ! -d "$AUFSDIR" ]; then
186 [ ! -f "$SRC/aufs-${AUFSVER}.tar.bz2" ] && cook aufs --getsrc
187 mkdir -p $AUFSSRCDIR
188 echo "Extracting: aufs-${AUFSVER}.tar.bz2"
189 tar xjf $SRC/aufs-${AUFSVER}.tar.bz2 -C $AUFSSRCDIR/
190 ( cd $AUFSDIR ; [ -d fs ] || git checkout origin/aufs${VERSION%.*} )
191 fi
193 echo "cook:linux" > $command
195 echo "Copying Aufs files and patches..."
196 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
198 # Use fixed patchs from stuff
199 cp -a $AUFSDIR/aufs3-*.patch $stuff
201 # SliTaz db stuff
202 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz
203 mkdir -p $WOK/$PACKAGE/source/slitaz
204 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
205 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
206 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
208 # Apply patches
209 echo "Applying patches..."
210 while read patch_file; do
211 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
212 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
213 if [ -f done.$patch_file ]; then
214 echo "Skipping $patch_file" && continue
215 fi
216 echo "Apply $patch_file"
217 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
218 touch done.$patch_file
219 done <<EOT
220 $PACKAGE-diff.u
221 $PACKAGE-freeinitrd.u
222 $PACKAGE-subroot.u
223 $PACKAGE-romfs.u
224 $PACKAGE-tcp_stealth.u
225 $PACKAGE-efi.u
226 aufs3-base.patch
227 aufs3-standalone.patch
228 aufs3-loopback.patch
229 aufs3-mmap.patch
230 EOT
232 # Mrproper and lguest
233 echo "Make kernel proper and then build lguest..."
234 make mrproper
235 cd tools/lguest
236 make lguest || return 1
238 echo "Build usbip..."
239 cd $src/drivers/staging/usbip/userspace
240 ./autogen.sh
241 ./configure CFLAGS="$CFLAGS -Wno-error=uninitialized" \
242 --with-usbids-dir=/usr/share/misc \
243 --mandir=/usr/share/man $CONFIGURE_ARGS &&
244 make && make DESTDIR=$DESTDIR/usbip install || return 1
246 cd $src
248 #
249 # Arch x86_64: TODO have a real cross environment
250 #
251 if [ ! "$nox64" ]; then
252 echo "Compiling: x86_64 Kernel"
254 # Build bzImage64 without modules first
255 if [ ! "$nonomods" ]; then
256 [ -d $DESTDIR/linux64 ] || mkdir -p $DESTDIR/linux64 ||
257 return 1
258 cp -f $stuff/$PACKAGE-slitaz.config64 .config
259 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
260 echo -e "\n* Configure bzImage64 without modules...\n"
261 yes '' | make ARCH=x86_64 oldconfig
262 echo -e "\n* Building bzImage64 without modules...\n"
263 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
264 mv arch/x86/boot/bzImage $DESTDIR/linux64
265 mv System.map System.map-without-modules64
266 mv vmlinux vmlinux-without-modules64
267 mv .config config-without-modules64
268 fi
270 # Build bzImage64 with modules
271 cp -f $stuff/$PACKAGE-slitaz.config64 .config
272 echo -e "\n* Configure bzImage64 with modules...\n"
273 yes '' | make ARCH=x86_64 oldconfig
274 echo -e "\n* Building bzImage64 with modules...\n"
275 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
276 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
277 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
278 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
279 ln .config $WOK/$PACKAGE/source/slitaz/config64
280 [ -s arch/x86/boot/bzImage ] || return 1
281 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
282 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz64
283 KVERSION=$VERSION-slitaz64
284 install_module_headers $DESTDIR/linux64
285 ln System.map System.map-modules64
286 ln vmlinux vmlinux-modules64
287 ln Module.symvers Module.symvers-modules64
288 cp .config config-modules64
289 else
290 echo "* Skipping: x86_64 Kernel..."
291 fi
293 #
294 # Linux Arch i386 - GCC arch i486
295 #
296 echo "Compiling: i386 Kernel..."
298 # Build bzImage without modules first
299 if [ ! "$nonomods" ]; then
300 cp -f $stuff/$PACKAGE-slitaz.config .config
301 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
302 echo -e "\n* Configure bzImage without modules...\n"
303 yes '' | make ARCH=i386 oldconfig
304 echo -e "\n* Building bzImage without modules...\n"
305 make ARCH=i386 -j 4 bzImage || exit 1
306 [ -d $DESTDIR ] || mkdir -p $DESTDIR
307 mv arch/x86/boot/bzImage $DESTDIR
308 mv System.map System.map-without-modules
309 mv vmlinux vmlinux-without-modules
310 mv .config config-without-modules
311 fi
313 # Build bzImage with modules
314 cp -f $stuff/$PACKAGE-slitaz.config .config
315 echo -e "\n* Configure bzImage with modules...\n"
316 yes '' | make ARCH=i386 oldconfig
317 ln .config $WOK/$PACKAGE/source/slitaz/config
318 echo -e "\n* Building bzImage with modules...\n"
319 make ARCH=i386 -j 4 bzImage &&
320 make ARCH=i386 -j 4 modules &&
321 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
322 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
323 [ -s arch/x86/boot/bzImage ] || return 1
324 mkdir -p $DESTDIR/boot 2> /dev/null
325 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
326 KVERSION=$VERSION-slitaz
327 install_module_headers $DESTDIR
329 # Compress all modules.
330 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
331 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
332 else
333 return 1
334 fi
335 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
336 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
337 fi
338 ln System.map System.map-modules
339 ln vmlinux vmlinux-modules
340 ln Module.symvers Module.symvers-modules
341 cp .config config-modules
342 }
344 # Rules to gen a SliTaz package suitable for Tazpkg.
345 genpkg_rules()
346 {
347 case "$ARCH" in
348 arm)
349 echo "Packing: ARM Kernel"
350 cp -a $install/* $fs
351 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
352 return 0 ;;
353 x86_64)
354 echo "TODO: use default or custom x86_64 packing"
355 return 0 ;;
356 esac
358 export PACKAGE VERSION
359 local path
360 cp -a $install/boot $fs
362 # Compress all modules.
363 path=$fs/lib/modules/$VERSION-slitaz/kernel
364 mkdir -p $path
366 # Get the base modules
367 export src install
368 mkdir -p $WOK/$PACKAGE/source/tmp
369 # Warning stuff/list_modules.sh must find the generated modules.list
370 $stuff/list_modules.sh \
371 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
372 while read module; do
373 dir=$(dirname $module)
374 [ -d $path/$dir ] || mkdir -p $path/$dir
375 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
376 done < $WOK/$PACKAGE/source/tmp/modules.list
378 # Remove unresolved links
379 rm -f $fs/lib/modules/$VERSION-slitaz/build
380 rm -f $fs/lib/modules/$VERSION-slitaz/source
382 # We only need module.{order,builtin} because other map files are
383 # generated by depmod in post_install
384 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
385 $install/lib/modules/$VERSION-slitaz/modules.builtin \
386 $fs/lib/modules/$VERSION-slitaz
388 # Pack all packages with a kernel module
389 sed -i "/^$PACKAGE\$/d" $CACHE/broken 2>/dev/null || true
390 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt); do
391 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
392 cook ${i%/receipt}
393 done
395 # Check any module in kernel .config that's not added to a linux-* pkgs
396 # and remove aufs patches: we dont need them in HG wok.
397 $stuff/check_modules.sh
399 # Keep fixed patches !
400 #rm -f $stuff/aufs3-*
401 }
403 # Pre and post install commands for Tazpkg.
404 post_install()
405 {
406 chroot "$root/" depmod -a $VERSION-slitaz
408 # Handle multiarch installation
409 case "$SLITAZ_ARCH" in
410 arm)
411 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
412 echo "Modules: /lib/modules/$VERSION-slitaz"
413 return 0 ;;
414 esac
416 # GRUB stuff.
417 if [ -f "$1/boot/grub/menu.lst" ]; then
418 # Current root device
419 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
420 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
421 # Use device.map to find grub device number
422 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
423 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
425 # Add and clean kernel entries in case of upgrade for installed system.
426 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
428 # Clean the old entry
429 # TODO: old vmlinuz file is removed but the entry is still there.
430 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
432 # Add the new entry
433 cat >> "$1/boot/grub/menu.lst" << EOT
435 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
436 $grub_dev
437 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
438 EOT
439 # Make it the default entry
440 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
441 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
442 fi
444 # Display information message.
445 cat <<EOT
447 ----
448 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
450 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
451 $grub_dev
452 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
453 ----
454 EOT
455 fi
456 true
457 }