# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../googleearth/googleearth.conf
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

# Set a custom install prefix.
if [ $prefix_auto = 1 ] ; then
	prefix="opt/googleearth"
	set_confopt
fi

# comes as script with a bzip2 at the end so we need to find out
# how many bytes the archive is and then extract it using tail

custextract=googleearth_extract
googleearth_extract() {
	local filesizes=
	# Determine the size of the archive.
	eval $( strings "$1" | grep '^filesizes=' )

	# Extract the archive.
	echo "Extracting $xsrctar:$filesizes ($taropt) ... "

	mkdir googleearth
	tail --bytes $filesizes $1 | tar -v $taropt - -C googleearth  > untar.txt
}

makeopt=
makeinstopt=

hook_add postmake 5 'googleearth_install'
googleearth_install() {
	# Do the actual installation.
	mkdir -pv $root/$prefix/google-earth
	tar -xvf googleearth-linux-x86.tar -C $root/$prefix/google-earth
	tar -xvf googleearth-data.tar -C $root/$prefix/google-earth

	install -m 755 bin/* $root$bindir/

	# Make sure the necessary environment vars will be set.h
	cat <<-EOT > $root/etc/profile.d/googleearth

	export GOOGLEEARTH_DATA_PATH="/$prefix/google-earth"
	EOT
}