blob: 77c7caefede104d3ab37ea934bba8e870f0ea5d9 [file] [log] [blame]
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +02001#!/bin/sh
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +02003
4#
Matteo Croceaf7db992019-11-04 14:11:44 +01005# buildtar 0.0.5
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +02006#
Jan-Benedict Glaw6073aa62006-01-01 14:23:47 +01007# (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +02008#
9# This script is used to compile a tarball from the currently
10# prepared kernel. Based upon the builddeb script from
11# Wichert Akkerman <wichert@wiggy.net>.
12#
13
14set -e
15
16#
17# Some variables and settings used throughout the script
18#
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020019tmpdir="${objtree}/tar-install"
Borislav Petkov6bc6c942013-03-06 09:05:47 +010020tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020021
22
23#
24# Figure out how to compress, if requested at all
25#
26case "${1}" in
Matteo Croceaf7db992019-11-04 14:11:44 +010027 dir-pkg|tar-pkg)
Masahiro Yamada77780f72017-09-02 17:05:35 +090028 opts=
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020029 ;;
30 targz-pkg)
Masahiro Yamada77780f72017-09-02 17:05:35 +090031 opts=--gzip
32 tarball=${tarball}.gz
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020033 ;;
34 tarbz2-pkg)
Masahiro Yamada77780f72017-09-02 17:05:35 +090035 opts=--bzip2
36 tarball=${tarball}.bz2
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020037 ;;
Zdenek Kaspar9a17f402011-01-30 12:18:51 +010038 tarxz-pkg)
Masahiro Yamada77780f72017-09-02 17:05:35 +090039 opts=--xz
40 tarball=${tarball}.xz
Zdenek Kaspar9a17f402011-01-30 12:18:51 +010041 ;;
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020042 *)
43 echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
44 exit 1
45 ;;
46esac
47
48
49#
50# Clean-up and re-create the temporary directory
51#
52rm -rf -- "${tmpdir}"
53mkdir -p -- "${tmpdir}/boot"
Masahiro Yamadadd965f12017-09-02 17:05:34 +090054dirs=boot
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020055
56#
57# Try to install modules
58#
Masahiro Yamada6fb7ef52019-03-08 18:56:25 +090059if grep -q '^CONFIG_MODULES=y' include/config/auto.conf; then
Masahiro Yamada175209c2019-02-14 12:05:14 +090060 make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install
Masahiro Yamadadd965f12017-09-02 17:05:34 +090061 dirs="$dirs lib"
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020062fi
63
64
65#
66# Install basic kernel files
67#
Jan-Benedict Glaw6073aa62006-01-01 14:23:47 +010068cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
Nicolas Porcelcfd63732017-08-19 00:20:51 +020069cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
Jan-Benedict Glaw6073aa62006-01-01 14:23:47 +010070cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020071
72
73#
74# Install arch-specific kernel image(s)
75#
76case "${ARCH}" in
Daniel De Graafbc395ad2008-01-21 18:21:11 -060077 x86|i386|x86_64)
78 [ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020079 ;;
80 alpha)
Jan-Benedict Glaw6073aa62006-01-01 14:23:47 +010081 [ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020082 ;;
Helge Deller91400ac2009-02-18 22:12:21 +000083 parisc*)
84 [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
85 [ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
86 ;;
Stuart Longland7848ea72010-10-08 11:45:37 +100087 mips)
88 if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
89 cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
90 elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then
91 cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
92 elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then
93 cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
94 elif [ -f "${objtree}/vmlinux.32" ]; then
95 cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
96 elif [ -f "${objtree}/vmlinux.64" ]; then
97 cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
98 elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then
99 cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
100 elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then
101 cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
102 elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then
103 cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
104 elif [ -f "${objtree}/vmlinux" ]; then
105 cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
106 fi
107 ;;
Olof Johansson0df57d92018-07-13 09:24:58 -0700108 arm64)
109 for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo ; do
110 if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then
111 cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
112 break
113 fi
114 done
115 ;;
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +0200116 *)
Jan-Benedict Glaw6073aa62006-01-01 14:23:47 +0100117 [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +0200118 echo "" >&2
119 echo '** ** ** WARNING ** ** **' >&2
120 echo "" >&2
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300121 echo "Your architecture did not define any architecture-dependent files" >&2
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +0200122 echo "to be placed into the tarball. Please add those to ${0} ..." >&2
123 echo "" >&2
124 sleep 5
125 ;;
126esac
127
Matteo Croceaf7db992019-11-04 14:11:44 +0100128if [ "${1}" = dir-pkg ]; then
129 echo "Kernel tree successfully created in $tmpdir"
130 exit 0
131fi
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +0200132
133#
134# Create the tarball
135#
Masahiro Yamada77780f72017-09-02 17:05:35 +0900136if tar --owner=root --group=root --help >/dev/null 2>&1; then
137 opts="$opts --owner=root --group=root"
138fi
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +0200139
Masahiro Yamada77780f72017-09-02 17:05:35 +0900140tar cf $tarball -C $tmpdir $opts $dirs
141
142echo "Tarball successfully created in $tarball"
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +0200143
144exit 0