xref: /linux/scripts/package/buildtar (revision 6bc6c9409de03987736df58c411c3aa7b5aed051)
16d983feaSJan-Benedict Glaw#!/bin/sh
26d983feaSJan-Benedict Glaw
36d983feaSJan-Benedict Glaw#
46073aa64SJan-Benedict Glaw# buildtar 0.0.4
56d983feaSJan-Benedict Glaw#
66073aa64SJan-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*6bc6c940SBorislav Petkovtarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.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)
31b589c8aeSAndi Kleen		compress="gzip"
326d983feaSJan-Benedict Glaw		file_ext=".gz"
336d983feaSJan-Benedict Glaw		;;
346d983feaSJan-Benedict Glaw	tarbz2-pkg)
35b589c8aeSAndi Kleen		compress="bzip2"
366d983feaSJan-Benedict Glaw		file_ext=".bz2"
376d983feaSJan-Benedict Glaw		;;
389a17f400SZdenek Kaspar	tarxz-pkg)
39b589c8aeSAndi Kleen		compress="xz"
409a17f400SZdenek Kaspar		file_ext=".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"
546d983feaSJan-Benedict Glaw
556d983feaSJan-Benedict Glaw
566d983feaSJan-Benedict Glaw#
576d983feaSJan-Benedict Glaw# Try to install modules
586d983feaSJan-Benedict Glaw#
596073aa64SJan-Benedict Glawif grep -q '^CONFIG_MODULES=y' "${objtree}/.config"; then
606073aa64SJan-Benedict Glaw	make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install
616d983feaSJan-Benedict Glawfi
626d983feaSJan-Benedict Glaw
636d983feaSJan-Benedict Glaw
646d983feaSJan-Benedict Glaw#
656d983feaSJan-Benedict Glaw# Install basic kernel files
666d983feaSJan-Benedict Glaw#
676073aa64SJan-Benedict Glawcp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}"
686073aa64SJan-Benedict Glawcp -v -- "${objtree}/.config" "${tmpdir}/boot/config-${KERNELRELEASE}"
696073aa64SJan-Benedict Glawcp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
706d983feaSJan-Benedict Glaw
716d983feaSJan-Benedict Glaw
726d983feaSJan-Benedict Glaw#
736d983feaSJan-Benedict Glaw# Install arch-specific kernel image(s)
746d983feaSJan-Benedict Glaw#
756d983feaSJan-Benedict Glawcase "${ARCH}" in
76bc395addSDaniel De Graaf	x86|i386|x86_64)
77bc395addSDaniel De Graaf		[ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
786d983feaSJan-Benedict Glaw		;;
796d983feaSJan-Benedict Glaw	alpha)
806073aa64SJan-Benedict Glaw		[ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
816d983feaSJan-Benedict Glaw		;;
8291400ac3SHelge Deller	parisc*)
8391400ac3SHelge Deller		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
8491400ac3SHelge Deller		[ -f "${objtree}/lifimage" ] && cp -v -- "${objtree}/lifimage" "${tmpdir}/boot/lifimage-${KERNELRELEASE}"
8591400ac3SHelge Deller		;;
866d983feaSJan-Benedict Glaw	vax)
876073aa64SJan-Benedict Glaw		[ -f "${objtree}/vmlinux.SYS" ] && cp -v -- "${objtree}/vmlinux.SYS" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.SYS"
886073aa64SJan-Benedict Glaw		[ -f "${objtree}/vmlinux.dsk" ] && cp -v -- "${objtree}/vmlinux.dsk" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.dsk"
896d983feaSJan-Benedict Glaw		;;
906d983feaSJan-Benedict Glaw	*)
916073aa64SJan-Benedict Glaw		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
926d983feaSJan-Benedict Glaw		echo "" >&2
936d983feaSJan-Benedict Glaw		echo '** ** **  WARNING  ** ** **' >&2
946d983feaSJan-Benedict Glaw		echo "" >&2
9525985edcSLucas De Marchi		echo "Your architecture did not define any architecture-dependent files" >&2
966d983feaSJan-Benedict Glaw		echo "to be placed into the tarball. Please add those to ${0} ..." >&2
976d983feaSJan-Benedict Glaw		echo "" >&2
986d983feaSJan-Benedict Glaw		sleep 5
996d983feaSJan-Benedict Glaw		;;
1006d983feaSJan-Benedict Glawesac
1016d983feaSJan-Benedict Glaw
1026d983feaSJan-Benedict Glaw
1036d983feaSJan-Benedict Glaw#
1046d983feaSJan-Benedict Glaw# Create the tarball
1056d983feaSJan-Benedict Glaw#
1066d983feaSJan-Benedict Glaw(
1076d983feaSJan-Benedict Glaw	cd "${tmpdir}"
10891d16185SMichal Marek	opts=
10991d16185SMichal Marek	if tar --owner=root --group=root --help >/dev/null 2>&1; then
11091d16185SMichal Marek		opts="--owner=root --group=root"
11191d16185SMichal Marek	fi
112fe04ddf7SMichal Marek	tar cf - boot/* lib/* $opts | ${compress} > "${tarball}${file_ext}"
1136d983feaSJan-Benedict Glaw)
1146d983feaSJan-Benedict Glaw
1156d983feaSJan-Benedict Glawecho "Tarball successfully created in ${tarball}${file_ext}"
1166d983feaSJan-Benedict Glaw
1176d983feaSJan-Benedict Glawexit 0
1186d983feaSJan-Benedict Glaw
119