buildtar 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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}.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 -c9"
  27. file_ext=".gz"
  28. ;;
  29. tarbz2-pkg)
  30. compress="bzip2 -c9"
  31. file_ext=".bz2"
  32. ;;
  33. tarxz-pkg)
  34. compress="xz -c9"
  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. *)
  78. [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
  79. echo "" >&2
  80. echo '** ** ** WARNING ** ** **' >&2
  81. echo "" >&2
  82. echo "Your architecture did not define any architecture-dependent files" >&2
  83. echo "to be placed into the tarball. Please add those to ${0} ..." >&2
  84. echo "" >&2
  85. sleep 5
  86. ;;
  87. esac
  88. #
  89. # Create the tarball
  90. #
  91. (
  92. cd "${tmpdir}"
  93. opts=
  94. if tar --owner=root --group=root --help >/dev/null 2>&1; then
  95. opts="--owner=root --group=root"
  96. fi
  97. tar cf - . $opts | ${compress} > "${tarball}${file_ext}"
  98. )
  99. echo "Tarball successfully created in ${tarball}${file_ext}"
  100. exit 0