buildtar 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/bin/sh
  2. #
  3. # buildtar 0.0.4
  4. #
  5. # (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
  6. #
  7. # This script is used to compile a tarball from the currently
  8. # prepared kernel. Based upon the builddeb script from
  9. # Wichert Akkerman <wichert@wiggy.net>.
  10. #
  11. set -e
  12. #
  13. # Some variables and settings used throughout the script
  14. #
  15. tmpdir="${objtree}/tar-install"
  16. tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
  17. #
  18. # Figure out how to compress, if requested at all
  19. #
  20. case "${1}" in
  21. tar-pkg)
  22. compress="cat"
  23. file_ext=""
  24. ;;
  25. targz-pkg)
  26. compress="gzip"
  27. file_ext=".gz"
  28. ;;
  29. tarbz2-pkg)
  30. compress="bzip2"
  31. file_ext=".bz2"
  32. ;;
  33. tarxz-pkg)
  34. compress="xz"
  35. file_ext=".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. #
  48. # Try to install modules
  49. #
  50. if grep -q '^CONFIG_MODULES=y' "${objtree}/.config"; then
  51. make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install
  52. fi
  53. #
  54. # Install basic kernel files
  55. #
  56. cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
  57. cp -v -- "${objtree}/.config" "${tmpdir}/boot/config-${KERNELRELEASE}"
  58. cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  59. #
  60. # Install arch-specific kernel image(s)
  61. #
  62. case "${ARCH}" in
  63. x86|i386|x86_64)
  64. [ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  65. ;;
  66. alpha)
  67. [ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  68. ;;
  69. parisc*)
  70. [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  71. [ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
  72. ;;
  73. vax)
  74. [ -f "${objtree}/vmlinux.SYS" ] && cp -v -- "${objtree}/vmlinux.SYS" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.SYS"
  75. [ -f "${objtree}/vmlinux.dsk" ] && cp -v -- "${objtree}/vmlinux.dsk" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.dsk"
  76. ;;
  77. mips)
  78. if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
  79. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  80. elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then
  81. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  82. elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then
  83. cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
  84. elif [ -f "${objtree}/vmlinux.32" ]; then
  85. cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  86. elif [ -f "${objtree}/vmlinux.64" ]; then
  87. cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  88. elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then
  89. cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  90. elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then
  91. cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  92. elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then
  93. cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  94. elif [ -f "${objtree}/vmlinux" ]; then
  95. cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
  96. fi
  97. ;;
  98. *)
  99. [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
  100. echo "" >&2
  101. echo '** ** ** WARNING ** ** **' >&2
  102. echo "" >&2
  103. echo "Your architecture did not define any architecture-dependent files" >&2
  104. echo "to be placed into the tarball. Please add those to ${0} ..." >&2
  105. echo "" >&2
  106. sleep 5
  107. ;;
  108. esac
  109. #
  110. # Create the tarball
  111. #
  112. (
  113. opts=
  114. if tar --owner=root --group=root --help >/dev/null 2>&1; then
  115. opts="--owner=root --group=root"
  116. fi
  117. tar cf - -C "$tmpdir" boot/ lib/ $opts | ${compress} > "${tarball}${file_ext}"
  118. )
  119. echo "Tarball successfully created in ${tarball}${file_ext}"
  120. exit 0