buildtar 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. #
  4. # buildtar 0.0.4
  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 -e
  13. #
  14. # Some variables and settings used throughout the script
  15. #
  16. tmpdir="${objtree}/tar-install"
  17. tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
  18. #
  19. # Figure out how to compress, if requested at all
  20. #
  21. case "${1}" in
  22. tar-pkg)
  23. opts=
  24. ;;
  25. targz-pkg)
  26. opts=--gzip
  27. tarball=${tarball}.gz
  28. ;;
  29. tarbz2-pkg)
  30. opts=--bzip2
  31. tarball=${tarball}.bz2
  32. ;;
  33. tarxz-pkg)
  34. opts=--xz
  35. tarball=${tarball}.xz
  36. ;;
  37. *)
  38. echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
  39. exit 1
  40. ;;
  41. esac
  42. #
  43. # Clean-up and re-create the temporary directory
  44. #
  45. rm -rf -- "${tmpdir}"
  46. mkdir -p -- "${tmpdir}/boot"
  47. dirs=boot
  48. #
  49. # Try to install modules
  50. #
  51. if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then
  52. make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install
  53. dirs="$dirs lib"
  54. fi
  55. #
  56. # Install basic kernel files
  57. #
  58. cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
  59. cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
  60. cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  61. #
  62. # Install arch-specific kernel image(s)
  63. #
  64. case "${ARCH}" in
  65. x86|i386|x86_64)
  66. [ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  67. ;;
  68. alpha)
  69. [ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  70. ;;
  71. parisc*)
  72. [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  73. [ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
  74. ;;
  75. mips)
  76. if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
  77. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  78. elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then
  79. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  80. elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then
  81. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  82. elif [ -f "${objtree}/vmlinux.32" ]; then
  83. cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  84. elif [ -f "${objtree}/vmlinux.64" ]; then
  85. cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  86. elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then
  87. cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  88. elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then
  89. cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  90. elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then
  91. cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  92. elif [ -f "${objtree}/vmlinux" ]; then
  93. cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  94. fi
  95. ;;
  96. arm64)
  97. for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo ; do
  98. if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then
  99. cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  100. break
  101. fi
  102. done
  103. ;;
  104. *)
  105. [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
  106. echo "" >&2
  107. echo '** ** ** WARNING ** ** **' >&2
  108. echo "" >&2
  109. echo "Your architecture did not define any architecture-dependent files" >&2
  110. echo "to be placed into the tarball. Please add those to ${0} ..." >&2
  111. echo "" >&2
  112. sleep 5
  113. ;;
  114. esac
  115. #
  116. # Create the tarball
  117. #
  118. if tar --owner=root --group=root --help >/dev/null 2>&1; then
  119. opts="$opts --owner=root --group=root"
  120. fi
  121. tar cf $tarball -C $tmpdir $opts $dirs
  122. echo "Tarball successfully created in $tarball"
  123. exit 0