wok view linux/receipt @ rev 17031

linux64: new module path (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Aug 17 09:56:09 2014 +0200 (2014-08-17)
parents 532076da08b9
children b9fafbaeb4c6
line source
1 # SliTaz package receipt.
3 PACKAGE="linux"
4 VERSION="3.2.53"
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="ftp://ftp.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 # Rules to configure and make the package.
48 compile_rules()
49 {
50 if [ -f "/usr/share/boot/initrd" ]; then
51 cp /usr/share/boot/initrd initrd.cpio
52 fi
54 # Handle cross compilation
55 case "$ARCH" in
56 arm)
57 echo "Compiling: $ARCH Kernel"
58 make mrproper
59 patch -Np1 < $stuff/$ARCH/linux-arm.patch || exit 1
60 cp -f $stuff/$ARCH/linux-arm.config .config
61 yes '' | make ARCH=$ARCH oldconfig
62 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- bzImage &&
63 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- modules &&
64 make ARCH=$ARCH CROSS_COMPILE=${HOST_SYSTEM}- \
65 INSTALL_MOD_PATH=$DESTDIR modules_install &&
66 mkdir -p $DESTDIR/boot &&
67 cp -a arch/arm/boot/zImage \
68 $DESTDIR/boot/linux-$VERSION-slitaz-$ARCH
69 #$stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
70 return 0 ;;
71 x86_64)
72 echo "TODO: Maybe use default ? But cross compile in x86_64 chroot"
73 echo "so we can remove the 64 build by uclibc-cross-compiler-x86_64"
74 return 0 ;;
75 esac
77 # Check for Aufs and get source/patches if needed
78 echo "Checking for Aufs packages..."
79 AUFSVER=$(grep ^VERSION= $WOK/aufs/receipt | cut -d "=" -f2 | sed -e 's/"//g')
80 AUFSDIR="$WOK/aufs/source/aufs-${AUFSVER}"
81 if [ ! -d "$AUFSDIR" ]; then
82 [ ! -f "$SRC/aufs-${AUFSVER}.tar.bz2" ] && cook aufs --getsrc
83 mkdir -p $WOK/aufs/source/
84 echo "Extracting: aufs-${AUFSVER}.tar.bz2"
85 tar xjf $SRC/aufs-${AUFSVER}.tar.bz2 -C $WOK/aufs/source/
86 fi
88 echo "cook:linux" > $command
90 echo "Copying Aufs files and patches..."
91 cp -a $AUFSDIR/Documentation $AUFSDIR/fs $AUFSDIR/include $src
92 cp -a $AUFSDIR/aufs3-*.patch $stuff
94 # SliTaz db stuff
95 [ -d $WOK/$PACKAGE/source/slitaz ] && rm -rf $WOK/$PACKAGE/source/slitaz
96 mkdir -p $WOK/$PACKAGE/source/slitaz
97 echo "$WGET_URL" > $WOK/$PACKAGE/source/slitaz/url
98 cp $stuff/gztazmod.sh $stuff/list_modules.sh $WOK/$PACKAGE/source/slitaz
99 cp $stuff/bootloader.sh $WOK/$PACKAGE/source/slitaz
101 # Apply patches
102 echo "Applying patches..."
103 while read patch_file; do
104 echo "$patch_file" >> $WOK/$PACKAGE/source/slitaz/patches
105 cp $stuff/$patch_file $WOK/$PACKAGE/source/slitaz
106 if [ -f done.$patch_file ]; then
107 echo "Skipping $patch_file" && continue
108 fi
109 echo "Apply $patch_file"
110 patch -p1 < $WOK/$PACKAGE/source/slitaz/$patch_file || return 1
111 touch done.$patch_file
112 done <<EOT
113 $PACKAGE-diff.u
114 $PACKAGE-header.u
115 $PACKAGE-freeinitrd.u
116 $PACKAGE-subroot.u
117 $PACKAGE-CVE-2013-2929.u
118 aufs3-base.patch
119 aufs3-standalone.patch
120 aufs3-loopback.patch
121 aufs3-mmap.patch
122 channel-negative-one-maxim.patch
123 mac80211.compat08082009.wl_frag+ack_v1.patch
124 EOT
126 # Mrproper and lguest
127 echo "Make kernel proper and then build lguest..."
128 make mrproper
129 cd Documentation/virtual/lguest
130 make lguest || return 1
131 cd $src
133 #
134 # Arch x86_64: TODO have a real cross environment
135 #
136 if [ ! "$nox64" ]; then
137 echo "Compiling: x86_64 Kernel"
139 # Build bzImage64 without modules first
140 if [ ! "$nonomods" ]; then
141 cp -f $stuff/$PACKAGE-slitaz.config64 .config
142 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
143 # We can't keep every driver in staging ???
144 sed -i -e 's/^CONFIG_RTL8192/#&/' \
145 -e 's/^CONFIG_R8187SE/#&/' \
146 -e 's/^CONFIG_RT2870/#&/' .config
147 echo -e "\n* Configure bzImage64 without modules...\n"
148 yes '' | make ARCH=x86_64 oldconfig
149 echo -e "\n* Building bzImage64 without modules...\n"
150 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
151 [ -d $DESTDIR ] || mkdir -p $DESTDIR/linux64
152 mv arch/x86/boot/bzImage $DESTDIR/linux64
153 mv System.map System.map-without-modules64
154 fi
156 # Build bzImage64 with modules
157 cp -f $stuff/$PACKAGE-slitaz.config64 .config
158 echo -e "\n* Configure bzImage64 with modules...\n"
159 yes '' | make ARCH=x86_64 oldconfig
160 echo -e "\n* Building bzImage64 with modules...\n"
161 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
162 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
163 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
164 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
165 ln .config $WOK/$PACKAGE/source/slitaz/config64
166 [ -s arch/x86/boot/bzImage ] || return 1
167 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
168 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz64
169 ln System.map System.map-modules64
170 ln Module.symvers Module.symvers-modules64
171 else
172 echo "* Skipping: x86_64 Kernel..."
173 fi
175 #
176 # Linux Arch i386 - GCC arch i486
177 #
178 echo "Compiling: i386 Kernel..."
180 # Build bzImage without modules first
181 if [ ! "$nonomods" ]; then
182 cp -f $stuff/$PACKAGE-slitaz.config .config
183 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
184 # We can't keep every driver in staging ???
185 sed -i -e 's/^CONFIG_RTL8192/#&/' \
186 -e 's/^CONFIG_R8187SE/#&/' \
187 -e 's/^CONFIG_RT2870/#&/' .config
188 echo -e "\n* Configure bzImage without modules...\n"
189 yes '' | make ARCH=i386 oldconfig
190 echo -e "\n* Building bzImage without modules...\n"
191 make ARCH=i386 -j 4 bzImage || exit 1
192 [ -d $DESTDIR ] || mkdir -p $DESTDIR
193 mv arch/x86/boot/bzImage $DESTDIR
194 mv System.map System.map-without-modules
195 fi
197 # Build bzImage with modules
198 cp -f $stuff/$PACKAGE-slitaz.config .config
199 echo -e "\n* Configure bzImage with modules...\n"
200 yes '' | make ARCH=i386 oldconfig
201 ln .config $WOK/$PACKAGE/source/slitaz/config
202 echo -e "\n* Building bzImage with modules...\n"
203 make ARCH=i386 -j 4 bzImage &&
204 make ARCH=i386 -j 4 modules &&
205 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
206 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
207 [ -s arch/x86/boot/bzImage ] || return 1
208 mkdir -p $DESTDIR/boot 2> /dev/null
209 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
211 # Compress all modules.
212 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
213 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
214 else
215 return 1
216 fi
217 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
218 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
219 fi
220 ln System.map System.map-modules
221 ln Module.symvers Module.symvers-modules
222 }
224 # Rules to gen a SliTaz package suitable for Tazpkg.
225 genpkg_rules()
226 {
227 case "$ARCH" in
228 arm)
229 echo "Packing: ARM Kernel"
230 cp -a $install/* $fs
231 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
232 return 0 ;;
233 x86_64)
234 echo "TODO: use default or custom x86_64 packing"
235 return 0 ;;
236 esac
238 export PACKAGE VERSION
239 local path
240 cp -a $install/boot $fs
242 # Compress all modules.
243 path=$fs/lib/modules/$VERSION-slitaz/kernel
244 mkdir -p $path
246 # Get the base modules
247 export src install
248 mkdir -p $WOK/$PACKAGE/source/tmp
249 # Warning stuff/list_modules.sh must find the generated modules.list
250 $stuff/list_modules.sh \
251 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
252 while read module; do
253 dir=$(dirname $module)
254 [ -d $path/$dir ] || mkdir -p $path/$dir
255 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
256 done < $WOK/$PACKAGE/source/tmp/modules.list
258 # Remove unresolved links
259 rm -f $fs/lib/modules/$VERSION-slitaz/build
260 rm -f $fs/lib/modules/$VERSION-slitaz/source
262 # We only need module.{order,builtin} because other map files are
263 # generated by depmod in post_install
264 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
265 $install/lib/modules/$VERSION-slitaz/modules.builtin \
266 $fs/lib/modules/$VERSION-slitaz
268 # Pack all packages with a kernel module
269 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt)
270 do
271 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
272 cook ${i%/receipt}
273 done
275 # Check any module in kernel .config that's not added to a linux-* pkgs
276 # and remove aufs patches: we dont need them in HG wok.
277 $stuff/check_modules.sh
278 rm -f $stuff/aufs3-*
279 }
281 # Pre and post install commands for Tazpkg.
282 post_install()
283 {
284 echo "Processing post-install commands..."
285 chroot "$root/" depmod -a $VERSION-slitaz
287 # Handle multiarch installation
288 case "$SLITAZ_ARCH" in
289 arm)
290 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
291 echo "Modules: /lib/modules/$VERSION-slitaz"
292 return 0 ;;
293 esac
295 # GRUB stuff.
296 if [ -f "$1/boot/grub/menu.lst" ]; then
297 # Current root device
298 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
299 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
300 # Use device.map to find grub device number
301 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
302 $1/boot/grub/device.map | cut -f1 | sed "s/)$/.$grub_part)/g")"
304 # Add and clean kernel entries in case of upgrade for installed system.
305 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
307 # Clean the old entry
308 # TODO: old vmlinuz file is removed but the entry is still there.
309 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
311 # Add the new entry
312 cat >> $1/boot/grub/menu.lst << EOT
314 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
315 $grub_dev
316 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
317 EOT
318 # Make it the default entry
319 last_entry=$(( $(grep -c '^title' $1/boot/grub/menu.lst)-1 ))
320 sed -e "s/^default.*/default $last_entry/g" -i $1/boot/grub/menu.lst
321 fi
323 # Display information message.
324 cat <<EOT
325 ----
326 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
328 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
329 $grub_dev
330 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
331 ----
332 EOT
333 fi
334 }