wok-next view linux/receipt @ rev 17346
Add ncdc
author | Paul Issott <paul@slitaz.org> |
---|---|
date | Fri Nov 07 20:26:01 2014 +0000 (2014-11-07) |
parents | 765487dd22da |
children | d06c0bbee2d8 |
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 $PACKAGE-romfs.u
119 aufs3-base.patch
120 aufs3-standalone.patch
121 aufs3-loopback.patch
122 aufs3-mmap.patch
123 channel-negative-one-maxim.patch
124 mac80211.compat08082009.wl_frag+ack_v1.patch
125 EOT
127 # Mrproper and lguest
128 echo "Make kernel proper and then build lguest..."
129 make mrproper
130 cd Documentation/virtual/lguest
131 make lguest || return 1
132 cd $src
134 #
135 # Arch x86_64: TODO have a real cross environment
136 #
137 if [ ! "$nox64" ]; then
138 echo "Compiling: x86_64 Kernel"
140 # Build bzImage64 without modules first
141 if [ ! "$nonomods" ]; then
142 cp -f $stuff/$PACKAGE-slitaz.config64 .config
143 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
144 # We can't keep every driver in staging ???
145 sed -i -e 's/^CONFIG_RTL8192/#&/' \
146 -e 's/^CONFIG_R8187SE/#&/' \
147 -e 's/^CONFIG_RT2870/#&/' .config
148 echo -e "\n* Configure bzImage64 without modules...\n"
149 yes '' | make ARCH=x86_64 oldconfig
150 echo -e "\n* Building bzImage64 without modules...\n"
151 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage || exit 1
152 [ -d $DESTDIR ] || mkdir -p $DESTDIR/linux64
153 mv arch/x86/boot/bzImage $DESTDIR/linux64
154 mv System.map System.map-without-modules64
155 fi
157 # Build bzImage64 with modules
158 cp -f $stuff/$PACKAGE-slitaz.config64 .config
159 echo -e "\n* Configure bzImage64 with modules...\n"
160 yes '' | make ARCH=x86_64 oldconfig
161 echo -e "\n* Building bzImage64 with modules...\n"
162 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- bzImage &&
163 make -j 4 ARCH=x86_64 CROSS_COMPILE=uclibc-x86_64- modules &&
164 make ARCH=x86_64 INSTALL_MOD_PATH=$DESTDIR/linux64 modules_install &&
165 make ARCH=x86_64 INSTALL_HDR_PATH=$DESTDIR/linux64/usr headers_install &&
166 ln .config $WOK/$PACKAGE/source/slitaz/config64
167 [ -s arch/x86/boot/bzImage ] || return 1
168 mkdir -p $DESTDIR/linux64/boot 2> /dev/null
169 mv arch/x86/boot/bzImage $DESTDIR/linux64/boot/vmlinuz-$VERSION-slitaz64
170 ln System.map System.map-modules64
171 ln Module.symvers Module.symvers-modules64
172 else
173 echo "* Skipping: x86_64 Kernel..."
174 fi
176 #
177 # Linux Arch i386 - GCC arch i486
178 #
179 echo "Compiling: i386 Kernel..."
181 # Build bzImage without modules first
182 if [ ! "$nonomods" ]; then
183 cp -f $stuff/$PACKAGE-slitaz.config .config
184 sed -i 's/CONFIG_MODULES=y/# CONFIG_MODULES is not set/' .config
185 # We can't keep every driver in staging ???
186 sed -i -e 's/^CONFIG_RTL8192/#&/' \
187 -e 's/^CONFIG_R8187SE/#&/' \
188 -e 's/^CONFIG_RT2870/#&/' .config
189 echo -e "\n* Configure bzImage without modules...\n"
190 yes '' | make ARCH=i386 oldconfig
191 echo -e "\n* Building bzImage without modules...\n"
192 make ARCH=i386 -j 4 bzImage || exit 1
193 [ -d $DESTDIR ] || mkdir -p $DESTDIR
194 mv arch/x86/boot/bzImage $DESTDIR
195 mv System.map System.map-without-modules
196 fi
198 # Build bzImage with modules
199 cp -f $stuff/$PACKAGE-slitaz.config .config
200 echo -e "\n* Configure bzImage with modules...\n"
201 yes '' | make ARCH=i386 oldconfig
202 ln .config $WOK/$PACKAGE/source/slitaz/config
203 echo -e "\n* Building bzImage with modules...\n"
204 make ARCH=i386 -j 4 bzImage &&
205 make ARCH=i386 -j 4 modules &&
206 make ARCH=i386 INSTALL_MOD_PATH=$DESTDIR modules_install &&
207 make ARCH=i386 INSTALL_HDR_PATH=$DESTDIR/usr headers_install &&
208 [ -s arch/x86/boot/bzImage ] || return 1
209 mkdir -p $DESTDIR/boot 2> /dev/null
210 mv arch/x86/boot/bzImage $DESTDIR/boot/vmlinuz-$VERSION-slitaz
212 # Compress all modules.
213 if [ -d "$DESTDIR/lib/modules/$VERSION-slitaz" ]; then
214 $stuff/gztazmod.sh $DESTDIR/lib/modules/$VERSION-slitaz
215 else
216 return 1
217 fi
218 if [ -d "$DESTDIR/linux64/lib/modules/$VERSION-slitaz64" ]; then
219 $stuff/gztazmod.sh $DESTDIR/linux64/lib/modules/$VERSION-slitaz64
220 fi
221 ln System.map System.map-modules
222 ln Module.symvers Module.symvers-modules
223 }
225 # Rules to gen a SliTaz package suitable for Tazpkg.
226 genpkg_rules()
227 {
228 case "$ARCH" in
229 arm)
230 echo "Packing: ARM Kernel"
231 cp -a $install/* $fs
232 rm -f $fs/lib/modules/*/build $fs/lib/modules/*/source
233 return 0 ;;
234 x86_64)
235 echo "TODO: use default or custom x86_64 packing"
236 return 0 ;;
237 esac
239 export PACKAGE VERSION
240 local path
241 cp -a $install/boot $fs
243 # Compress all modules.
244 path=$fs/lib/modules/$VERSION-slitaz/kernel
245 mkdir -p $path
247 # Get the base modules
248 export src install
249 mkdir -p $WOK/$PACKAGE/source/tmp
250 # Warning stuff/list_modules.sh must find the generated modules.list
251 $stuff/list_modules.sh \
252 $(cat $stuff/modules.list) > $WOK/$PACKAGE/source/tmp/modules.list
253 while read module; do
254 dir=$(dirname $module)
255 [ -d $path/$dir ] || mkdir -p $path/$dir
256 cp -a $install/lib/modules/$VERSION-slitaz/kernel/$module $path/$dir
257 done < $WOK/$PACKAGE/source/tmp/modules.list
259 # Remove unresolved links
260 rm -f $fs/lib/modules/$VERSION-slitaz/build
261 rm -f $fs/lib/modules/$VERSION-slitaz/source
263 # We only need module.{order,builtin} because other map files are
264 # generated by depmod in post_install
265 cp -a $install/lib/modules/$VERSION-slitaz/modules.order \
266 $install/lib/modules/$VERSION-slitaz/modules.builtin \
267 $fs/lib/modules/$VERSION-slitaz
269 # Pack all packages with a kernel module
270 for i in $(cd $WOK; grep -l '^WANTED="linux"' */receipt)
271 do
272 [ ! -d "$install/lib/modules/$VERSION-slitaz" ] && return 1
273 cook ${i%/receipt}
274 done
276 # Check any module in kernel .config that's not added to a linux-* pkgs
277 # and remove aufs patches: we dont need them in HG wok.
278 $stuff/check_modules.sh
279 rm -f $stuff/aufs3-*
280 }
282 # Pre and post install commands for Tazpkg.
283 post_install()
284 {
285 echo "Processing post-install commands..."
286 chroot "$root/" depmod -a $VERSION-slitaz
288 # Handle multiarch installation
289 case "$SLITAZ_ARCH" in
290 arm)
291 echo "Kernel : /boot/linux-$VERSION-slitaz-$ARCH"
292 echo "Modules: /lib/modules/$VERSION-slitaz"
293 return 0 ;;
294 esac
296 # GRUB stuff.
297 if [ -f "$1/boot/grub/menu.lst" ]; then
298 # Current root device
299 root_dev="/dev/$(lsblk | grep '/$'| grep -o '[a-z]d[a-z][0-9]*')"
300 grub_part="$(( $(echo $root_dev | grep -o '[0-9]*$')-1 ))"
301 # Use device.map to find grub device number
302 grub_dev="$(grep $(echo $root_dev | grep -o '^/dev/.d.' ) \
303 $1/boot/grub/device.map | cut -f1 | sed "s/)$/.$grub_part)/g")"
305 # Add and clean kernel entries in case of upgrade for installed system.
306 if ! grep -q vmlinuz-$VERSION-slitaz $1/boot/grub/menu.lst; then
308 # Clean the old entry
309 # TODO: old vmlinuz file is removed but the entry is still there.
310 # So grub error:15 when selected: http://bugs.slitaz.org/?id=74
312 # Add the new entry
313 cat >> $1/boot/grub/menu.lst << EOT
315 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
316 $grub_dev
317 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev quiet
318 EOT
319 # Make it the default entry
320 last_entry=$(( $(grep -c '^title' $1/boot/grub/menu.lst)-1 ))
321 sed -e "s/^default.*/default $last_entry/g" -i $1/boot/grub/menu.lst
322 fi
324 # Display information message.
325 cat <<EOT
326 ----
327 GRUB is installed, these tree lines must be in your /boot/grub/menu.lst:
329 title SliTaz GNU/Linux (Kernel $VERSION-slitaz)
330 $grub_dev
331 kernel /boot/vmlinuz-$VERSION-slitaz root=$root_dev
332 ----
333 EOT
334 fi
335 }