16d983feaSJan-Benedict Glaw#!/bin/sh 2b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 36d983feaSJan-Benedict Glaw 46d983feaSJan-Benedict Glaw# 56073aa64SJan-Benedict Glaw# buildtar 0.0.4 66d983feaSJan-Benedict Glaw# 76073aa64SJan-Benedict Glaw# (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de> 86d983feaSJan-Benedict Glaw# 96d983feaSJan-Benedict Glaw# This script is used to compile a tarball from the currently 106d983feaSJan-Benedict Glaw# prepared kernel. Based upon the builddeb script from 116d983feaSJan-Benedict Glaw# Wichert Akkerman <wichert@wiggy.net>. 126d983feaSJan-Benedict Glaw# 136d983feaSJan-Benedict Glaw 146d983feaSJan-Benedict Glawset -e 156d983feaSJan-Benedict Glaw 166d983feaSJan-Benedict Glaw# 176d983feaSJan-Benedict Glaw# Some variables and settings used throughout the script 186d983feaSJan-Benedict Glaw# 196d983feaSJan-Benedict Glawtmpdir="${objtree}/tar-install" 206bc6c940SBorislav Petkovtarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar" 216d983feaSJan-Benedict Glaw 226d983feaSJan-Benedict Glaw 236d983feaSJan-Benedict Glaw# 246d983feaSJan-Benedict Glaw# Figure out how to compress, if requested at all 256d983feaSJan-Benedict Glaw# 266d983feaSJan-Benedict Glawcase "${1}" in 276d983feaSJan-Benedict Glaw tar-pkg) 2877780f79SMasahiro Yamada opts= 296d983feaSJan-Benedict Glaw ;; 306d983feaSJan-Benedict Glaw targz-pkg) 3177780f79SMasahiro Yamada opts=--gzip 3277780f79SMasahiro Yamada tarball=${tarball}.gz 336d983feaSJan-Benedict Glaw ;; 346d983feaSJan-Benedict Glaw tarbz2-pkg) 3577780f79SMasahiro Yamada opts=--bzip2 3677780f79SMasahiro Yamada tarball=${tarball}.bz2 376d983feaSJan-Benedict Glaw ;; 389a17f400SZdenek Kaspar tarxz-pkg) 3977780f79SMasahiro Yamada opts=--xz 4077780f79SMasahiro Yamada tarball=${tarball}.xz 419a17f400SZdenek Kaspar ;; 426d983feaSJan-Benedict Glaw *) 436d983feaSJan-Benedict Glaw echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2 446d983feaSJan-Benedict Glaw exit 1 456d983feaSJan-Benedict Glaw ;; 466d983feaSJan-Benedict Glawesac 476d983feaSJan-Benedict Glaw 486d983feaSJan-Benedict Glaw 496d983feaSJan-Benedict Glaw# 506d983feaSJan-Benedict Glaw# Clean-up and re-create the temporary directory 516d983feaSJan-Benedict Glaw# 526d983feaSJan-Benedict Glawrm -rf -- "${tmpdir}" 536d983feaSJan-Benedict Glawmkdir -p -- "${tmpdir}/boot" 54dd965f1fSMasahiro Yamadadirs=boot 556d983feaSJan-Benedict Glaw 566d983feaSJan-Benedict Glaw# 576d983feaSJan-Benedict Glaw# Try to install modules 586d983feaSJan-Benedict Glaw# 59cfd63736SNicolas Porcelif grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then 60*175209ccSMasahiro Yamada make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install 61dd965f1fSMasahiro Yamada dirs="$dirs lib" 626d983feaSJan-Benedict Glawfi 636d983feaSJan-Benedict Glaw 646d983feaSJan-Benedict Glaw 656d983feaSJan-Benedict Glaw# 666d983feaSJan-Benedict Glaw# Install basic kernel files 676d983feaSJan-Benedict Glaw# 686073aa64SJan-Benedict Glawcp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}" 69cfd63736SNicolas Porcelcp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}" 706073aa64SJan-Benedict Glawcp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 716d983feaSJan-Benedict Glaw 726d983feaSJan-Benedict Glaw 736d983feaSJan-Benedict Glaw# 746d983feaSJan-Benedict Glaw# Install arch-specific kernel image(s) 756d983feaSJan-Benedict Glaw# 766d983feaSJan-Benedict Glawcase "${ARCH}" in 77bc395addSDaniel De Graaf x86|i386|x86_64) 78bc395addSDaniel De Graaf [ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 796d983feaSJan-Benedict Glaw ;; 806d983feaSJan-Benedict Glaw alpha) 816073aa64SJan-Benedict Glaw [ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 826d983feaSJan-Benedict Glaw ;; 8391400ac3SHelge Deller parisc*) 8491400ac3SHelge Deller [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 8591400ac3SHelge Deller [ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}" 8691400ac3SHelge Deller ;; 877848ea79SStuart Longland mips) 887848ea79SStuart Longland if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then 897848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 907848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then 917848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 927848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then 937848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 947848ea79SStuart Longland elif [ -f "${objtree}/vmlinux.32" ]; then 957848ea79SStuart Longland cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 967848ea79SStuart Longland elif [ -f "${objtree}/vmlinux.64" ]; then 977848ea79SStuart Longland cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 987848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then 997848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 1007848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then 1017848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 1027848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then 1037848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 1047848ea79SStuart Longland elif [ -f "${objtree}/vmlinux" ]; then 1057848ea79SStuart Longland cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 1067848ea79SStuart Longland fi 1077848ea79SStuart Longland ;; 1080df57d90SOlof Johansson arm64) 1090df57d90SOlof Johansson for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo ; do 1100df57d90SOlof Johansson if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then 1110df57d90SOlof Johansson cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 1120df57d90SOlof Johansson break 1130df57d90SOlof Johansson fi 1140df57d90SOlof Johansson done 1150df57d90SOlof Johansson ;; 1166d983feaSJan-Benedict Glaw *) 1176073aa64SJan-Benedict Glaw [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}" 1186d983feaSJan-Benedict Glaw echo "" >&2 1196d983feaSJan-Benedict Glaw echo '** ** ** WARNING ** ** **' >&2 1206d983feaSJan-Benedict Glaw echo "" >&2 12125985edcSLucas De Marchi echo "Your architecture did not define any architecture-dependent files" >&2 1226d983feaSJan-Benedict Glaw echo "to be placed into the tarball. Please add those to ${0} ..." >&2 1236d983feaSJan-Benedict Glaw echo "" >&2 1246d983feaSJan-Benedict Glaw sleep 5 1256d983feaSJan-Benedict Glaw ;; 1266d983feaSJan-Benedict Glawesac 1276d983feaSJan-Benedict Glaw 1286d983feaSJan-Benedict Glaw 1296d983feaSJan-Benedict Glaw# 1306d983feaSJan-Benedict Glaw# Create the tarball 1316d983feaSJan-Benedict Glaw# 13291d16185SMichal Marekif tar --owner=root --group=root --help >/dev/null 2>&1; then 13377780f79SMasahiro Yamada opts="$opts --owner=root --group=root" 13491d16185SMichal Marekfi 1356d983feaSJan-Benedict Glaw 13677780f79SMasahiro Yamadatar cf $tarball -C $tmpdir $opts $dirs 13777780f79SMasahiro Yamada 13877780f79SMasahiro Yamadaecho "Tarball successfully created in $tarball" 1396d983feaSJan-Benedict Glaw 1406d983feaSJan-Benedict Glawexit 0 141