Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 #
0005 # buildtar 0.0.5
0006 #
0007 # (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
0008 #
0009 # This script is used to compile a tarball from the currently
0010 # prepared kernel. Based upon the builddeb script from
0011 # Wichert Akkerman <wichert@wiggy.net>.
0012 #
0013 
0014 set -e
0015 
0016 #
0017 # Some variables and settings used throughout the script
0018 #
0019 tmpdir="${objtree}/tar-install"
0020 tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar"
0021 
0022 
0023 #
0024 # Figure out how to compress, if requested at all
0025 #
0026 case "${1}" in
0027         dir-pkg|tar-pkg)
0028                 opts=
0029                 ;;
0030         targz-pkg)
0031                 opts="-I ${KGZIP}"
0032                 tarball=${tarball}.gz
0033                 ;;
0034         tarbz2-pkg)
0035                 opts="-I ${KBZIP2}"
0036                 tarball=${tarball}.bz2
0037                 ;;
0038         tarxz-pkg)
0039                 opts="-I ${XZ}"
0040                 tarball=${tarball}.xz
0041                 ;;
0042         tarzst-pkg)
0043                 opts="-I ${ZSTD}"
0044                 tarball=${tarball}.zst
0045                 ;;
0046         *)
0047                 echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
0048                 exit 1
0049                 ;;
0050 esac
0051 
0052 
0053 #
0054 # Clean-up and re-create the temporary directory
0055 #
0056 rm -rf -- "${tmpdir}"
0057 mkdir -p -- "${tmpdir}/boot"
0058 dirs=boot
0059 
0060 
0061 #
0062 # Try to install dtbs
0063 #
0064 if grep -q '^CONFIG_OF_EARLY_FLATTREE=y' include/config/auto.conf; then
0065         # Only some architectures with OF support have this target
0066         if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
0067                 $MAKE ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_DTBS_PATH="${tmpdir}/boot/dtbs/${KERNELRELEASE}" dtbs_install
0068     fi
0069 fi
0070 
0071 
0072 #
0073 # Try to install modules
0074 #
0075 if grep -q '^CONFIG_MODULES=y' include/config/auto.conf; then
0076         make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install
0077         dirs="$dirs lib"
0078 fi
0079 
0080 
0081 #
0082 # Install basic kernel files
0083 #
0084 cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
0085 cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}"
0086 cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0087 
0088 
0089 #
0090 # Install arch-specific kernel image(s)
0091 #
0092 case "${ARCH}" in
0093         x86|i386|x86_64)
0094                 [ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
0095                 ;;
0096         alpha)
0097                 [ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
0098                 ;;
0099         parisc*)
0100                 [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0101                 [ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
0102                 ;;
0103         mips)
0104                 if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
0105                         cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
0106                 elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then
0107                         cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
0108                 elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then
0109                         cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
0110                 elif [ -f "${objtree}/vmlinux.32" ]; then
0111                         cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0112                 elif [ -f "${objtree}/vmlinux.64" ]; then
0113                         cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0114                 elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then
0115                         cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0116                 elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then
0117                         cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0118                 elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then
0119                         cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0120                 elif [ -f "${objtree}/vmlinux" ]; then
0121                         cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0122                 fi
0123                 ;;
0124         arm64)
0125                 for i in Image.bz2 Image.gz Image.lz4 Image.lzma Image.lzo ; do
0126                         if [ -f "${objtree}/arch/arm64/boot/${i}" ] ; then
0127                                 cp -v -- "${objtree}/arch/arm64/boot/${i}" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
0128                                 break
0129                         fi
0130                 done
0131                 ;;
0132         riscv)
0133                 for i in Image.bz2 Image.gz Image; do
0134                         if [ -f "${objtree}/arch/riscv/boot/${i}" ] ; then
0135                                 cp -v -- "${objtree}/arch/riscv/boot/${i}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
0136                                 break
0137                         fi
0138                 done
0139                 ;;
0140         *)
0141                 [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
0142                 echo "" >&2
0143                 echo '** ** **  WARNING  ** ** **' >&2
0144                 echo "" >&2
0145                 echo "Your architecture did not define any architecture-dependent files" >&2
0146                 echo "to be placed into the tarball. Please add those to ${0} ..." >&2
0147                 echo "" >&2
0148                 sleep 5
0149                 ;;
0150 esac
0151 
0152 if [ "${1}" = dir-pkg ]; then
0153         echo "Kernel tree successfully created in $tmpdir"
0154         exit 0
0155 fi
0156 
0157 #
0158 # Create the tarball
0159 #
0160 if tar --owner=root --group=root --help >/dev/null 2>&1; then
0161         opts="$opts --owner=root --group=root"
0162 fi
0163 
0164 tar cf $tarball -C $tmpdir $opts $dirs
0165 
0166 echo "Tarball successfully created in $tarball"
0167 
0168 exit 0