wok-current view linux/receipt @ rev 24065
grub2: declared CONFIG_FILES
author | Hans-G?nter Theisgen |
---|---|
date | Sun Jun 20 14:41:40 2021 +0100 (2021-06-20) |
parents | 86790a278e70 |
children | 97e141edc8c2 |
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 current_version()
33 {
34 wget -O - $WEB_SITE 2> /dev/null | grep -A 1 longterm | \
35 sed '/strong/!d;s|.*<strong>||;s|</s.*||;q'
36 }
38 # Handle multiarch compilation. Less bdeps when cross-compiling for ARM
39 case "$ARCH" in
40 arm) BUILD_DEPENDS="xz" ;;
41 x86_64) BUILD_DEPENDS="xz" ;;
42 esac
44 # Handle multiarch installation. ARM use Busybox modutils, so avoid any
45 # deps on kmod. SLITAZ_ARCH can have also custom post_install commands
46 if [ -f $root/etc/slitaz/slitaz.conf ]; then
47 . $root/etc/slitaz/slitaz.conf
48 case "$SLITAZ_ARCH" in
49 arm) DEPENDS="" ;;
50 esac
51 fi
53 install_module_headers()
54 {
55 local path
56 path=usr/src/linux-$KVERSION
57 mkdir -p $1/lib/modules/$KVERSION
58 ln -sf /$path $1/lib/modules/$KVERSION/build
59 install -D -m644 $src/Makefile \
60 $1/$path/Makefile
61 install -D -m644 $src/kernel/Makefile \
62 $1/$path/kernel/Makefile
63 install -D -m644 $src/.config \
64 $1/$path/.config
65 mkdir -p $1/$path/include
67 cp -a $src/include/* $1/$path/include/
68 rm -f $1/$path/include/Kbuild
70 # copy arch includes for external modules
71 mkdir -p $1/$path/arch/x86
72 cp -a $src/arch/x86/include $1/$path/arch/x86/
74 # copy files necessary for later builds, like nvidia and vmware
75 cp -a $src/Module.symvers $1/$path/Module.symvers
76 cp -a $src/scripts $1/$path
77 # fix permissions on scripts dir
78 chmod og-w -R $1/$path/scripts
79 mkdir -p $1/$path/.tmp_versions
81 mkdir -p $1/$path/arch/x86/kernel
82 cp -a $src/arch/x86/Makefile $1/$path/arch/x86/
83 cp -a $src/arch/x86/Makefile_32.cpu $1/$path/arch/x86/
84 cp -a $src/arch/x86/kernel/asm-offsets.s $1/$path/arch/x86/kernel/
86 # add headers for lirc package
87 mkdir -p $1/$path/drivers/media
88 ( cd $src/drivers/media ; find i2c -name '*.h' | cpio -o -H newc ) | \
89 ( cd $1/$path/drivers/media ; cpio -idmu )
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-core
111 cp -a $src/drivers/media/dvb-core/*.h $1/$path/drivers/media/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/i2c/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/usb/dvb-usb
132 cp -a $src/drivers/media/usb/dvb-usb/*.h $1/$path/drivers/media/usb/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/tuners
136 cp -a $src/drivers/media/tuners/*.h $1/$path/drivers/media/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
142 cp -a $src/fs/*.h $1/$path/fs/
144 # copy in Kconfig files
145 for i in $(find . -name "Kconfig*"); do
146 mkdir -p $1/$path/$(echo $i | sed 's|/Kconfig.*||')
147 cp -a $src/$i $1/$path/$i
148 done
150 chown -R root.root $1/$path
151 find $1/$path -type d -exec chmod 755 {} \;
152 # remove unneeded architectures
153 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}
154 }
156 # Rules to configure and make the package.
157 compile_rules()
158 {
159 if [ -f "/usr/share/boot/initrd" ]; then
160 cp /usr/share/boot/initrd initrd.cpio
161 fi
163 # Handle cross compilation
164 case "$ARCH" in
165 arm)
166 echo "Compiling: $ARCH Kernel"
167 make mrproper
168 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
169 cp -f $stuff/$ARCH/linux-arm.config .config
170 yes '' | make ARCH=$ARCH oldconfig
171 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
172 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
173 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
174 INSTALL_MOD_PATH=$DESTDIR modules_install &&
175 mkdir -p $DESTDIR/boot &&
176 cp -a arch/arm/boot/zImage \
177 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
178 #$stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
179 return 0 ;;
180 x86_64)
181 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
182 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
183 return 0 ;;
184 esac
186 # Check for Aufs and get source/patches if needed
187 echo "Checking for Aufs packages..."
188 AUFSVER=$(grep ^VERSION= $WOK/linux-aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g')
189 AUFSSRCDIR="$WOK/linux-aufs/source"
190 AUFSDIR="$AUFSSRCDIR/linux-aufs-${AUFSVER}"
191 if [ ! -d "$AUFSDIR" ]; then
192 [ ! -f "$SRC/aufs-${AUFSVER}.tar.bz2" ] && cook aufs --getsrc
193 mkdir -p $AUFSSRCDIR
194 echo "Extracting: aufs-${AUFSVER}.tar.bz2"
195 tar xjf $SRC/aufs-${AUFSVER}.tar.bz2 -C $AUFSSRCDIR/
196 ( cd $AUFSDIR ; [ -d fs ] || git checkout origin/aufs${VERSION%.*} )
197 fi
199 echo "cook:linux" > $command
201 echo "Copying Aufs files and patches..."
202 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
204 # Use fixed patchs from stuff
205 cp -a $AUFSDIR/aufs3-*.patch $stuff
207 # SliTaz db stuff
208 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz
209 mkdir -p $WOK/$PACKAGE/source/slitaz
210 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
211 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
212 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
214 # Apply patches
215 echo "Applying patches..."
216 while read patch_file; do
217 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
218 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
219 if [ -f done.$patch_file ]; then
220 echo "Skipping $patch_file" && continue
221 fi
222 echo "Apply $patch_file"
223 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
224 touch done.$patch_file
225 done <<EOT
226 $PACKAGE-diff.u
227 $PACKAGE-freeinitrd.u
228 $PACKAGE-subroot.u
229 $PACKAGE-romfs.u
230 $PACKAGE-tcp_stealth.u
231 $PACKAGE-efi.u
232 aufs3-base.patch
233 aufs3-standalone.patch
234 aufs3-loopback.patch
235 aufs3-mmap.patch
236 EOT
238 # Mrproper and lguest
239 echo "Make kernel proper and then build lguest..."
240 make mrproper
241 cd tools/lguest
242 make lguest || return 1
244 echo "Build usbip..."
245 cd $src/drivers/staging/usbip/userspace
246 ./autogen.sh
247 ./configure CFLAGS="$CFLAGS -Wno-error=uninitialized" \
248 --with-usbids-dir=/usr/share/misc \
249 --mandir=/usr/share/man $CONFIGURE_ARGS &&
250 make && make DESTDIR=$DESTDIR/usbip install || return 1
252 cd $src
254 #
255 # Arch x86_64: TODO have a real cross environment
256 #
257 if [ ! "$nox64" ]; then
258 echo "Compiling: x86_64 Kernel"
260 # Build bzImage64 without modules first
261 if [ ! "$nonomods" ]; then
262 [ -d $DESTDIR/linux64 ] || mkdir -p $DESTDIR/linux64 ||
263 return 1
264 cp -f $stuff/$PACKAGE-slitaz.config64 .config
265 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
266 echo -e "\n* Configure bzImage64 without modules...\n"
267 yes '' | make ARCH=x86_64 oldconfig
268 echo -e "\n* Building bzImage64 without modules...\n"
269 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
270 mv arch/x86/boot/bzImage $DESTDIR/linux64
271 mv System.map System.map-without-modules64
272 mv vmlinux vmlinux-without-modules64
273 mv .config config-without-modules64
274 fi
276 # Build bzImage64 with modules
277 cp -f $stuff/$PACKAGE-slitaz.config64 .config
278 echo -e "\n* Configure bzImage64 with modules...\n"
279 yes '' | make ARCH=x86_64 oldconfig
280 echo -e "\n* Building bzImage64 with modules...\n"
281 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
282 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
283 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
284 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
285 ln .config $WOK/$PACKAGE/source/slitaz/config64
286 [ -s arch/x86/boot/bzImage ] || return 1
287 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
288 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz64
289 KVERSION=$VERSION-slitaz64
290 install_module_headers $DESTDIR/linux64
291 ln System.map System.map-modules64
292 ln vmlinux vmlinux-modules64
293 ln Module.symvers Module.symvers-modules64
294 cp .config config-modules64
295 else
296 echo "* Skipping: x86_64 Kernel..."
297 fi
299 #
300 # Linux Arch i386 - GCC arch i486
301 #
302 echo "Compiling: i386 Kernel..."
304 # Build bzImage without modules first
305 if [ ! "$nonomods" ]; then
306 cp -f $stuff/$PACKAGE-slitaz.config .config
307 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
308 echo -e "\n* Configure bzImage without modules...\n"
309 yes '' | make ARCH=i386 oldconfig
310 echo -e "\n* Building bzImage without modules...\n"
311 make ARCH=i386 -j 4 bzImage || exit 1
312 [ -d $DESTDIR ] || mkdir -p $DESTDIR
313 mv arch/x86/boot/bzImage $DESTDIR
314 mv System.map System.map-without-modules
315 mv vmlinux vmlinux-without-modules
316 mv .config config-without-modules
317 fi
319 # Build bzImage with modules
320 cp -f $stuff/$PACKAGE-slitaz.config .config
321 echo -e "\n* Configure bzImage with modules...\n"
322 yes '' | make ARCH=i386 oldconfig
323 ln .config $WOK/$PACKAGE/source/slitaz/config
324 echo -e "\n* Building bzImage with modules...\n"
325 make ARCH=i386 -j 4 bzImage &&
326 make ARCH=i386 -j 4 modules &&
327 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
328 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
329 [ -s arch/x86/boot/bzImage ] || return 1
330 mkdir -p $DESTDIR/boot 2> /dev/null
331 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
332 KVERSION=$VERSION-slitaz
333 install_module_headers $DESTDIR
335 # Compress all modules.
336 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
337 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
338 else
339 return 1
340 fi
341 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
342 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
343 fi
344 ln System.map System.map-modules
345 ln vmlinux vmlinux-modules
346 ln Module.symvers Module.symvers-modules
347 cp .config config-modules
348 }
350 # Rules to gen a SliTaz package suitable for Tazpkg.
351 genpkg_rules()
352 {
353 case "$ARCH" in
354 arm)
355 echo "Packing: ARM Kernel"
356 cp -a $install/* $fs
357 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
358 return 0 ;;
359 x86_64)
360 echo "TODO: use default or custom x86_64 packing"
361 return 0 ;;
362 esac
364 export PACKAGE VERSION
365 local path
366 cp -a $install/boot $fs
368 # Compress all modules.
369 path=$fs/lib/modules/$VERSION-slitaz/kernel
370 mkdir -p $path
372 # Get the base modules
373 export src install
374 mkdir -p $WOK/$PACKAGE/source/tmp
375 # Warning stuff/list_modules.sh must find the generated modules.list
376 $stuff/list_modules.sh \
377 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
378 while read module; do
379 dir=$(dirname $module)
380 [ -d $path/$dir ] || mkdir -p $path/$dir
381 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
382 done < $WOK/$PACKAGE/source/tmp/modules.list
384 # Remove unresolved links
385 rm -f $fs/lib/modules/$VERSION-slitaz/build
386 rm -f $fs/lib/modules/$VERSION-slitaz/source
388 # We only need module.{order,builtin} because other map files are
389 # generated by depmod in post_install
390 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
391 $install/lib/modules/$VERSION-slitaz/modules.builtin \
392 $fs/lib/modules/$VERSION-slitaz
394 # Pack all packages with a kernel module
395 sed -i "/^$PACKAGE\$/d" $CACHE/broken 2>/dev/null || true
396 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt); do
397 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
398 cook ${i%/receipt}
399 done
401 # Check any module in kernel .config that's not added to a linux-* pkgs
402 # and remove aufs patches: we dont need them in HG wok.
403 $stuff/check_modules.sh
405 # Keep fixed patches !
406 #rm -f $stuff/aufs3-*
407 }
409 # Pre and post install commands for Tazpkg.
410 post_install()
411 {
412 chroot "$root/" depmod -a $VERSION-slitaz
414 # Handle multiarch installation
415 case "$SLITAZ_ARCH" in
416 arm)
417 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
418 echo "Modules: /lib/modules/$VERSION-slitaz"
419 return 0 ;;
420 esac
422 # GRUB stuff.
423 if [ -f "$1/boot/grub/menu.lst" ]; then
424 # Current root device
425 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
426 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
427 # Use device.map to find grub device number
428 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
429 "$1/boot/grub/device.map" | cut -f1 | sed "s/)$/.$grub_part)/g")"
431 # Add and clean kernel entries in case of upgrade for installed system.
432 if ! grep -q vmlinuz-$VERSION-slitaz "$1/boot/grub/menu.lst"; then
434 # Clean the old entry
435 # TODO: old vmlinuz file is removed but the entry is still there.
436 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
438 # Add the new entry
439 cat >> "$1/boot/grub/menu.lst" << EOT
441 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
442 $grub_dev
443 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
444 EOT
445 # Make it the default entry
446 last_entry=$(( $(grep -c '^title' "$1/boot/grub/menu.lst")-1 ))
447 sed -e "s/^default.*/default $last_entry/g" -i "$1/boot/grub/menu.lst"
448 fi
450 # Display information message.
451 cat <<EOT
453 ----
454 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
456 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
457 $grub_dev
458 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
459 ----
460 EOT
461 fi
462 true
463 }