aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/package/buildtar
blob: d8fffe6f890657b3b42c32639ad8bc5313880328 (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
#!/bin/sh

#
# buildtar 0.0.3
#
# (C) 2004-2005 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
#
version="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}${EXTRANAME}"
tmpdir="${objtree}/tar-install"
tarball="${objtree}/linux-${version}.tar"


#
# Figure out how to compress, if requested at all
#
case "${1}" in
	tar-pkg)
		compress="cat"
		file_ext=""
		;;
	targz-pkg)
		compress="gzip -c9"
		file_ext=".gz"
		;;
	tarbz2-pkg)
		compress="bzip2 -c9"
		file_ext=".bz2"
		;;
	*)
		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
#
if ! make INSTALL_MOD_PATH="${tmpdir}" modules_install; then
	echo "" >&2
	echo "Ignoring error at module_install time, since that could be" >&2
	echo "a result of missing local modutils/module-init-tools," >&2
	echo "or you just didn't compile in module support at all..." >&2
	echo "" >&2
fi


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


#
# Install arch-specific kernel image(s)
#
case "${ARCH}" in
	i386)
		[ -f arch/i386/boot/bzImage ] && cp -v -- arch/i386/boot/bzImage "${tmpdir}/boot/vmlinuz-${version}"
		;;
	alpha)
		[ -f arch/alpha/boot/vmlinux.gz ] && cp -v -- arch/alpha/boot/vmlinux.gz "${tmpdir}/boot/vmlinuz-${version}"
		;;
	vax)
		[ -f vmlinux.SYS ] && cp -v -- vmlinux.SYS "${tmpdir}/boot/vmlinux-${version}.SYS"
		[ -f vmlinux.dsk ] && cp -v -- vmlinux.dsk "${tmpdir}/boot/vmlinux-${version}.dsk"
		;;
	*)
		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${version}"
		echo "" >&2
		echo '** ** **  WARNING  ** ** **' >&2
		echo "" >&2
		echo "Your architecture did not define any architecture-dependant files" >&2
		echo "to be placed into the tarball. Please add those to ${0} ..." >&2
		echo "" >&2
		sleep 5
		;;
esac


#
# Create the tarball
#
(
	cd "${tmpdir}"
	tar cf - . | ${compress} > "${tarball}${file_ext}"
)

echo "Tarball successfully created in ${tarball}${file_ext}"

exit 0