summaryrefslogtreecommitdiff
blob: a836ca8780e28b3a303e26557555624352639782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-emulation/vmware-workstation-tools/vmware-workstation-tools-4.5.3.ebuild,v 1.3 2006/06/09 15:07:39 wolf31o2 Exp $

inherit eutils

DESCRIPTION="Guest-os tools for VMware Workstation"
HOMEPAGE="http://www.vmware.com/"

# the vmware-tools sources are part of the vmware virtual machine;
# they must be installed by hand
SRC_URI=""
LICENSE="vmware"
SLOT="0"
KEYWORDS="~x86"
IUSE="X"
RESTRICT=""

DEPEND=""
RDEPEND="sys-apps/pciutils"

dir=/opt/vmware/tools
Ddir=${D}/${dir}
TARBALL="vmware-linux-tools.tar.gz"
#VMwareTools-5.0.0-13124.tar.gz

S=${WORKDIR}/vmware-tools-distrib

vmware_create_initd() {
	dodir /etc/vmware-tools/init.d
	dodir /etc/vmware-tools/init.d/rc0.d
	dodir /etc/vmware-tools/init.d/rc1.d
	dodir /etc/vmware-tools/init.d/rc2.d
	dodir /etc/vmware-tools/init.d/rc3.d
	dodir /etc/vmware-tools/init.d/rc4.d
	dodir /etc/vmware-tools/init.d/rc5.d
	dodir /etc/vmware-tools/init.d/rc6.d

	# This is to fix a problem where if someone merges vmware and then
	# before configuring vmware they upgrade or re-merge the vmware
	# package which would rmdir the /etc/vmware/init.d/rc?.d directories.
	keepdir /etc/vmware-tools/init.d/rc{0,1,2,3,4,5,6}.d
}

vmware_run_questions() {
	# Questions:
	einfo "Adding answers to /etc/vmware/locations"
	locations="${D}/etc/vmware-tools/locations"
	echo "answer BINDIR ${dir}/bin" >> ${locations}
	echo "answer LIBDIR ${dir}/lib" >> ${locations}
	echo "answer MANDIR ${dir}/man" >> ${locations}
	echo "answer DOCDIR ${dir}/doc" >> ${locations}
	echo "answer SBINDIR ${dir}/sbin" >> ${locations}
	echo "answer RUN_CONFIGURATOR no" >> ${locations}
	echo "answer INITDIR /etc/vmware-tools/init.d" >> ${locations}
	echo "answer INITSCRIPTSDIR /etc/vmware-tools/init.d" >> ${locations}
}

pkg_setup() {
	einfo "You will need ${TARBALL} from the VMware installation."
	einfo "Select VM->Install VMware Tools from VMware Workstation's menu."
	cdrom_get_cds ${TARBALL}
}

src_unpack() {
	tar xf "${CDROM_ROOT}"/"${TARBALL}"
}

src_install() {
	dodir ${dir}/bin
	cp -pPR bin/* ${Ddir}/bin || die

	dodir ${dir}/lib
	cp -dr lib/* ${Ddir}/lib || die
	# Since with Gentoo we compile everthing it doesn't make sense to keep
	# the precompiled modules arround. Saves about 4 megs of disk space too.
	rm -rf ${Ddir}/lib/modules/binary || die

	into ${dir}
	# install the binaries
	dosbin sbin/vmware-checkvm || die
	dosbin sbin/vmware-guestd || die

	# install the config files
	dodir /etc/vmware-tools
	cp -pPR etc/* ${D}/etc/vmware-tools || die

	# install the init scripts
	newinitd ${FILESDIR}/${PN}.rc vmware-tools || die

	# Environment
	doenvd ${FILESDIR}/90vmware-tools || die

	# if we have X, install the default config
	if use X ; then
		insinto /etc/X11
		doins ${FILESDIR}/xorg.conf
	fi

	vmware_create_initd || die

	cp -pPR installer/services.sh ${D}/etc/vmware-tools/init.d/vmware-tools || die

	vmware_run_questions || die
}

pkg_postinst () {
	# This must be done after the install to get the mtimes on each file
	# right. This perl snippet gets the /etc/vmware/locations file code:
	# perl -e "@a = stat('bin/vmware'); print \$a[9]"
	# The above perl line and the find line below output the same thing.
	# I would think the find line is faster to execute.
	# find /opt/vmware/workstation/bin/vmware -printf %T@

	#Note: it's a bit weird to use ${D} in a preinst script but it should work
	#(drobbins, 1 Feb 2002)

	einfo "Generating /etc/vmware-tools/locations file."
	d=`echo ${D} | wc -c`
	for x in `find ${Ddir} ${D}/etc/vmware-tools` ; do
		x="`echo ${x} | cut -c ${d}-`"
		if [ -d ${D}/${x} ] ; then
			echo "directory ${x}" >> ${D}/etc/vmware-tools/locations
		else
			echo -n "file ${x}" >> ${D}/etc/vmware-tools/locations
			if [ "${x}" == "/etc/vmware-tools/locations" ] ; then
				echo "" >> ${D}/etc/vmware-tools/locations
			elif [ "${x}" == "/etc/vmware-tools/not_configured" ] ; then
				echo "" >> ${D}/etc/vmware-tools/locations
			else
				echo -n " " >> ${D}/etc/vmware-tools/locations
				#perl -e "@a = stat('${D}${x}'); print \$a[9]" >> ${D}/etc/vmware/locations
				find ${D}${x} -printf %T@ >> ${D}/etc/vmware-tools/locations
				echo "" >> ${D}/etc/vmware-tools/locations
			fi
		fi
	done
	einfo "To start using the vmware-tools, please run the following:"
	echo
	einfo "  ${dir}/bin/vmware-config-tools.pl"
	einfo "  rc-update add vmware-tools default"
	einfo "  /etc/init.d/vmware-tools start"
	echo
	einfo "Please report all bugs to http://bugs.gentoo.org/"
	echo
	ewarn "These tools might not compile with newer kernels.  I am unable to"
	ewarn "find any patches for these to make them compile, so you're on your"
	ewarn "own if using a newer kernel in your VM.  If you know of any patches,"
	ewarn "then please file a bug so everyone can benefit."
	echo
}