mkspec 4.8 KB

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