mkspec 5.5 KB

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