mkspec 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/sh
  2. #
  3. # Output a simple RPM spec file.
  4. # This version assumes a minimum of RPM 4.13
  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. set -eu
  12. output=$1
  13. mkdir -p "$(dirname "${output}")"
  14. exec >"${output}"
  15. if grep -q CONFIG_MODULES=y include/config/auto.conf; then
  16. echo '%define with_devel %{?_without_devel: 0} %{?!_without_devel: 1}'
  17. else
  18. echo '%define with_devel 0'
  19. fi
  20. # use %{debug_package} machinery to generate -debuginfo
  21. with_debuginfo_rpm=0
  22. # manually generate -debuginfo package
  23. with_debuginfo_manual=0
  24. # debuginfo package generation uses find-debuginfo.sh under the hood,
  25. # which only works on uncompressed modules that contain debuginfo
  26. if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf &&
  27. (! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) &&
  28. (! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then
  29. # If module signing is enabled (which may be required to boot with
  30. # lockdown enabled), the find-debuginfo.sh machinery cannot be used
  31. # because the signatures will be stripped off the modules. However, due
  32. # to an rpm bug in versions prior to 4.20.0
  33. #
  34. # https://github.com/rpm-software-management/rpm/issues/3057
  35. # https://github.com/rpm-software-management/rpm/commit/49f906998f3cf1f4152162ca61ac0869251c380f
  36. #
  37. # We cannot provide our own debuginfo package because it does not listen
  38. # to our custom files list, failing the build due to unpackaged files.
  39. # Manually generate the debug info package if using rpm 4.20.0. If not
  40. # using rpm 4.20.0, avoid generating a -debuginfo package altogether,
  41. # as it is not safe.
  42. if grep -q CONFIG_MODULE_SIG=y include/config/auto.conf; then
  43. rpm_ver_str=$(rpm --version 2>/dev/null)
  44. # Split the version on spaces
  45. IFS=' '
  46. set -- $rpm_ver_str
  47. if [ "${1:-}" = RPM -a "${2:-}" = version ]; then
  48. IFS=.
  49. set -- $3
  50. rpm_ver=$(( 1000000 * $1 + 10000 * $2 + 100 * $3 + ${4:-0} ))
  51. if [ "$rpm_ver" -ge 4200000 ]; then
  52. with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
  53. fi
  54. fi
  55. else
  56. with_debuginfo_rpm='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}'
  57. fi
  58. fi
  59. echo "%define with_debuginfo_manual $with_debuginfo_manual"
  60. echo "%define with_debuginfo_rpm $with_debuginfo_rpm"
  61. cat<<EOF
  62. %define ARCH ${ARCH}
  63. %define KERNELRELEASE ${KERNELRELEASE}
  64. %define pkg_release $("${srctree}/scripts/build-version")
  65. EOF
  66. cat "${srctree}/scripts/package/kernel.spec"
  67. # collect the user's name and email address for the changelog entry
  68. if [ "$(command -v git)" ]; then
  69. name=$(git config user.name) || true
  70. email=$(git config user.email) || true
  71. fi
  72. if [ ! "${name:+set}" ]; then
  73. name=${KBUILD_BUILD_USER:-$(id -nu)}
  74. fi
  75. if [ ! "${email:+set}" ]; then
  76. buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
  77. builduser=${KBUILD_BUILD_USER:-$(id -nu)}
  78. email="${builduser}@${buildhost}"
  79. fi
  80. cat << EOF
  81. %changelog
  82. * $(LC_ALL=C date +'%a %b %d %Y') ${name} <${email}>
  83. - Custom built Linux kernel.
  84. EOF