xref: /linux/scripts/package/buildtar (revision 6073aa643f52fd12b02f0532dc96287f4c3293b5)
16d983feaSJan-Benedict Glaw#!/bin/sh
26d983feaSJan-Benedict Glaw
36d983feaSJan-Benedict Glaw#
4*6073aa64SJan-Benedict Glaw# buildtar 0.0.4
56d983feaSJan-Benedict Glaw#
6*6073aa64SJan-Benedict Glaw# (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de>
76d983feaSJan-Benedict Glaw#
86d983feaSJan-Benedict Glaw# This script is used to compile a tarball from the currently
96d983feaSJan-Benedict Glaw# prepared kernel. Based upon the builddeb script from
106d983feaSJan-Benedict Glaw# Wichert Akkerman <wichert@wiggy.net>.
116d983feaSJan-Benedict Glaw#
126d983feaSJan-Benedict Glaw
136d983feaSJan-Benedict Glawset -e
146d983feaSJan-Benedict Glaw
156d983feaSJan-Benedict Glaw#
166d983feaSJan-Benedict Glaw# Some variables and settings used throughout the script
176d983feaSJan-Benedict Glaw#
186d983feaSJan-Benedict Glawtmpdir="${objtree}/tar-install"
19*6073aa64SJan-Benedict Glawtarball="${objtree}/linux-${KERNELRELEASE}.tar"
206d983feaSJan-Benedict Glaw
216d983feaSJan-Benedict Glaw
226d983feaSJan-Benedict Glaw#
236d983feaSJan-Benedict Glaw# Figure out how to compress, if requested at all
246d983feaSJan-Benedict Glaw#
256d983feaSJan-Benedict Glawcase "${1}" in
266d983feaSJan-Benedict Glaw	tar-pkg)
276d983feaSJan-Benedict Glaw		compress="cat"
286d983feaSJan-Benedict Glaw		file_ext=""
296d983feaSJan-Benedict Glaw		;;
306d983feaSJan-Benedict Glaw	targz-pkg)
316d983feaSJan-Benedict Glaw		compress="gzip -c9"
326d983feaSJan-Benedict Glaw		file_ext=".gz"
336d983feaSJan-Benedict Glaw		;;
346d983feaSJan-Benedict Glaw	tarbz2-pkg)
356d983feaSJan-Benedict Glaw		compress="bzip2 -c9"
366d983feaSJan-Benedict Glaw		file_ext=".bz2"
376d983feaSJan-Benedict Glaw		;;
386d983feaSJan-Benedict Glaw	*)
396d983feaSJan-Benedict Glaw		echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2
406d983feaSJan-Benedict Glaw		exit 1
416d983feaSJan-Benedict Glaw		;;
426d983feaSJan-Benedict Glawesac
436d983feaSJan-Benedict Glaw
446d983feaSJan-Benedict Glaw
456d983feaSJan-Benedict Glaw#
466d983feaSJan-Benedict Glaw# Clean-up and re-create the temporary directory
476d983feaSJan-Benedict Glaw#
486d983feaSJan-Benedict Glawrm -rf -- "${tmpdir}"
496d983feaSJan-Benedict Glawmkdir -p -- "${tmpdir}/boot"
506d983feaSJan-Benedict Glaw
516d983feaSJan-Benedict Glaw
526d983feaSJan-Benedict Glaw#
536d983feaSJan-Benedict Glaw# Try to install modules
546d983feaSJan-Benedict Glaw#
55*6073aa64SJan-Benedict Glawif grep -q '^CONFIG_MODULES=y' "${objtree}/.config"; then
56*6073aa64SJan-Benedict Glaw	make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install
576d983feaSJan-Benedict Glawfi
586d983feaSJan-Benedict Glaw
596d983feaSJan-Benedict Glaw
606d983feaSJan-Benedict Glaw#
616d983feaSJan-Benedict Glaw# Install basic kernel files
626d983feaSJan-Benedict Glaw#
63*6073aa64SJan-Benedict Glawcp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
64*6073aa64SJan-Benedict Glawcp -v -- "${objtree}/.config" "${tmpdir}/boot/config-${KERNELRELEASE}"
65*6073aa64SJan-Benedict Glawcp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
666d983feaSJan-Benedict Glaw
676d983feaSJan-Benedict Glaw
686d983feaSJan-Benedict Glaw#
696d983feaSJan-Benedict Glaw# Install arch-specific kernel image(s)
706d983feaSJan-Benedict Glaw#
716d983feaSJan-Benedict Glawcase "${ARCH}" in
726d983feaSJan-Benedict Glaw	i386)
73*6073aa64SJan-Benedict Glaw		[ -f "${objtree}/arch/i386/boot/bzImage" ] && cp -v -- "${objtree}/arch/i386/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
746d983feaSJan-Benedict Glaw		;;
756d983feaSJan-Benedict Glaw	alpha)
76*6073aa64SJan-Benedict Glaw		[ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
776d983feaSJan-Benedict Glaw		;;
786d983feaSJan-Benedict Glaw	vax)
79*6073aa64SJan-Benedict Glaw		[ -f "${objtree}/vmlinux.SYS" ] && cp -v -- "${objtree}/vmlinux.SYS" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.SYS"
80*6073aa64SJan-Benedict Glaw		[ -f "${objtree}/vmlinux.dsk" ] && cp -v -- "${objtree}/vmlinux.dsk" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.dsk"
816d983feaSJan-Benedict Glaw		;;
826d983feaSJan-Benedict Glaw	*)
83*6073aa64SJan-Benedict Glaw		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
846d983feaSJan-Benedict Glaw		echo "" >&2
856d983feaSJan-Benedict Glaw		echo '** ** **  WARNING  ** ** **' >&2
866d983feaSJan-Benedict Glaw		echo "" >&2
876d983feaSJan-Benedict Glaw		echo "Your architecture did not define any architecture-dependant files" >&2
886d983feaSJan-Benedict Glaw		echo "to be placed into the tarball. Please add those to ${0} ..." >&2
896d983feaSJan-Benedict Glaw		echo "" >&2
906d983feaSJan-Benedict Glaw		sleep 5
916d983feaSJan-Benedict Glaw		;;
926d983feaSJan-Benedict Glawesac
936d983feaSJan-Benedict Glaw
946d983feaSJan-Benedict Glaw
956d983feaSJan-Benedict Glaw#
966d983feaSJan-Benedict Glaw# Create the tarball
976d983feaSJan-Benedict Glaw#
986d983feaSJan-Benedict Glaw(
996d983feaSJan-Benedict Glaw	cd "${tmpdir}"
1006d983feaSJan-Benedict Glaw	tar cf - . | ${compress} > "${tarball}${file_ext}"
1016d983feaSJan-Benedict Glaw)
1026d983feaSJan-Benedict Glaw
1036d983feaSJan-Benedict Glawecho "Tarball successfully created in ${tarball}${file_ext}"
1046d983feaSJan-Benedict Glaw
1056d983feaSJan-Benedict Glawexit 0
1066d983feaSJan-Benedict Glaw
107