buildtar 4.1 KB
Newer Older
1 2 3
#!/bin/sh

#
4
# buildtar 0.0.4
5
#
6
# (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
7 8 9 10 11 12 13 14 15 16 17 18
#
# 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"
19
tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
20 21 22 23 24 25 26


#
# Figure out how to compress, if requested at all
#
case "${1}" in
	tar-pkg)
27
		opts=
28 29
		;;
	targz-pkg)
30 31
		opts=--gzip
		tarball=${tarball}.gz
32 33
		;;
	tarbz2-pkg)
34 35
		opts=--bzip2
		tarball=${tarball}.bz2
36
		;;
37
	tarxz-pkg)
38 39
		opts=--xz
		tarball=${tarball}.xz
40
		;;
41 42 43 44 45 46 47 48 49 50 51 52
	*)
		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"
53
dirs=boot
54 55 56 57

#
# Try to install modules
#
58
if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then
59
	make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install
60
	dirs="$dirs lib"
61 62 63 64 65 66
fi


#
# Install basic kernel files
#
67
cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
68
cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
69
cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
70 71 72 73 74 75


#
# Install arch-specific kernel image(s)
#
case "${ARCH}" in
76 77
	x86|i386|x86_64)
		[ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
78 79
		;;
	alpha)
80
		[ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
81
		;;
H
Helge Deller 已提交
82 83 84 85
	parisc*)
		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
		[ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
		;;
86
	vax)
87 88
		[ -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"
89
		;;
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
	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
		;;
111
	*)
112
		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
113 114 115
		echo "" >&2
		echo '** ** **  WARNING  ** ** **' >&2
		echo "" >&2
L
Lucas De Marchi 已提交
116
		echo "Your architecture did not define any architecture-dependent files" >&2
117 118 119 120 121 122 123 124 125 126
		echo "to be placed into the tarball. Please add those to ${0} ..." >&2
		echo "" >&2
		sleep 5
		;;
esac


#
# Create the tarball
#
127 128 129 130 131
if tar --owner=root --group=root --help >/dev/null 2>&1; then
	opts="$opts --owner=root --group=root"
fi

tar cf $tarball -C $tmpdir $opts $dirs
132

133
echo "Tarball successfully created in $tarball"
134 135

exit 0