Robert Rosengren | 05640d0 | 2010-08-04 15:20:54 +0200 | [diff] [blame] | 1 | # |
| 2 | # Spec file originally created for Fedora, modified for Moblin Linux |
| 3 | # |
| 4 | |
| 5 | Summary: The Linux kernel (the core of the Linux operating system) |
| 6 | |
| 7 | |
| 8 | # For a stable, released kernel, released_kernel should be 1. For rawhide |
| 9 | # and/or a kernel built from an rc snapshot, released_kernel should |
| 10 | # be 0. |
| 11 | %define released_kernel 1 |
| 12 | |
| 13 | # Versions of various parts |
| 14 | |
| 15 | # base_sublevel is the kernel version we're starting with and patching |
| 16 | # on top of -- for example, 2.6.22-rc7 starts with a 2.6.21 base, |
| 17 | # which yields a base_sublevel of 21. |
| 18 | |
| 19 | %define base_sublevel 34 |
| 20 | |
| 21 | |
| 22 | ## If this is a released kernel ## |
| 23 | %if 0%{?released_kernel} |
| 24 | # Do we have a 2.6.21.y update to apply? |
| 25 | %define stable_update 0 |
| 26 | # Set rpm version accordingly |
| 27 | %if 0%{?stable_update} |
| 28 | %define stablerev .%{stable_update} |
| 29 | %endif |
| 30 | %define rpmversion 2.6.%{base_sublevel}%{?stablerev} |
| 31 | |
| 32 | ## The not-released-kernel case ## |
| 33 | %else |
| 34 | # The next upstream release sublevel (base_sublevel+1) |
| 35 | %define upstream_sublevel %(expr %{base_sublevel} + 1) |
| 36 | # The rc snapshot level |
| 37 | |
| 38 | %define rcrev 8 |
| 39 | |
| 40 | |
| 41 | %if 0%{?rcrev} |
| 42 | %define rctag ~rc%rcrev |
| 43 | %endif |
| 44 | |
| 45 | %if !0%{?rcrev} |
| 46 | %define rctag ~rc0 |
| 47 | %endif |
| 48 | |
| 49 | # Set rpm version accordingly |
| 50 | %define rpmversion 2.6.%{upstream_sublevel}%{?rctag} |
| 51 | %endif |
| 52 | |
| 53 | # The kernel tarball/base version |
| 54 | %define kversion 2.6.%{base_sublevel} |
| 55 | |
| 56 | %define make_target bzImage |
| 57 | |
| 58 | %define KVERREL %{version}-%{release} |
| 59 | %define hdrarch %_target_cpu |
| 60 | |
| 61 | %define all_x86 i386 i586 i686 %{ix86} |
| 62 | |
| 63 | %define all_arm arm %{arm} |
| 64 | |
| 65 | # Overrides for generic default options |
| 66 | %define all_arch_configs kernel-*.config |
| 67 | |
| 68 | # Per-arch tweaks |
| 69 | |
| 70 | %ifarch %{all_x86} |
| 71 | %define all_arch_configs kernel-*.config |
| 72 | %define image_install_path boot |
| 73 | %define hdrarch i386 |
| 74 | %define kernel_image arch/x86/boot/bzImage |
| 75 | %endif |
| 76 | |
| 77 | %ifarch x86_64 |
| 78 | %define all_arch_configs kernel-%{version}-x86_64*.config |
| 79 | %define image_install_path boot |
| 80 | %define kernel_image arch/x86/boot/bzImage |
| 81 | %endif |
| 82 | |
| 83 | %ifarch %{all_arm} |
| 84 | %define all_arch_configs kernel-*.config |
| 85 | %define image_install_path boot |
| 86 | %define kernel_image arch/arm/boot/zImage |
| 87 | %define make_target uImage |
| 88 | %endif |
| 89 | |
| 90 | %define oldconfig_target nonint_oldconfig |
| 91 | |
| 92 | # |
| 93 | # Packages that need to be installed before the kernel is, because the %post |
| 94 | # scripts use them. |
| 95 | # |
| 96 | %define kernel_prereq fileutils, module-init-tools, mkinitrd >= 6.0.39-1 |
| 97 | |
| 98 | # |
| 99 | # Disable debug info |
| 100 | # |
| 101 | %define debug_package %{nil} |
| 102 | |
| 103 | # |
| 104 | # This macro does requires, provides, conflicts, obsoletes for a kernel package. |
| 105 | # %%kernel_reqprovconf <subpackage> |
| 106 | # It uses any kernel_<subpackage>_conflicts and kernel_<subpackage>_obsoletes |
| 107 | # macros defined above. |
| 108 | # |
| 109 | %define kernel_reqprovconf \ |
| 110 | Provides: kernel = %{rpmversion}-%{release}\ |
| 111 | Provides: kernel-drm = 4.3.0\ |
| 112 | Provides: kernel-uname-r = %{KVERREL}%{?1:-%{1}}\ |
| 113 | Requires(pre): %{kernel_prereq}\ |
| 114 | %{?1:%{expand:%%{?kernel_%{1}_conflicts:Conflicts: %%{kernel_%{1}_conflicts}}}}\ |
| 115 | %{?1:%{expand:%%{?kernel_%{1}_obsoletes:Obsoletes: %%{kernel_%{1}_obsoletes}}}}\ |
| 116 | %{?1:%{expand:%%{?kernel_%{1}_provides:Provides: %%{kernel_%{1}_provides}}}}\ |
| 117 | # We can't let RPM do the dependencies automatic because it'll then pick up\ |
| 118 | # a correct but undesirable perl dependency from the module headers which\ |
| 119 | # isn't required for the kernel proper to function\ |
| 120 | AutoReq: no\ |
| 121 | AutoProv: yes\ |
| 122 | %{nil} |
| 123 | |
| 124 | Name: kernel%{?variant} |
| 125 | Group: System/Kernel |
| 126 | License: GPLv2 |
| 127 | URL: http://www.kernel.org/ |
| 128 | Version: %{rpmversion} |
| 129 | Release: 1 |
| 130 | |
| 131 | %kernel_reqprovconf |
| 132 | |
| 133 | # |
| 134 | # List the packages used during the kernel build |
| 135 | # |
| 136 | BuildRequires: module-init-tools, bash >= 2.03, sh-utils |
| 137 | BuildRequires: findutils, make >= 3.78 |
| 138 | #BuildRequires: linux-firmware |
| 139 | BuildRequires: elfutils-libelf-devel binutils-devel |
| 140 | BuildRequires: u-boot-tools |
| 141 | BuildRequires: fdupes |
| 142 | |
| 143 | Source0: linux-%{kversion}.tar.gz |
| 144 | Source100: kernel-rpmlintrc |
| 145 | |
| 146 | |
| 147 | # |
| 148 | # Reminder of the patch filename format: |
| 149 | # linux-<version it is supposed to be upstream>-<description-separated-with-dashes>.patch |
| 150 | # |
| 151 | |
| 152 | |
| 153 | # |
| 154 | # Stable patch - critical bugfixes |
| 155 | # |
| 156 | #Patch: patch-2.6.33.2.bz2 |
| 157 | |
| 158 | # |
| 159 | # STE: scripts for automatically listing and applying patches |
| 160 | # |
| 161 | %define ste_patch_archive ste-patches.tar.gz |
| 162 | %define ste_patches \ |
| 163 | %( \ |
| 164 | if [ -e %{_sourcedir}/%{ste_patch_archive} ] \ |
| 165 | then \ |
| 166 | tar -C %{_sourcedir} -xzf %{_sourcedir}/%{ste_patch_archive} \ |
| 167 | for i in `cd %{_sourcedir} && ls -1 *.patch.gz` \ |
| 168 | do \ |
| 169 | num=`echo $i | cut -d- -f1 | sed 's|^0*||g'` \ |
| 170 | num=$(($num-1)) \ |
| 171 | name=`echo $i` \ |
| 172 | echo 'Patch'$num':\ '$name \ |
| 173 | done \ |
| 174 | fi \ |
| 175 | ) |
| 176 | |
| 177 | %define ste_apply_patches \ |
| 178 | %( \ |
| 179 | if [ -e %{_sourcedir}/%{ste_patch_archive} ] \ |
| 180 | then \ |
| 181 | for i in `cd %{_sourcedir} && ls -1 *.patch.gz` \ |
| 182 | do \ |
| 183 | num=`echo $i | cut -d- -f1 | sed 's|^0*||g'` \ |
| 184 | num=$(($num-1)) \ |
| 185 | echo '%patch'$num' -p1'\ |
| 186 | # echo 'patch -i '%{_sourcedir}/$i' -p1 --verbose'\ |
| 187 | done \ |
| 188 | fi \ |
| 189 | ) |
| 190 | |
| 191 | %ste_patches |
| 192 | |
| 193 | |
| 194 | BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root |
| 195 | |
| 196 | %description |
| 197 | The kernel package contains the Linux kernel (vmlinuz), the core of any |
| 198 | Linux operating system. The kernel handles the basic functions |
| 199 | of the operating system: memory allocation, process allocation, device |
| 200 | input and output, etc. |
| 201 | |
| 202 | |
| 203 | # |
| 204 | # This macro creates a kernel-<subpackage>-devel package. |
| 205 | # %%kernel_devel_package <subpackage> <pretty-name> |
| 206 | # |
| 207 | %define kernel_devel_package() \ |
| 208 | %package %{?1:%{1}-}devel\ |
| 209 | Summary: Development package for building kernel modules to match the %{?2:%{2} }kernel\ |
| 210 | Group: System/Kernel\ |
| 211 | Provides: kernel%{?1:-%{1}}-devel = %{version}-%{release}\ |
| 212 | Provides: kernel-devel = %{version}-%{release}%{?1:-%{1}}\ |
| 213 | Provides: kernel-devel-uname-r = %{KVERREL}%{?1:-%{1}}\ |
| 214 | Requires: kernel%{?1:-%{1}} = %{version}-%{release}\ |
| 215 | AutoReqProv: no\ |
| 216 | Requires(pre): /usr/bin/find\ |
| 217 | %description -n kernel%{?variant}%{?1:-%{1}}-devel\ |
| 218 | This package provides kernel headers and makefiles sufficient to build modules\ |
| 219 | against the %{?2:%{2} }kernel package.\ |
| 220 | %{nil} |
| 221 | |
| 222 | # |
| 223 | # This macro creates a kernel-<subpackage> and its -devel too. |
| 224 | # %%define variant_summary The Linux kernel compiled for <configuration> |
| 225 | # %%kernel_variant_package [-n <pretty-name>] <subpackage> |
| 226 | # |
| 227 | %define kernel_variant_package(n:) \ |
| 228 | %package %1\ |
| 229 | Summary: %{variant_summary}\ |
| 230 | Group: System/Kernel\ |
| 231 | %kernel_reqprovconf\ |
| 232 | %{expand:%%kernel_devel_package %1 %{!?-n:%1}%{?-n:%{-n*}}}\ |
| 233 | %{nil} |
| 234 | |
| 235 | |
| 236 | # First the auxiliary packages of the main kernel package. |
| 237 | %kernel_devel_package |
| 238 | |
| 239 | %package -n perf |
| 240 | Summary: The 'perf' performance counter tool |
| 241 | Group: System/Performance |
| 242 | Obsoletes: oprofile <= 0.9.5 |
| 243 | %description -n perf |
| 244 | This package provides the "perf" tool that can be used to monitor performance counter events |
| 245 | as well as various kernel internal events. |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | # Now, each variant package. |
| 251 | |
| 252 | %define variant_summary Kernel for the ste u8500 |
| 253 | %kernel_variant_package u8500 |
| 254 | %description u8500 |
| 255 | This package contains the kernel optimized for the Nokia N900 device |
| 256 | |
| 257 | |
| 258 | %prep |
| 259 | # First we unpack the kernel tarball. |
| 260 | # If this isn't the first make prep, we use links to the existing clean tarball |
| 261 | # which speeds things up quite a bit. |
| 262 | |
| 263 | # Update to latest upstream. |
| 264 | %if 0%{?released_kernel} |
| 265 | %define vanillaversion 2.6.%{base_sublevel} |
| 266 | # released_kernel with stable_update available case |
| 267 | %if 0%{?stable_update} |
| 268 | %define vanillaversion 2.6.%{base_sublevel}.%{stable_update} |
| 269 | %endif |
| 270 | # non-released_kernel case |
| 271 | %else |
| 272 | %if 0%{?rcrev} |
| 273 | %define vanillaversion 2.6.%{upstream_sublevel}-rc%{rcrev} |
| 274 | %endif |
| 275 | %else |
| 276 | # pre-{base_sublevel+1}-rc1 case |
| 277 | %endif |
| 278 | |
| 279 | if [ ! -d kernel-%{kversion}/vanilla-%{vanillaversion} ]; then |
| 280 | # Ok, first time we do a make prep. |
| 281 | rm -f pax_global_header |
| 282 | %setup -q -n kernel-%{kversion} -c |
| 283 | mv linux-%{kversion} vanilla-%{vanillaversion} |
| 284 | cd vanilla-%{vanillaversion} |
| 285 | |
| 286 | |
| 287 | %if 0%{?rcrev} |
| 288 | # patch-2.6.%{upstream_sublevel}-rc%{rcrev}.bz2 |
| 289 | #%patch00 -p1 |
| 290 | %endif |
| 291 | |
| 292 | # |
| 293 | # Reminder of the patch filename format: |
| 294 | # linux-<version it is supposed to be upstream>-<description-separated-with-dashes>.patch |
| 295 | # |
| 296 | |
| 297 | |
| 298 | # |
| 299 | # Stable patch - critical bugfixes |
| 300 | # |
| 301 | |
| 302 | # |
| 303 | # STE: Applying all patches generated from script |
| 304 | # |
| 305 | %ste_apply_patches |
| 306 | # STE: Workaround chmod 644 on all headers, since patch dont like chmod'ing (?) |
| 307 | find . -name "*.h" -exec chmod 644 {} \; |
| 308 | # STE: Workaround end |
| 309 | |
| 310 | cd .. |
| 311 | |
| 312 | else |
| 313 | # We already have a vanilla dir. |
| 314 | cd kernel-%{kversion} |
| 315 | if [ -d linux-%{kversion} ]; then |
| 316 | # Just in case we ctrl-c'd a prep already |
| 317 | rm -rf deleteme |
| 318 | # Move away the stale away, and delete in background. |
| 319 | mv linux-%{kversion} deleteme |
| 320 | rm -rf deleteme & |
| 321 | fi |
| 322 | fi |
| 323 | |
| 324 | cp -rl vanilla-%{vanillaversion} linux-%{kversion} |
| 325 | |
| 326 | cd linux-%{kversion} |
| 327 | |
| 328 | # Any further pre-build tree manipulations happen here. |
| 329 | |
| 330 | # only deal with configs if we are going to build for the arch |
| 331 | |
| 332 | # get rid of unwanted files resulting from patch fuzz |
| 333 | find . \( -name "*.orig" -o -name "*~" \) -exec rm -f {} \; >/dev/null |
| 334 | |
| 335 | cd .. |
| 336 | |
| 337 | ### |
| 338 | ### build |
| 339 | ### |
| 340 | %build |
| 341 | |
| 342 | |
| 343 | cp_vmlinux() |
| 344 | { |
| 345 | eu-strip --remove-comment -o "$2" "$1" |
| 346 | } |
| 347 | |
| 348 | BuildKernel() { |
| 349 | MakeTarget=$1 |
| 350 | KernelImage=$2 |
| 351 | Flavour=$3 |
| 352 | InstallName=${4:-vmlinuz} |
| 353 | |
| 354 | # Pick the right config file for the kernel we're building |
| 355 | Config=kernel${Flavour:+-${Flavour}}.config |
| 356 | DevelDir=/usr/src/kernels/%{KVERREL}${Flavour:+-${Flavour}} |
| 357 | |
| 358 | # When the bootable image is just the ELF kernel, strip it. |
| 359 | # We already copy the unstripped file into the debuginfo package. |
| 360 | if [ "$KernelImage" = vmlinux ]; then |
| 361 | CopyKernel=cp_vmlinux |
| 362 | else |
| 363 | CopyKernel=cp |
| 364 | fi |
| 365 | |
| 366 | KernelVer=%{version}-%{release}${Flavour:+-${Flavour}} |
| 367 | echo BUILDING A KERNEL FOR ${Flavour} %{_target_cpu}... |
| 368 | |
| 369 | # make sure EXTRAVERSION says what we want it to say |
| 370 | perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{?stablerev}%{?rctag}-%{release}/" Makefile |
| 371 | # perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = %{?stablerev}%{?rctag}-%{release}${Flavour:+-${Flavour}}/" Makefile |
| 372 | |
| 373 | # and now to start the build process |
| 374 | |
| 375 | make -s mrproper |
| 376 | |
| 377 | # Set config |
| 378 | make %{?_smp_mflags} mop500$(DEBUG)_power_defconfig |
| 379 | # STE: Disable multibuffer and multitouch. |
Robert Marklund | a77c874 | 2010-08-18 13:22:28 +0200 | [diff] [blame] | 380 | scripts/config --file .config --enable DISPLAY_GENERIC_DSI_PRIMARY_AUTO_SYNC --enable DISPLAY_GENERIC_DSI_SECONDARY_AUTO_SYNC |
| 381 | # Does not exist in the 34 kernel yet |
| 382 | #scripts/config --file .config --disable U8500_TSC_MULTITOUCH |
| 383 | |
Robert Marklund | 9276a2f | 2010-08-25 14:30:02 +0200 | [diff] [blame] | 384 | # Enable pmem |
| 385 | scripts/config --file .config --enable CONFIG_ANDROID_PMEM |
| 386 | |
joakim | d6af4c6 | 2010-08-27 10:04:23 +0200 | [diff] [blame] | 387 | # Enable hwmem |
| 388 | scripts/config --file .config --enable CONFIG_HWMEM |
| 389 | |
Robert Rosengren | 05640d0 | 2010-08-04 15:20:54 +0200 | [diff] [blame] | 390 | # STE: Enable conf for external sd-cards. |
| 391 | scripts/config --file .config --enable LEVELSHIFTER_HREF_V1_PLUS |
| 392 | # STE: Enable g_multi USB gadget with RNDIS, CDC Serial and Storage configuration. |
| 393 | scripts/config --file .config --module CONFIG_USB_G_MULTI --enable CONFIG_USB_G_MULTI_RNDIS --disable USB_G_MULTI_CDC |
joakim | d6af4c6 | 2010-08-27 10:04:23 +0200 | [diff] [blame] | 394 | # STE: Enable CONFIG_MCDE_FB_AVOID_REALLOC to avoid reallocations. |
| 395 | scripts/config --file .config --enable CONFIG_MCDE_FB_AVOID_REALLOC |
| 396 | scripts/config --file .config --enable CONFIG_DISPLAY_GENERIC_DSI_PRIMARY_AUTO_SYNC |
Robert Rosengren | 05640d0 | 2010-08-04 15:20:54 +0200 | [diff] [blame] | 397 | |
| 398 | Arch="x86" |
| 399 | %ifarch %{all_arm} |
| 400 | Arch="arm" |
| 401 | %endif |
| 402 | echo USING ARCH=$Arch |
| 403 | |
| 404 | # Build |
| 405 | make %{?_smp_mflags} ARCH=$Arch $MakeTarget |
| 406 | make %{?_smp_mflags} ARCH=$Arch modules |
| 407 | |
| 408 | # STE: uImage placed for now in boot. |
| 409 | cp -f arch/arm/boot/uImage $RPM_BUILD_ROOT/boot/uImage-$KernelVer |
| 410 | chmod 755 $RPM_BUILD_ROOT/boot/uImage-$KernelVer |
| 411 | |
| 412 | |
| 413 | # Start installing the results |
| 414 | install -m 644 .config $RPM_BUILD_ROOT/boot/config-$KernelVer |
| 415 | install -m 644 System.map $RPM_BUILD_ROOT/boot/System.map-$KernelVer |
| 416 | touch $RPM_BUILD_ROOT/boot/initrd-$KernelVer.img |
| 417 | if [ -f arch/$Arch/boot/zImage.stub ]; then |
| 418 | cp arch/$Arch/boot/zImage.stub $RPM_BUILD_ROOT/boot/zImage.stub-$KernelVer || : |
| 419 | fi |
| 420 | $CopyKernel $KernelImage \ |
| 421 | $RPM_BUILD_ROOT/boot/$InstallName-$KernelVer |
| 422 | chmod 755 $RPM_BUILD_ROOT/boot/$InstallName-$KernelVer |
| 423 | |
| 424 | mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer |
| 425 | make ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT modules_install KERNELRELEASE=$KernelVer |
| 426 | %ifnarch %{all_arm} |
| 427 | make -s ARCH=$Arch INSTALL_MOD_PATH=$RPM_BUILD_ROOT vdso_install KERNELRELEASE=$KernelVer |
| 428 | %endif |
| 429 | |
| 430 | # And save the headers/makefiles etc for building modules against |
| 431 | # |
| 432 | # This all looks scary, but the end result is supposed to be: |
| 433 | # * all arch relevant include/ files |
| 434 | # * all Makefile/Kconfig files |
| 435 | # * all script/ files |
| 436 | |
| 437 | rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 438 | rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/source |
| 439 | mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 440 | (cd $RPM_BUILD_ROOT/lib/modules/$KernelVer ; ln -s build source) |
| 441 | # dirs for additional modules per module-init-tools, kbuild/modules.txt |
| 442 | # first copy everything |
| 443 | cp --parents `find -type f -name "Makefile*" -o -name "Kconfig*"` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 444 | cp Module.symvers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 445 | cp System.map $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 446 | if [ -s Module.markers ]; then |
| 447 | cp Module.markers $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 448 | fi |
| 449 | # then drop all but the needed Makefiles/Kconfig files |
| 450 | rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Documentation |
| 451 | rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts |
| 452 | rm -rf $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include |
| 453 | cp .config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 454 | cp -a scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 455 | if [ -d arch/%{_arch}/scripts ]; then |
| 456 | cp -a arch/%{_arch}/scripts $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch} || : |
| 457 | fi |
| 458 | if [ -f arch/%{_arch}/*lds ]; then |
| 459 | cp -a arch/%{_arch}/*lds $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/%{_arch}/ || : |
| 460 | fi |
| 461 | rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*.o |
| 462 | rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/scripts/*/*.o |
| 463 | cp -a --parents arch/%{_arch}/include $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 464 | if [ "$Flavour" = u8500 ]; then |
| 465 | # U8500 specific include files |
| 466 | cp -a --parents arch/arm/mach-ux500/include $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 467 | cp -a --parents arch/arm/plat-nomadik/include $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 468 | fi |
| 469 | mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include |
| 470 | cd include |
| 471 | cp -a acpi asm-generic config crypto drm generated keys linux math-emu media mtd net pcmcia rdma rxrpc scsi sound video trace $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include |
| 472 | #cp -a `readlink asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include |
| 473 | # While arch/powerpc/include/asm is still a symlink to the old |
| 474 | # include/asm-ppc{64,} directory, include that in kernel-devel too. |
| 475 | if [ "$Arch" = "powerpc" -a -r ../arch/powerpc/include/asm ]; then |
| 476 | cp -a `readlink ../arch/powerpc/include/asm` $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include |
| 477 | mkdir -p $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/$Arch/include |
| 478 | pushd $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/arch/$Arch/include |
| 479 | ln -sf ../../../include/asm-ppc* asm |
| 480 | popd |
| 481 | fi |
| 482 | |
| 483 | # Find and remove .gitignore |
| 484 | find $RPM_BUILD_ROOT/lib/modules/$KernelVer/build -name .gitignore | xargs --no-run-if-empty rm -f |
| 485 | |
| 486 | # Make sure the Makefile and version.h have a matching timestamp so that |
| 487 | # external modules can be built |
| 488 | touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/Makefile $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/linux/version.h |
| 489 | touch -r $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/.config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/generated/autoconf.h |
| 490 | # Copy .config to include/config/auto.conf so "make prepare" is unnecessary. |
| 491 | cp $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/.config $RPM_BUILD_ROOT/lib/modules/$KernelVer/build/include/config/auto.conf |
| 492 | cd .. |
| 493 | |
| 494 | # |
| 495 | # save the vmlinux file for kernel debugging into the kernel-debuginfo rpm |
| 496 | # |
| 497 | # cp vmlinux $RPM_BUILD_ROOT/lib/modules/$KernelVer |
| 498 | |
| 499 | find $RPM_BUILD_ROOT/lib/modules/$KernelVer -name "*.ko" -type f >modnames |
| 500 | |
| 501 | # mark modules executable so that strip-to-file can strip them |
| 502 | xargs --no-run-if-empty chmod u+x < modnames |
| 503 | |
| 504 | # Generate a list of modules for block and networking. |
| 505 | |
| 506 | fgrep /drivers/ modnames | xargs --no-run-if-empty nm -upA | |
| 507 | sed -n 's,^.*/\([^/]*\.ko\): *U \(.*\)$,\1 \2,p' > drivers.undef |
| 508 | |
| 509 | collect_modules_list() |
| 510 | { |
| 511 | sed -r -n -e "s/^([^ ]+) \\.?($2)\$/\\1/p" drivers.undef | |
| 512 | LC_ALL=C sort -u > $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.$1 |
| 513 | } |
| 514 | |
| 515 | collect_modules_list networking \ |
| 516 | 'register_netdev|ieee80211_register_hw|usbnet_probe' |
| 517 | collect_modules_list block \ |
| 518 | 'ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans' |
| 519 | |
| 520 | # remove files that will be auto generated by depmod at rpm -i time |
| 521 | for i in alias ccwmap dep ieee1394map inputmap isapnpmap ofmap pcimap seriomap symbols usbmap |
| 522 | do |
| 523 | rm -f $RPM_BUILD_ROOT/lib/modules/$KernelVer/modules.$i |
| 524 | done |
| 525 | |
| 526 | # Move the devel headers out of the root file system |
| 527 | mkdir -p $RPM_BUILD_ROOT/usr/src/kernels |
| 528 | mv $RPM_BUILD_ROOT/lib/modules/$KernelVer/build $RPM_BUILD_ROOT/$DevelDir |
| 529 | ln -sf ../../..$DevelDir $RPM_BUILD_ROOT/lib/modules/$KernelVer/build |
| 530 | |
| 531 | # Last but not least, remove few kernel dupes.. |
| 532 | %fdupes $RPM_BUILD_ROOT/$DevelDir |
| 533 | } |
| 534 | |
| 535 | |
| 536 | ### |
| 537 | # DO it... |
| 538 | ### |
| 539 | |
| 540 | # prepare directories |
| 541 | rm -rf $RPM_BUILD_ROOT |
| 542 | mkdir -p $RPM_BUILD_ROOT/boot |
| 543 | |
| 544 | cd linux-%{kversion} |
| 545 | BuildKernel %make_target %kernel_image u8500 |
| 546 | |
| 547 | ### |
| 548 | ### install |
| 549 | ### |
| 550 | |
| 551 | %define install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\ |
| 552 | %%install |
| 553 | |
| 554 | %install |
| 555 | |
| 556 | # NOTE - Linux Kernel already installed in build section. Now only installing perf tool. |
| 557 | cd linux-%{kversion} |
| 558 | |
| 559 | |
| 560 | cd tools/perf |
| 561 | make DESTDIR=$RPM_BUILD_ROOT install |
| 562 | mkdir -p $RPM_BUILD_ROOT/usr/bin/ |
| 563 | mkdir -p $RPM_BUILD_ROOT/usr/libexec/ |
| 564 | mv $RPM_BUILD_ROOT/bin/* $RPM_BUILD_ROOT/usr/bin/ |
| 565 | mv $RPM_BUILD_ROOT/libexec/* $RPM_BUILD_ROOT/usr/libexec/ |
| 566 | |
| 567 | rm -rf $RPM_BUILD_ROOT/lib/firmware |
| 568 | |
| 569 | %fdupes $RPM_BUILD_ROOT/usr/libexec/ |
| 570 | |
| 571 | |
| 572 | |
| 573 | ### |
| 574 | ### clean |
| 575 | ### |
| 576 | |
| 577 | %clean |
| 578 | rm -rf $RPM_BUILD_ROOT |
| 579 | |
| 580 | ### |
| 581 | ### scripts |
| 582 | ### |
| 583 | |
| 584 | # |
| 585 | # This macro defines a %%post script for a kernel*-devel package. |
| 586 | # %%kernel_devel_post <subpackage> |
| 587 | # |
| 588 | %define kernel_devel_post() \ |
| 589 | %{expand:%%post %{?1:%{1}-}devel}\ |
| 590 | if [ -f /etc/sysconfig/kernel ]\ |
| 591 | then\ |
| 592 | . /etc/sysconfig/kernel || exit $?\ |
| 593 | fi\ |
| 594 | if [ "$HARDLINK" != "no" -a -x /usr/sbin/hardlink ]\ |
| 595 | then\ |
| 596 | (cd /usr/src/kernels/%{KVERREL}%{?1:-%{1}} &&\ |
| 597 | /usr/bin/find . -type f | while read f; do\ |
| 598 | hardlink -c /usr/src/kernels/*.fc*.*/$f $f\ |
| 599 | done)\ |
| 600 | fi\ |
| 601 | %{nil} |
| 602 | |
| 603 | # This macro defines a %%posttrans script for a kernel package. |
| 604 | # %%kernel_variant_posttrans [-v <subpackage>] [-s <s> -r <r>] <mkinitrd-args> |
| 605 | # More text can follow to go at the end of this variant's %%post. |
| 606 | # |
| 607 | %define kernel_variant_posttrans(s:r:v:) \ |
| 608 | %{expand:%%posttrans %{?-v*}}\ |
| 609 | /sbin/new-kernel-pkg --package kernel%{?-v:-%{-v*}} --rpmposttrans %{KVERREL}%{?-v:-%{-v*}} || exit $?\ |
| 610 | %{nil} |
| 611 | |
| 612 | # |
| 613 | # This macro defines a %%post script for a kernel package and its devel package. |
| 614 | # %%kernel_variant_post [-v <subpackage>] [-s <s> -r <r>] <mkinitrd-args> |
| 615 | # More text can follow to go at the end of this variant's %%post. |
| 616 | # |
| 617 | %define kernel_variant_post(s:r:v:) \ |
| 618 | %{expand:%%kernel_devel_post %{?-v*}}\ |
| 619 | %{expand:%%kernel_variant_posttrans %{?-v*}}\ |
| 620 | %{expand:%%post %{?-v*}}\ |
| 621 | %{-s:\ |
| 622 | if [ `uname -i` == "x86_64" -o `uname -i` == "i386" ] &&\ |
| 623 | [ -f /etc/sysconfig/kernel ]; then\ |
| 624 | /bin/sed -i -e 's/^DEFAULTKERNEL=%{-s*}$/DEFAULTKERNEL=%{-r*}/' /etc/sysconfig/kernel || exit $?\ |
| 625 | fi}\ |
| 626 | # Added workaround for kernel modules built in a chroot environment\ |
| 627 | # where modprobe fails \ |
| 628 | if [ ! -d /lib/modules/`uname -r`/kernel ]; then \ |
| 629 | ln -sf /lib/modules/%{KVERREL}%{?-v:-%{-v*}} /lib/modules/`uname -r`\ |
| 630 | fi \ |
| 631 | /sbin/new-kernel-pkg --package kernel%{?-v:-%{-v*}} --mkinitrd --depmod --install %{*} %{KVERREL}%{?-v:-%{-v*}} || exit $?\ |
| 632 | %{nil} |
| 633 | |
| 634 | # |
| 635 | # This macro defines a %%preun script for a kernel package. |
| 636 | # %%kernel_variant_preun <subpackage> |
| 637 | # |
| 638 | %define kernel_variant_preun() \ |
| 639 | %{expand:%%preun %{?1}} \ |
| 640 | /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}%{?1:-%{1}} || exit $? \ |
| 641 | %{nil} |
| 642 | |
| 643 | |
| 644 | %kernel_variant_preun u8500 |
| 645 | %kernel_variant_post -v u8500 |
| 646 | |
| 647 | if [ -x /sbin/ldconfig ] |
| 648 | then |
| 649 | /sbin/ldconfig -X || exit $? |
| 650 | fi |
| 651 | |
| 652 | ### |
| 653 | ### file lists |
| 654 | ### |
| 655 | |
| 656 | |
| 657 | |
| 658 | # This is %{image_install_path} on an arch where that includes ELF files, |
| 659 | # or empty otherwise. |
| 660 | %define elf_image_install_path %{?kernel_image_elf:%{image_install_path}} |
| 661 | |
| 662 | # |
| 663 | # This macro defines the %%files sections for a kernel package |
| 664 | # and its devel packages. |
| 665 | # %%kernel_variant_files [-k vmlinux] [-a <extra-files-glob>] [-e <extra-nonbinary>] <condition> <subpackage> |
| 666 | # |
| 667 | %define kernel_variant_files(a:e:k:) \ |
| 668 | %if %{1}\ |
| 669 | %{expand:%%files %{?2}}\ |
| 670 | %defattr(-,root,root)\ |
| 671 | /boot/%{?-k:%{-k*}}%{!?-k:vmlinuz}-%{KVERREL}%{?2:-%{2}}\ |
| 672 | /boot/uImage-%{KVERREL}%{?2:-%{2}}\ |
| 673 | /boot/System.map-%{KVERREL}%{?2:-%{2}}\ |
| 674 | #/boot/symvers-%{KVERREL}%{?2:-%{2}}.gz\ |
| 675 | /boot/config-%{KVERREL}%{?2:-%{2}}\ |
| 676 | %{?-a:%{-a*}}\ |
| 677 | %dir /lib/modules/%{KVERREL}%{?2:-%{2}}\ |
| 678 | /lib/modules/%{KVERREL}%{?2:-%{2}}/kernel\ |
| 679 | /lib/modules/%{KVERREL}%{?2:-%{2}}/build\ |
| 680 | /lib/modules/%{KVERREL}%{?2:-%{2}}/source\ |
| 681 | %ifnarch %{all_arm}\ |
| 682 | /lib/modules/%{KVERREL}%{?2:-%{2}}/vdso\ |
| 683 | %endif\ |
| 684 | /lib/modules/%{KVERREL}%{?2:-%{2}}/modules.block\ |
| 685 | /lib/modules/%{KVERREL}%{?2:-%{2}}/modules.dep.bin\ |
| 686 | /lib/modules/%{KVERREL}%{?2:-%{2}}/modules.alias.bin\ |
| 687 | /lib/modules/%{KVERREL}%{?2:-%{2}}/modules.symbols.bin\ |
| 688 | /lib/modules/%{KVERREL}%{?2:-%{2}}/modules.networking\ |
| 689 | /lib/modules/%{KVERREL}%{?2:-%{2}}/modules.order\ |
| 690 | /lib/modules/%{KVERREL}%{?2:-%{2}}/modules.builtin* \ |
| 691 | %ghost /boot/initrd-%{KVERREL}%{?2:-%{2}}.img\ |
| 692 | %{?-e:%{-e*}}\ |
| 693 | %{expand:%%files %{?2:%{2}-}devel}\ |
| 694 | %defattr(-,root,root)\ |
| 695 | %verify(not mtime) /usr/src/kernels/%{KVERREL}%{?2:-%{2}}\ |
| 696 | %endif\ |
| 697 | %{nil} |
| 698 | |
| 699 | |
| 700 | %files -n perf |
| 701 | %defattr(-,root,root) |
| 702 | /usr/bin/perf |
| 703 | /usr/libexec/perf-core/ |
| 704 | |
| 705 | |
| 706 | %kernel_variant_files 1 u8500 |
| 707 | |
| 708 | |
| 709 | %changelog |
| 710 | * Mon Jul 5 2010 Olle Trรคnk <olle.trank@stericsson.com> - 2.6.34 |
| 711 | - Added USB Gadget Multi (g_multi.ko) support. |
| 712 | * Fri Jul 2 2010 Robert Rosengren <robert.rosengren@stericsson.com> - 2.6.34 |
| 713 | - Solved rpmlint errors and few warnings. |
| 714 | * Tue Jun 29 2010 Robert Rosengren <robert.rosengren@stericsson.com> - 2.6.34 |
| 715 | - Turned STE changes into patches on vanilla kernel instead of one package. |
| 716 | * Tue Jun 8 2010 Robert Rosengren <robert.rosengren@stericsson.com> - 2.6.34 |
| 717 | - Upgraded to STE Kernel version 2.6.34. |
| 718 | * Mon May 17 2010 Robert Rosengren <robert.rosengren@stericsson.com> - 2.6.29 |
| 719 | - Initial STE version of 2.6.29 kernel, spec file based on MeeGo. |