buildtar 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # buildtar 0.0.5
  5. #
  6. # (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
  7. #
  8. # This script is used to compile a tarball from the currently
  9. # prepared kernel. Based upon the builddeb script from
  10. # Wichert Akkerman <wichert@wiggy.net>.
  11. #
  12. set -eu
  13. #
  14. # Some variables and settings used throughout the script
  15. #
  16. tmpdir=$1
  17. #
  18. # Clean-up and re-create the temporary directory
  19. #
  20. rm -rf -- "${tmpdir}"
  21. mkdir -p -- "${tmpdir}/boot"
  22. #
  23. # Try to install dtbs
  24. #
  25. if grep -q '^CONFIG_OF_EARLY_FLATTREE=y' include/config/auto.conf; then
  26. # Only some architectures with OF support have this target
  27. if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
  28. $MAKE ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_DTBS_PATH="${tmpdir}/boot/dtbs/${KERNELRELEASE}" dtbs_install
  29. fi
  30. fi
  31. #
  32. # Install modules
  33. #
  34. make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install
  35. #
  36. # Install basic kernel files
  37. #
  38. cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
  39. cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
  40. cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  41. #
  42. # Install arch-specific kernel image(s)
  43. #
  44. # Note:
  45. # mips and arm64 copy the first image found. This may not produce the desired
  46. # outcome because it may pick up a stale file remaining in the build tree.
  47. #
  48. case "${ARCH}" in
  49. alpha)
  50. cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  51. ;;
  52. parisc*)
  53. cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  54. [ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
  55. ;;
  56. mips)
  57. # Please note the following code may copy a stale file.
  58. if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
  59. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  60. elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then
  61. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  62. elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then
  63. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  64. elif [ -f "${objtree}/vmlinux.32" ]; then
  65. cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  66. elif [ -f "${objtree}/vmlinux.64" ]; then
  67. cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  68. elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then
  69. cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  70. elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then
  71. cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  72. elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then
  73. cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  74. elif [ -f "${objtree}/vmlinux" ]; then
  75. cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  76. fi
  77. ;;
  78. arm64)
  79. # Please note the following code may copy a stale file.
  80. for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo vmlinuz.efi ; do
  81. if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then
  82. cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  83. break
  84. fi
  85. done
  86. ;;
  87. riscv)
  88. case "${KBUILD_IMAGE##*/}" in
  89. Image.*|vmlinuz.efi)
  90. cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}";;
  91. *)
  92. cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}";;
  93. esac
  94. ;;
  95. *)
  96. cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  97. ;;
  98. esac