wok-current view linux/receipt @ rev 20266

linux-module-headers: add include/linux/version.h (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Mar 15 18:29:25 2018 +0100 (2018-03-15)
parents e564e12169b9
children f078c217decc
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"
17 #
18 # The Linux receipt handle cross compilation. For x86_64 we actually use
19 # the uclibc-cross-compiler-x86_64 and for ARM we use a real cross env.
20 # Please discuss any change and keep it simple, dont play with VERSION
21 # string or Kernel SUBLEVEL because depmod and Pankso dont like that!
22 #
23 # The receipt also handle some cook options for faster build:
24 # --nox64 : Skip the x86_64 cross compilation
25 # --nonomods : Skip bzImage without modules build
26 #
28 # Aufs enable chroot
29 AUFS_NOT_RAMFS="uclibc-cross-compiler-x86_64 is not compatible with aufs+tmpfs 8("
31 # Handle multiarch compilation. Less bdeps when cross-compiling for ARM
32 case "$ARCH" in
33 arm) BUILD_DEPENDS="xz" ;;
34 x86_64) BUILD_DEPENDS="xz" ;;
35 esac
37 # Handle multiarch installation. ARM use Busybox modutils, so avoid any
38 # deps on kmod. SLITAZ_ARCH can have also custom post_install commands
39 if [ -f $root/etc/slitaz/slitaz.conf ]; then
40 . $root/etc/slitaz/slitaz.conf
41 case "$SLITAZ_ARCH" in
42 arm) DEPENDS="" ;;
43 esac
44 fi
46 install_module_headers()
47 {
48 local path
49 path=usr/src/linux-$KVERSION
50 mkdir -p $1/lib/modules/$KVERSION
51 ln -sf /$path $1/lib/modules/$KVERSION/build
52 install -D -m644 $src/Makefile \
53 $1/$path/Makefile
54 install -D -m644 $src/kernel/Makefile \
55 $1/$path/kernel/Makefile
56 install -D -m644 $src/.config \
57 $1/$path/.config
58 mkdir -p $1/$path/include
60 cp -a $src/include/* $1/$path/include/
61 rm -f $1/$path/include/Kbuild
63 # copy arch includes for external modules
64 mkdir -p $1/$path/arch/x86
65 cp -a $src/arch/x86/include $1/$path/arch/x86/
67 # copy files necessary for later builds, like nvidia and vmware
68 cp -a $src/Module.symvers $1/$path/Module.symvers
69 cp -a $src/scripts $1/$path
70 # fix permissions on scripts dir
71 chmod og-w -R $1/$path/scripts
72 mkdir -p $1/$path/.tmp_versions
74 mkdir -p $1/$path/arch/x86/kernel
75 cp -a $src/arch/x86/Makefile $1/$path/arch/x86/
76 cp -a $src/arch/x86/Makefile_32.cpu $1/$path/arch/x86/
77 cp -a $src/arch/x86/kernel/asm-offsets.s $1/$path/arch/x86/kernel/
79 # add headers for lirc package
80 mkdir -p $1/$path/drivers/media
81 ( cd $src/drivers/media ; find i2c -name '*.h' | cpio -o -H newc ) | \
82 ( cd $1/$path/drivers/media ; cpio -idmu )
84 # add docbook makefile
85 install -D -m644 $src/Documentation/DocBook/Makefile \
86 $1/$path/Documentation/DocBook/Makefile
88 # add dm headers
89 mkdir -p $1/$path/drivers/md
90 cp -a $src/drivers/md/*.h $1/$path/drivers/md
92 # add inotify.h
93 mkdir -p $1/$path/include/linux
94 cp -a $src/include/linux/inotify.h $1/$path/include/linux/
96 # add wireless headers
97 mkdir -p $1/$path/net/mac80211/
98 cp -a $src/net/mac80211/*.h $1/$path/net/mac80211/
100 # add dvb headers for external modules
101 # in reference to:
102 # http://bugs.archlinux.org/task/9912
103 mkdir -p $1/$path/drivers/media/dvb-core
104 cp -a $src/drivers/media/dvb-core/*.h $1/$path/drivers/media/dvb-core/
106 # add dvb headers for external modules
107 # in reference to:
108 # http://bugs.archlinux.org/task/11194
109 if [ -d $src/include/config/dvb/ ]; then
110 mkdir -p $1/$path/include/config/dvb/
111 cp $src/include/config/dvb/*.h $1/$path/include/config/dvb/
112 fi
114 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
115 # in reference to:
116 # http://bugs.archlinux.org/task/13146
117 mkdir -p $1/$path/drivers/media/dvb-frontends/
118 cp -a $src/drivers/media/dvb-frontends/lgdt330x.h $1/$path/drivers/media/dvb-frontends/
119 cp -a $src/drivers/media/i2c/msp3400-driver.h $1/$path/drivers/media/dvb-frontends/
121 # add dvb headers
122 # in reference to:
123 # http://bugs.archlinux.org/task/20402
124 mkdir -p $1/$path/drivers/media/usb/dvb-usb
125 cp -a $src/drivers/media/usb/dvb-usb/*.h $1/$path/drivers/media/usb/dvb-usb/
126 mkdir -p $1/$path/drivers/media/dvb-frontends
127 cp -a $src/drivers/media/dvb-frontends/*.h $1/$path/drivers/media/dvb-frontends/
128 mkdir -p $1/$path/drivers/media/tuners
129 cp -a $src/drivers/media/tuners/*.h $1/$path/drivers/media/tuners/
131 # add xfs and shmem for aufs building
132 mkdir -p $1/$path/fs/xfs
133 mkdir -p $1/$path/mm
134 cp -a $src/fs/xfs/xfs_sb.h $1/$path/fs/xfs/xfs_sb.h
135 cp -a $src/fs/*.h $1/$path/fs/
137 # copy in Kconfig files
138 for i in $(find . -name "Kconfig*"); do
139 mkdir -p $1/$path/$(echo $i | sed 's|/Kconfig.*||')
140 cp -a $src/$i $1/$path/$i
141 done
143 chown -R root.root $1/$path
144 find $1/$path -type d -exec chmod 755 {} \;
145 # remove unneeded architectures
146 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}
147 }
149 # Rules to configure and make the package.
150 compile_rules()
151 {
152 if [ -f "/usr/share/boot/initrd" ]; then
153 cp /usr/share/boot/initrd initrd.cpio
154 fi
156 # Handle cross compilation
157 case "$ARCH" in
158 arm)
159 echo "Compiling: $ARCH Kernel"
160 make mrproper
161 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
162 cp -f $stuff/$ARCH/linux-arm.config .config
163 yes '' | make ARCH=$ARCH oldconfig
164 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
165 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
166 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
167 INSTALL_MOD_PATH=$DESTDIR modules_install &&
168 mkdir -p $DESTDIR/boot &&
169 cp -a arch/arm/boot/zImage \
170 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
171 #$stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
172 return 0 ;;
173 x86_64)
174 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
175 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
176 return 0 ;;
177 esac
179 # Check for Aufs and get source/patches if needed
180 echo "Checking for Aufs packages..."
181 AUFSVER=$(grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g')
182 AUFSDIR="$WOK/aufs/source/aufs-${AUFSVER}"
183 if [ ! -d "$AUFSDIR" ]; then
184 [ ! -f "$SRC/aufs-${AUFSVER}.tar.bz2" ] && cook aufs --getsrc
185 mkdir -p $WOK/aufs/source/
186 echo "Extracting: aufs-${AUFSVER}.tar.bz2"
187 tar xjf $SRC/aufs-${AUFSVER}.tar.bz2 -C $WOK/aufs/source/
188 fi
190 echo "cook:linux" > $command
192 echo "Copying Aufs files and patches..."
193 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
195 # Use fixed patchs from stuff
196 cp -a $AUFSDIR/aufs3-*.patch $stuff
198 # SliTaz db stuff
199 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz
200 mkdir -p $WOK/$PACKAGE/source/slitaz
201 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
202 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
203 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
205 # Apply patches
206 echo "Applying patches..."
207 while read patch_file; do
208 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
209 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
210 if [ -f done.$patch_file ]; then
211 echo "Skipping $patch_file" && continue
212 fi
213 echo "Apply $patch_file"
214 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
215 touch done.$patch_file
216 done <<EOT
217 $PACKAGE-diff.u
218 $PACKAGE-freeinitrd.u
219 $PACKAGE-subroot.u
220 $PACKAGE-romfs.u
221 aufs3-base.patch
222 aufs3-standalone.patch
223 aufs3-loopback.patch
224 aufs3-mmap.patch
225 EOT
227 # Mrproper and lguest
228 echo "Make kernel proper and then build lguest..."
229 make mrproper
230 cd tools/lguest
231 make lguest || return 1
232 cd $src
234 #
235 # Arch x86_64: TODO have a real cross environment
236 #
237 if [ ! "$nox64" ]; then
238 echo "Compiling: x86_64 Kernel"
240 # Build bzImage64 without modules first
241 if [ ! "$nonomods" ]; then
242 cp -f $stuff/$PACKAGE-slitaz.config64 .config
243 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
244 echo -e "\n* Configure bzImage64 without modules...\n"
245 yes '' | make ARCH=x86_64 oldconfig
246 echo -e "\n* Building bzImage64 without modules...\n"
247 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
248 [ -d $DESTDIR ] || mkdir -p $DESTDIR/linux64
249 mv arch/x86/boot/bzImage $DESTDIR/linux64
250 mv System.map System.map-without-modules64
251 mv vmlinux vmlinux-without-modules64
252 mv .config config-without-modules64
253 fi
255 # Build bzImage64 with modules
256 cp -f $stuff/$PACKAGE-slitaz.config64 .config
257 echo -e "\n* Configure bzImage64 with modules...\n"
258 yes '' | make ARCH=x86_64 oldconfig
259 echo -e "\n* Building bzImage64 with modules...\n"
260 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
261 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
262 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
263 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
264 ln .config $WOK/$PACKAGE/source/slitaz/config64
265 [ -s arch/x86/boot/bzImage ] || return 1
266 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
267 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz64
268 KVERSION=$VERSION-slitaz64
269 install_module_headers $DESTDIR/linux64
270 ln System.map System.map-modules64
271 ln vmlinux vmlinux-modules64
272 ln Module.symvers Module.symvers-modules64
273 cp .config config-modules64
274 else
275 echo "* Skipping: x86_64 Kernel..."
276 fi
278 #
279 # Linux Arch i386 - GCC arch i486
280 #
281 echo "Compiling: i386 Kernel..."
283 # Build bzImage without modules first
284 if [ ! "$nonomods" ]; then
285 cp -f $stuff/$PACKAGE-slitaz.config .config
286 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
287 echo -e "\n* Configure bzImage without modules...\n"
288 yes '' | make ARCH=i386 oldconfig
289 echo -e "\n* Building bzImage without modules...\n"
290 make ARCH=i386 -j 4 bzImage || exit 1
291 [ -d $DESTDIR ] || mkdir -p $DESTDIR
292 mv arch/x86/boot/bzImage $DESTDIR
293 mv System.map System.map-without-modules
294 mv vmlinux vmlinux-without-modules
295 mv .config config-without-modules
296 fi
298 # Build bzImage with modules
299 cp -f $stuff/$PACKAGE-slitaz.config .config
300 echo -e "\n* Configure bzImage with modules...\n"
301 yes '' | make ARCH=i386 oldconfig
302 ln .config $WOK/$PACKAGE/source/slitaz/config
303 echo -e "\n* Building bzImage with modules...\n"
304 make ARCH=i386 -j 4 bzImage &&
305 make ARCH=i386 -j 4 modules &&
306 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
307 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
308 [ -s arch/x86/boot/bzImage ] || return 1
309 mkdir -p $DESTDIR/boot 2> /dev/null
310 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
311 KVERSION=$VERSION-slitaz
312 install_module_headers $DESTDIR
314 # Compress all modules.
315 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
316 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
317 else
318 return 1
319 fi
320 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
321 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
322 fi
323 ln System.map System.map-modules
324 ln vmlinux vmlinux-modules
325 ln Module.symvers Module.symvers-modules
326 cp .config config-modules
327 }
329 # Rules to gen a SliTaz package suitable for Tazpkg.
330 genpkg_rules()
331 {
332 case "$ARCH" in
333 arm)
334 echo "Packing: ARM Kernel"
335 cp -a $install/* $fs
336 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
337 return 0 ;;
338 x86_64)
339 echo "TODO: use default or custom x86_64 packing"
340 return 0 ;;
341 esac
343 export PACKAGE VERSION
344 local path
345 cp -a $install/boot $fs
347 # Compress all modules.
348 path=$fs/lib/modules/$VERSION-slitaz/kernel
349 mkdir -p $path
351 # Get the base modules
352 export src install
353 mkdir -p $WOK/$PACKAGE/source/tmp
354 # Warning stuff/list_modules.sh must find the generated modules.list
355 $stuff/list_modules.sh \
356 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
357 while read module; do
358 dir=$(dirname $module)
359 [ -d $path/$dir ] || mkdir -p $path/$dir
360 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
361 done < $WOK/$PACKAGE/source/tmp/modules.list
363 # Remove unresolved links
364 rm -f $fs/lib/modules/$VERSION-slitaz/build
365 rm -f $fs/lib/modules/$VERSION-slitaz/source
367 # We only need module.{order,builtin} because other map files are
368 # generated by depmod in post_install
369 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
370 $install/lib/modules/$VERSION-slitaz/modules.builtin \
371 $fs/lib/modules/$VERSION-slitaz
373 # Pack all packages with a kernel module
374 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt); do
375 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
376 cook ${i%/receipt}
377 done
379 # Check any module in kernel .config that's not added to a linux-* pkgs
380 # and remove aufs patches: we dont need them in HG wok.
381 $stuff/check_modules.sh
383 # Keep fixed patches !
384 #rm -f $stuff/aufs3-*
385 }
387 # Pre and post install commands for Tazpkg.
388 post_install()
389 {
390 chroot "$root/" depmod -a $VERSION-slitaz
392 # Handle multiarch installation
393 case "$SLITAZ_ARCH" in
394 arm)
395 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
396 echo "Modules: /lib/modules/$VERSION-slitaz"
397 return 0 ;;
398 esac
400 # GRUB stuff.
401 if [ -f "$1/boot/grub/menu.lst" ]; then
402 # Current root device
403 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
404 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
405 # Use device.map to find grub device number
406 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
407 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
409 # Add and clean kernel entries in case of upgrade for installed system.
410 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
412 # Clean the old entry
413 # TODO: old vmlinuz file is removed but the entry is still there.
414 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
416 # Add the new entry
417 cat >> "$1/boot/grub/menu.lst" << EOT
419 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
420 $grub_dev
421 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
422 EOT
423 # Make it the default entry
424 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
425 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
426 fi
428 # Display information message.
429 cat <<EOT
431 ----
432 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
434 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
435 $grub_dev
436 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
437 ----
438 EOT
439 fi
440 true
441 }