16d983feaSJan-Benedict Glaw#!/bin/sh 2b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 36d983feaSJan-Benedict Glaw 46d983feaSJan-Benedict Glaw# 5af7db99aSMatteo Croce# buildtar 0.0.5 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# 19*1fc90958SMasahiro Yamadatmpdir=$1 206d983feaSJan-Benedict Glaw 216d983feaSJan-Benedict Glaw# 226d983feaSJan-Benedict Glaw# Clean-up and re-create the temporary directory 236d983feaSJan-Benedict Glaw# 246d983feaSJan-Benedict Glawrm -rf -- "${tmpdir}" 256d983feaSJan-Benedict Glawmkdir -p -- "${tmpdir}/boot" 26dd965f1fSMasahiro Yamadadirs=boot 276d983feaSJan-Benedict Glaw 2855a87cd8SDomenico Andreoli 2955a87cd8SDomenico Andreoli# 3055a87cd8SDomenico Andreoli# Try to install dtbs 3155a87cd8SDomenico Andreoli# 3255a87cd8SDomenico Andreoliif grep -q '^CONFIG_OF_EARLY_FLATTREE=y' include/config/auto.conf; then 3355a87cd8SDomenico Andreoli # Only some architectures with OF support have this target 3455a87cd8SDomenico Andreoli if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then 3555a87cd8SDomenico Andreoli $MAKE ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_DTBS_PATH="${tmpdir}/boot/dtbs/${KERNELRELEASE}" dtbs_install 3655a87cd8SDomenico Andreoli fi 3755a87cd8SDomenico Andreolifi 3855a87cd8SDomenico Andreoli 3955a87cd8SDomenico Andreoli 406d983feaSJan-Benedict Glaw# 416d983feaSJan-Benedict Glaw# Try to install modules 426d983feaSJan-Benedict Glaw# 436fb7ef5aSMasahiro Yamadaif grep -q '^CONFIG_MODULES=y' include/config/auto.conf; then 44175209ccSMasahiro Yamada make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install 45dd965f1fSMasahiro Yamada dirs="$dirs lib" 466d983feaSJan-Benedict Glawfi 476d983feaSJan-Benedict Glaw 486d983feaSJan-Benedict Glaw 496d983feaSJan-Benedict Glaw# 506d983feaSJan-Benedict Glaw# Install basic kernel files 516d983feaSJan-Benedict Glaw# 526073aa64SJan-Benedict Glawcp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}" 53cfd63736SNicolas Porcelcp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}" 546073aa64SJan-Benedict Glawcp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 556d983feaSJan-Benedict Glaw 566d983feaSJan-Benedict Glaw 576d983feaSJan-Benedict Glaw# 586d983feaSJan-Benedict Glaw# Install arch-specific kernel image(s) 596d983feaSJan-Benedict Glaw# 606d983feaSJan-Benedict Glawcase "${ARCH}" in 61bc395addSDaniel De Graaf x86|i386|x86_64) 62bc395addSDaniel De Graaf [ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 636d983feaSJan-Benedict Glaw ;; 646d983feaSJan-Benedict Glaw alpha) 656073aa64SJan-Benedict Glaw [ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 666d983feaSJan-Benedict Glaw ;; 6791400ac3SHelge Deller parisc*) 6891400ac3SHelge Deller [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 6991400ac3SHelge Deller [ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}" 7091400ac3SHelge Deller ;; 717848ea79SStuart Longland mips) 727848ea79SStuart Longland if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then 737848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 747848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then 757848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 767848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then 777848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 787848ea79SStuart Longland elif [ -f "${objtree}/vmlinux.32" ]; then 797848ea79SStuart Longland cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 807848ea79SStuart Longland elif [ -f "${objtree}/vmlinux.64" ]; then 817848ea79SStuart Longland cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 827848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then 837848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 847848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then 857848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 867848ea79SStuart Longland elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then 877848ea79SStuart Longland cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 887848ea79SStuart Longland elif [ -f "${objtree}/vmlinux" ]; then 897848ea79SStuart Longland cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 907848ea79SStuart Longland fi 917848ea79SStuart Longland ;; 920df57d90SOlof Johansson arm64) 93731c4eacSVeronika Kabatova for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo vmlinuz.efi ; do 940df57d90SOlof Johansson if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then 950df57d90SOlof Johansson cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" 960df57d90SOlof Johansson break 970df57d90SOlof Johansson fi 980df57d90SOlof Johansson done 990df57d90SOlof Johansson ;; 1007d0bc44bSCarlos de Paula riscv) 1017d0bc44bSCarlos de Paula for i in Image.bz2 Image.gz Image; do 1027d0bc44bSCarlos de Paula if [ -f "${objtree}/arch/riscv/boot/${i}" ] ; then 1037d0bc44bSCarlos de Paula cp -v -- "${objtree}/arch/riscv/boot/${i}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 1047d0bc44bSCarlos de Paula break 1057d0bc44bSCarlos de Paula fi 1067d0bc44bSCarlos de Paula done 1077d0bc44bSCarlos de Paula ;; 1086d983feaSJan-Benedict Glaw *) 1096073aa64SJan-Benedict Glaw [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}" 1106d983feaSJan-Benedict Glaw echo "" >&2 1116d983feaSJan-Benedict Glaw echo '** ** ** WARNING ** ** **' >&2 1126d983feaSJan-Benedict Glaw echo "" >&2 11325985edcSLucas De Marchi echo "Your architecture did not define any architecture-dependent files" >&2 1146d983feaSJan-Benedict Glaw echo "to be placed into the tarball. Please add those to ${0} ..." >&2 1156d983feaSJan-Benedict Glaw echo "" >&2 1166d983feaSJan-Benedict Glaw sleep 5 1176d983feaSJan-Benedict Glaw ;; 1186d983feaSJan-Benedict Glawesac 119