2005-05-24 13:27:37 +04:00
#!/bin/sh
#
2006-01-01 16:23:47 +03:00
# buildtar 0.0.4
2005-05-24 13:27:37 +04:00
#
2006-01-01 16:23:47 +03:00
# (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
2005-05-24 13:27:37 +04:00
#
# This script is used to compile a tarball from the currently
# prepared kernel. Based upon the builddeb script from
# Wichert Akkerman <wichert@wiggy.net>.
#
set -e
#
# Some variables and settings used throughout the script
#
tmpdir="${objtree}/tar-install"
2013-03-06 12:05:47 +04:00
tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
2005-05-24 13:27:37 +04:00
#
# Figure out how to compress, if requested at all
#
case "${1}" in
tar-pkg)
compress="cat"
file_ext=""
;;
targz-pkg)
2012-09-08 23:47:59 +04:00
compress="gzip"
2005-05-24 13:27:37 +04:00
file_ext=".gz"
;;
tarbz2-pkg)
2012-09-08 23:47:59 +04:00
compress="bzip2"
2005-05-24 13:27:37 +04:00
file_ext=".bz2"
;;
2011-01-30 14:18:51 +03:00
tarxz-pkg)
2012-09-08 23:47:59 +04:00
compress="xz"
2011-01-30 14:18:51 +03:00
file_ext=".xz"
;;
2005-05-24 13:27:37 +04:00
*)
echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
exit 1
;;
esac
#
# Clean-up and re-create the temporary directory
#
rm -rf -- "${tmpdir}"
mkdir -p -- "${tmpdir}/boot"
#
# Try to install modules
#
2006-01-01 16:23:47 +03:00
if grep -q '^CONFIG_MODULES=y' "${objtree}/.config"; then
make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install
2005-05-24 13:27:37 +04:00
fi
#
# Install basic kernel files
#
2006-01-01 16:23:47 +03:00
cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
cp -v -- "${objtree}/.config" "${tmpdir}/boot/config-${KERNELRELEASE}"
cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
2005-05-24 13:27:37 +04:00
#
# Install arch-specific kernel image(s)
#
case "${ARCH}" in
2008-01-22 03:21:11 +03:00
x86|i386|x86_64)
[ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
2005-05-24 13:27:37 +04:00
;;
alpha)
2006-01-01 16:23:47 +03:00
[ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
2005-05-24 13:27:37 +04:00
;;
2009-02-19 01:12:21 +03:00
parisc*)
[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
[ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
;;
2005-05-24 13:27:37 +04:00
vax)
2006-01-01 16:23:47 +03:00
[ -f "${objtree}/vmlinux.SYS" ] && cp -v -- "${objtree}/vmlinux.SYS" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.SYS"
[ -f "${objtree}/vmlinux.dsk" ] && cp -v -- "${objtree}/vmlinux.dsk" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.dsk"
2005-05-24 13:27:37 +04:00
;;
*)
2006-01-01 16:23:47 +03:00
[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
2005-05-24 13:27:37 +04:00
echo "" >&2
echo '** ** ** WARNING ** ** **' >&2
echo "" >&2
2011-03-31 05:57:33 +04:00
echo "Your architecture did not define any architecture-dependent files" >&2
2005-05-24 13:27:37 +04:00
echo "to be placed into the tarball. Please add those to ${0} ..." >&2
echo "" >&2
sleep 5
;;
esac
#
# Create the tarball
#
(
cd "${tmpdir}"
2009-11-24 18:11:37 +03:00
opts=
if tar --owner=root --group=root --help >/dev/null 2>&1; then
opts="--owner=root --group=root"
fi
2012-09-25 18:03:03 +04:00
tar cf - boot/* lib/* $opts | ${compress} > "${tarball}${file_ext}"
2005-05-24 13:27:37 +04:00
)
echo "Tarball successfully created in ${tarball}${file_ext}"
exit 0