LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File acpi-dump-export.sh of Package acpica (Project home:draht:131-compat)

#!/bin/bash
set -e
unset LANG
unset ${!LC_*}
t=`mktemp --tmpdir=/dev/shm`
x() {
	rm -fv "${t}"
}
trap x EXIT
if test -z "${t}" ; then exit 1 ; fi

xz_opts="--compress --force --verbose -9 --extreme --threads=0"
#
acpidump_srcdir=$1
if test -z "${acpidump_srcdir}"
then
	acpidump_srcdir=~/work/src/kernel/linux.git
fi
#
d=$PWD
git_tag=HEAD
#
tar_up_git() {
	local src_dir=$1
	local extract_dir=$2
	local git_tag=$3
	local suffix=.$4
	local date=
	local touch_date=
	local archive_paths=

	shift 4
	archive_paths="$@"
	echo "${extract_dir}"
	#
	rm -rf ${extract_dir}
	date="$( pushd "${src_dir}" > /dev/null && git log --pretty=format:%ci --max-count=1 ${git_tag}^..${git_tag} )"
	echo "git tag '${git_tag} timestamp: '${date}'"
	touch_date="`date -u -d \"${date}\" +%Y%m%d%H%M.%S`"
	touch -t "${touch_date}" "${t}"
	if test -f ${extract_dir}.tar${suffix}
	then
		if ! test "${t}" -nt ${extract_dir}.tar${suffix}
		then
			echo "git tag '${git_tag}' not newer than ${extract_dir}.tar${suffix}"
			return
		fi
	fi
	(
	cd "${src_dir}" && test -d .git &&
	git archive --format=tar --prefix=${extract_dir}/ ${git_tag} ${archive_paths}
	) |
	tar xfa -
	for f in $(find ${extract_dir} -type f)
	do
		touch -d "`cd ${src_dir} ;f_rev=$(git rev-list --max-count=1 ${git_tag} -- ${f#*/}) ; git show -s --format=format:%ai ${f_rev} `" ${f}
	done
	touch -t "${touch_date}" ${extract_dir}/git-whatchanged.txt
	tar cfa ${extract_dir}.tar $(find ${extract_dir} -type f | sort)
	touch -r ${extract_dir}/git-whatchanged.txt ${extract_dir}.tar
	case "${suffix}" in
		.xz)
			xz ${xz_opts} ${extract_dir}.tar
		;;
		.bz2)
			bzip2 -fv9 ${extract_dir}.tar
		;;
		.gz)
			gzip -fv9 ${extract_dir}.tar
		;;
		*)
		;;
	esac
	rm -rf ${extract_dir}
	#
}
#
pushd "${acpidump_srcdir}"
git_changeset="`git log '--pretty=format:%ci git:%h' | sed 1q`"
git show ${git_tag}:Makefile | sed 's@[[:blank:]]@@g;2 q' > ${t}
source ${t}
popd
acpidump_version=${VERSION}.${PATCHLEVEL}
#
acpidump_extract_dir=acpidump-${acpidump_version}
time tar_up_git "${acpidump_srcdir}" "${acpidump_extract_dir}" "${git_tag}" xz \
	"COPYING tools/power/acpi include/acpi drivers/acpi/acpica"
#