mkspec 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/bin/sh
  2. #
  3. # Output a simple RPM spec file.
  4. # This version assumes a minimum of RPM 4.0.3.
  5. #
  6. # The only gothic bit here is redefining install_post to avoid
  7. # stripping the symbols from files in the kernel which we want
  8. #
  9. # Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
  10. #
  11. # how we were called determines which rpms we build and how we build them
  12. if [ "$1" = prebuilt ]; then
  13. S=DEL
  14. else
  15. S=
  16. fi
  17. if grep -q CONFIG_MODULES=y .config; then
  18. M=
  19. else
  20. M=DEL
  21. fi
  22. if grep -q CONFIG_DRM=y .config; then
  23. PROVIDES=kernel-drm
  24. fi
  25. PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
  26. __KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
  27. EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \
  28. --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
  29. --exclude=.config.old --exclude=.missing-syscalls.d"
  30. # We can label the here-doc lines for conditional output to the spec file
  31. #
  32. # Labels:
  33. # $S: this line is enabled only when building source package
  34. # $M: this line is enabled only when CONFIG_MODULES is enabled
  35. sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
  36. Name: kernel
  37. Summary: The Linux Kernel
  38. Version: $__KERNELRELEASE
  39. Release: $(cat .version 2>/dev/null || echo 1)
  40. License: GPL
  41. Group: System Environment/Kernel
  42. Vendor: The Linux Community
  43. URL: http://www.kernel.org
  44. $S Source: kernel-$__KERNELRELEASE.tar.gz
  45. Provides: $PROVIDES
  46. %define __spec_install_post /usr/lib/rpm/brp-compress || :
  47. %define debug_package %{nil}
  48. %description
  49. The Linux Kernel, the operating system core itself
  50. %package headers
  51. Summary: Header files for the Linux kernel for use by glibc
  52. Group: Development/System
  53. Obsoletes: kernel-headers
  54. Provides: kernel-headers = %{version}
  55. %description headers
  56. Kernel-headers includes the C header files that specify the interface
  57. between the Linux kernel and userspace libraries and programs. The
  58. header files define structures and constants that are needed for
  59. building most standard programs and are also needed for rebuilding the
  60. glibc package.
  61. $S$M %package devel
  62. $S$M Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel
  63. $S$M Group: System Environment/Kernel
  64. $S$M AutoReqProv: no
  65. $S$M %description -n kernel-devel
  66. $S$M This package provides kernel headers and makefiles sufficient to build modules
  67. $S$M against the $__KERNELRELEASE kernel package.
  68. $S$M
  69. $S %prep
  70. $S %setup -q
  71. $S
  72. $S %build
  73. $S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
  74. $S
  75. %install
  76. mkdir -p %{buildroot}/boot
  77. %ifarch ia64
  78. mkdir -p %{buildroot}/boot/efi
  79. cp \$(make image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
  80. ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/
  81. %else
  82. cp \$(make image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
  83. %endif
  84. $M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_install
  85. make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr KBUILD_SRC= headers_install
  86. cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
  87. cp .config %{buildroot}/boot/config-$KERNELRELEASE
  88. bzip2 -9 --keep vmlinux
  89. mv vmlinux.bz2 %{buildroot}/boot/vmlinux-$KERNELRELEASE.bz2
  90. $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/build
  91. $S$M rm -f %{buildroot}/lib/modules/$KERNELRELEASE/source
  92. $S$M mkdir -p %{buildroot}/usr/src/kernels/$KERNELRELEASE
  93. $S$M tar cf - $EXCLUDES . | tar xf - -C %{buildroot}/usr/src/kernels/$KERNELRELEASE
  94. $S$M cd %{buildroot}/lib/modules/$KERNELRELEASE
  95. $S$M ln -sf /usr/src/kernels/$KERNELRELEASE build
  96. $S$M ln -sf /usr/src/kernels/$KERNELRELEASE source
  97. %clean
  98. rm -rf %{buildroot}
  99. %post
  100. if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then
  101. cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm
  102. cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm
  103. rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE
  104. /sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
  105. rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm
  106. fi
  107. %preun
  108. if [ -x /sbin/new-kernel-pkg ]; then
  109. new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img
  110. elif [ -x /usr/bin/kernel-install ]; then
  111. kernel-install remove $KERNELRELEASE
  112. fi
  113. %postun
  114. if [ -x /sbin/update-bootloader ]; then
  115. /sbin/update-bootloader --remove $KERNELRELEASE
  116. fi
  117. %files
  118. %defattr (-, root, root)
  119. $M /lib/modules/$KERNELRELEASE
  120. $M %exclude /lib/modules/$KERNELRELEASE/build
  121. $M %exclude /lib/modules/$KERNELRELEASE/source
  122. /boot/*
  123. %files headers
  124. %defattr (-, root, root)
  125. /usr/include
  126. $S$M
  127. $S$M %files devel
  128. $S$M %defattr (-, root, root)
  129. $S$M /usr/src/kernels/$KERNELRELEASE
  130. $S$M /lib/modules/$KERNELRELEASE/build
  131. $S$M /lib/modules/$KERNELRELEASE/source
  132. EOF