xref: /linux/scripts/package/buildtar (revision 7848ea79025d07a5b35bfebb700f11999e5be69e)
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"
196bc6c940SBorislav 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		;;
90*7848ea79SStuart Longland	mips)
91*7848ea79SStuart Longland		if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
92*7848ea79SStuart Longland			cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
93*7848ea79SStuart Longland		elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then
94*7848ea79SStuart Longland			cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
95*7848ea79SStuart Longland		elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then
96*7848ea79SStuart Longland			cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
97*7848ea79SStuart Longland		elif [ -f "${objtree}/vmlinux.32" ]; then
98*7848ea79SStuart Longland			cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
99*7848ea79SStuart Longland		elif [ -f "${objtree}/vmlinux.64" ]; then
100*7848ea79SStuart Longland			cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
101*7848ea79SStuart Longland		elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then
102*7848ea79SStuart Longland			cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
103*7848ea79SStuart Longland		elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then
104*7848ea79SStuart Longland			cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
105*7848ea79SStuart Longland		elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then
106*7848ea79SStuart Longland			cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
107*7848ea79SStuart Longland		elif [ -f "${objtree}/vmlinux" ]; then
108*7848ea79SStuart Longland			cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
109*7848ea79SStuart Longland		fi
110*7848ea79SStuart Longland		;;
1116d983feaSJan-Benedict Glaw	*)
1126073aa64SJan-Benedict Glaw		[ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
1136d983feaSJan-Benedict Glaw		echo "" >&2
1146d983feaSJan-Benedict Glaw		echo '** ** **  WARNING  ** ** **' >&2
1156d983feaSJan-Benedict Glaw		echo "" >&2
11625985edcSLucas De Marchi		echo "Your architecture did not define any architecture-dependent files" >&2
1176d983feaSJan-Benedict Glaw		echo "to be placed into the tarball. Please add those to ${0} ..." >&2
1186d983feaSJan-Benedict Glaw		echo "" >&2
1196d983feaSJan-Benedict Glaw		sleep 5
1206d983feaSJan-Benedict Glaw		;;
1216d983feaSJan-Benedict Glawesac
1226d983feaSJan-Benedict Glaw
1236d983feaSJan-Benedict Glaw
1246d983feaSJan-Benedict Glaw#
1256d983feaSJan-Benedict Glaw# Create the tarball
1266d983feaSJan-Benedict Glaw#
1276d983feaSJan-Benedict Glaw(
1286d983feaSJan-Benedict Glaw	cd "${tmpdir}"
12991d16185SMichal Marek	opts=
13091d16185SMichal Marek	if tar --owner=root --group=root --help >/dev/null 2>&1; then
13191d16185SMichal Marek		opts="--owner=root --group=root"
13291d16185SMichal Marek	fi
133fe04ddf7SMichal Marek	tar cf - boot/* lib/* $opts | ${compress} > "${tarball}${file_ext}"
1346d983feaSJan-Benedict Glaw)
1356d983feaSJan-Benedict Glaw
1366d983feaSJan-Benedict Glawecho "Tarball successfully created in ${tarball}${file_ext}"
1376d983feaSJan-Benedict Glaw
1386d983feaSJan-Benedict Glawexit 0
1396d983feaSJan-Benedict Glaw
140