Files
kernel/scripts/package/buildtar
T

141 lines
4.1 KiB
Bash
Raw Normal View History

2005-05-24 11:27:37 +02:00
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
2005-05-24 11:27:37 +02:00
#
2006-01-01 14:23:47 +01:00
# buildtar 0.0.4
2005-05-24 11:27:37 +02:00
#
2006-01-01 14:23:47 +01:00
# (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
2005-05-24 11:27:37 +02: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 09:05:47 +01:00
tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
2005-05-24 11:27:37 +02:00
#
# Figure out how to compress, if requested at all
#
case "${1}" in
tar-pkg)
opts=
2005-05-24 11:27:37 +02:00
;;
targz-pkg)
opts=--gzip
tarball=${tarball}.gz
2005-05-24 11:27:37 +02:00
;;
tarbz2-pkg)
opts=--bzip2
tarball=${tarball}.bz2
2005-05-24 11:27:37 +02:00
;;
2011-01-30 12:18:51 +01:00
tarxz-pkg)
opts=--xz
tarball=${tarball}.xz
2011-01-30 12:18:51 +01:00
;;
2005-05-24 11:27:37 +02: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"
dirs=boot
2005-05-24 11:27:37 +02:00
#
# Try to install modules
#
if grep -q '^CONFIG_MODULES=y' include/config/auto.conf; then
make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install
dirs="$dirs lib"
2005-05-24 11:27:37 +02:00
fi
#
# Install basic kernel files
#
2006-01-01 14:23:47 +01:00
cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
2017-08-19 00:20:51 +02:00
cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
2006-01-01 14:23:47 +01:00
cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
2005-05-24 11:27:37 +02:00
#
# Install arch-specific kernel image(s)
#
case "${ARCH}" in
2008-01-21 18:21:11 -06: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 11:27:37 +02:00
;;
alpha)
2006-01-01 14:23:47 +01:00
[ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
2005-05-24 11:27:37 +02:00
;;
2009-02-18 22:12:21 +00:00
parisc*)
[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
[ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
;;
mips)
if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then
cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then
cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
elif [ -f "${objtree}/vmlinux.32" ]; then
cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
elif [ -f "${objtree}/vmlinux.64" ]; then
cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then
cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then
cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then
cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
elif [ -f "${objtree}/vmlinux" ]; then
cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
fi
;;
2018-07-13 09:24:58 -07:00
arm64)
for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo ; do
if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then
cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
break
fi
done
;;
2005-05-24 11:27:37 +02:00
*)
2006-01-01 14:23:47 +01:00
[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
2005-05-24 11:27:37 +02:00
echo "" >&2
echo '** ** ** WARNING ** ** **' >&2
echo "" >&2
2011-03-30 22:57:33 -03:00
echo "Your architecture did not define any architecture-dependent files" >&2
2005-05-24 11:27:37 +02:00
echo "to be placed into the tarball. Please add those to ${0} ..." >&2
echo "" >&2
sleep 5
;;
esac
#
# Create the tarball
#
if tar --owner=root --group=root --help >/dev/null 2>&1; then
opts="$opts --owner=root --group=root"
fi
2005-05-24 11:27:37 +02:00
tar cf $tarball -C $tmpdir $opts $dirs
echo "Tarball successfully created in $tarball"
2005-05-24 11:27:37 +02:00
exit 0