#!/bin/bash

# Compress the /boot/vmlinux image after find-debuginfo.sh has done its job

set -e

case "$RPM_PACKAGE_NAME" in
kernel-*)
	;;
*)
	exit 0
esac
for f in $RPM_BUILD_ROOT/boot/vmlinux-*; do
	if [ -L "$f" ]; then
		f=`readlink -f "$f"`
	fi
	for compression in gz/gzip xz; do
		if test -e "$f" -a -e "$f.${compression%/*}"; then
			echo "${compression#*/} $f"
			# Deliberately not using -n; the vmlinux image has a
			# predictable timestamp (bnc#880848#c20)
			${compression#*/} -k -9 -f "$f"
		fi
	done
done

