summaryrefslogtreecommitdiff
path: root/scripts/package/buildtar
blob: 65b4ea50296219e2cfed406dddd3cb4eac0737ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0

#
# buildtar 0.0.5
#
# (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
#
# 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=$1

#
# Clean-up and re-create the temporary directory
#
rm -rf -- "${tmpdir}"
mkdir -p -- "${tmpdir}/boot"
dirs=boot


#
# Try to install dtbs
#
if grep -q '^CONFIG_OF_EARLY_FLATTREE=y' include/config/auto.conf; then
	# Only some architectures with OF support have this target
	if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
		$MAKE ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_DTBS_PATH="${tmpdir}/boot/dtbs/${KERNELRELEASE}" dtbs_install
    fi
fi


#
# 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"
fi


#
# Install basic kernel files
#
cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"


#
# Install arch-specific kernel image(s)
#
case "${ARCH}" in
	x86|i386|x86_64)
		[ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
		;;
	alpha)
		[ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
		;;
	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
		;;
	arm64)
		for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo vmlinuz.efi ; do
			if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then
				cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
				break
			fi
		done
		;;
	riscv)
		for i in Image.bz2 Image.gz Image; do
			if [ -f "${objtree}/arch/riscv/boot/${i}" ] ; then
				cp -v -- "${objtree}/arch/riscv/boot/${i}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
				break
			fi
		done
		;;
	*)
		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
		echo "" >&2
		echo '** ** **  WARNING  ** ** **' >&2
		echo "" >&2
		echo "Your architecture did not define any architecture-dependent files" >&2
		echo "to be placed into the tarball. Please add those to ${0} ..." >&2
		echo "" >&2
		sleep 5
		;;
esac