mkspec 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. PREBUILT=true
  14. else
  15. PREBUILT=false
  16. fi
  17. # starting to output the spec
  18. if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then
  19. PROVIDES=kernel-drm
  20. fi
  21. PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
  22. __KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
  23. echo "Name: kernel"
  24. echo "Summary: The Linux Kernel"
  25. echo "Version: $__KERNELRELEASE"
  26. # we need to determine the NEXT version number so that uname and
  27. # rpm -q will agree
  28. echo "Release: `. $srctree/scripts/mkversion`"
  29. echo "License: GPL"
  30. echo "Group: System Environment/Kernel"
  31. echo "Vendor: The Linux Community"
  32. echo "URL: http://www.kernel.org"
  33. if ! $PREBUILT; then
  34. echo "Source: kernel-$__KERNELRELEASE.tar.gz"
  35. fi
  36. echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
  37. echo "Provides: $PROVIDES"
  38. echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
  39. echo "%define debug_package %{nil}"
  40. echo ""
  41. echo "%description"
  42. echo "The Linux Kernel, the operating system core itself"
  43. echo ""
  44. echo "%package headers"
  45. echo "Summary: Header files for the Linux kernel for use by glibc"
  46. echo "Group: Development/System"
  47. echo "Obsoletes: kernel-headers"
  48. echo "Provides: kernel-headers = %{version}"
  49. echo "%description headers"
  50. echo "Kernel-headers includes the C header files that specify the interface"
  51. echo "between the Linux kernel and userspace libraries and programs. The"
  52. echo "header files define structures and constants that are needed for"
  53. echo "building most standard programs and are also needed for rebuilding the"
  54. echo "glibc package."
  55. echo ""
  56. echo "%package devel"
  57. echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
  58. echo "Group: System Environment/Kernel"
  59. echo "AutoReqProv: no"
  60. echo "%description -n kernel-devel"
  61. echo "This package provides kernel headers and makefiles sufficient to build modules"
  62. echo "against the $__KERNELRELEASE kernel package."
  63. echo ""
  64. if ! $PREBUILT; then
  65. echo "%prep"
  66. echo "%setup -q"
  67. echo ""
  68. fi
  69. echo "%build"
  70. if ! $PREBUILT; then
  71. echo "make clean && make %{?_smp_mflags}"
  72. echo ""
  73. fi
  74. echo "%install"
  75. echo 'KBUILD_IMAGE=$(make image_name)'
  76. echo "%ifarch ia64"
  77. echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules'
  78. echo "%else"
  79. echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
  80. echo "%endif"
  81. echo 'mkdir -p $RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
  82. echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= mod-fw= modules_install'
  83. echo 'INSTALL_FW_PATH=$RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
  84. echo 'make INSTALL_FW_PATH=$INSTALL_FW_PATH' firmware_install
  85. echo "%ifarch ia64"
  86. echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
  87. echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
  88. echo "%else"
  89. echo "%ifarch ppc64"
  90. echo "cp vmlinux arch/powerpc/boot"
  91. echo "cp arch/powerpc/boot/"'$KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
  92. echo "%else"
  93. echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
  94. echo "%endif"
  95. echo "%endif"
  96. echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr KBUILD_SRC= headers_install'
  97. echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
  98. echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
  99. echo "%ifnarch ppc64"
  100. echo 'bzip2 -9 --keep vmlinux'
  101. echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
  102. echo "%endif"
  103. if ! $PREBUILT; then
  104. echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/{build,source}"
  105. echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
  106. echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude=firmware --exclude .config.old --exclude .missing-syscalls.d\""
  107. echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
  108. echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
  109. echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
  110. echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
  111. fi
  112. echo ""
  113. echo "%clean"
  114. echo 'rm -rf $RPM_BUILD_ROOT'
  115. echo ""
  116. echo "%post"
  117. echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then"
  118. echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm"
  119. echo "cp /boot/System.map-$KERNELRELEASE /boot/.System.map-$KERNELRELEASE-rpm"
  120. echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE"
  121. echo "/sbin/installkernel $KERNELRELEASE /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
  122. echo "rm -f /boot/.vmlinuz-$KERNELRELEASE-rpm /boot/.System.map-$KERNELRELEASE-rpm"
  123. echo "fi"
  124. echo ""
  125. echo "%preun"
  126. echo "if [ -x /sbin/new-kernel-pkg ]; then"
  127. echo "new-kernel-pkg --remove $KERNELRELEASE --rminitrd --initrdfile=/boot/initramfs-$KERNELRELEASE.img"
  128. echo "fi"
  129. echo ""
  130. echo "%postun"
  131. echo "if [ -x /sbin/update-bootloader ]; then"
  132. echo "/sbin/update-bootloader --remove $KERNELRELEASE"
  133. echo "fi"
  134. echo ""
  135. echo "%files"
  136. echo '%defattr (-, root, root)'
  137. echo "/lib/modules/$KERNELRELEASE"
  138. echo "%exclude /lib/modules/$KERNELRELEASE/build"
  139. echo "%exclude /lib/modules/$KERNELRELEASE/source"
  140. echo "/lib/firmware/$KERNELRELEASE"
  141. echo "/boot/*"
  142. echo ""
  143. echo "%files headers"
  144. echo '%defattr (-, root, root)'
  145. echo "/usr/include"
  146. echo ""
  147. if ! $PREBUILT; then
  148. echo "%files devel"
  149. echo '%defattr (-, root, root)'
  150. echo "/usr/src/kernels/$KERNELRELEASE"
  151. echo "/lib/modules/$KERNELRELEASE/build"
  152. echo "/lib/modules/$KERNELRELEASE/source"
  153. echo ""
  154. fi