/[gentoo-x86]/eclass/vmware.eclass
Gentoo

Contents of /eclass/vmware.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.37 - (show annotations) (download)
Sat Sep 1 20:49:01 2012 UTC (2 years, 3 months ago) by vadimk
Branch: MAIN
CVS Tags: HEAD
Changes since 1.36: +1 -1 lines
FILE REMOVED
Removed Files: vmware-mod.eclass vmware.eclass

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/vmware.eclass,v 1.36 2012/07/01 19:43:30 vadimk Exp $
4
5 # @DEAD
6
7 # This eclass is for all vmware-* ebuilds in the tree and should contain all
8 # of the common components across the multiple packages.
9
10 # Only one package per "product" is allowed to be installed at any given time.
11
12 inherit pax-utils eutils cdrom
13
14 EXPORT_FUNCTIONS pkg_preinst pkg_postinst pkg_setup src_install src_unpack pkg_postrm
15
16 DEPEND="x11-misc/shared-mime-info"
17
18 export ANY_ANY="vmware-any-any-update115"
19 #export TOOLS_ANY="vmware-tools-any-update1"
20 export VMWARE_GROUP=${VMWARE_GROUP:-vmware}
21 export VMWARE_INSTALL_DIR=/opt/${PN//-//}
22
23 vmware_create_initd() {
24 dodir "${config_dir}"/init.d/rc{0,1,2,3,4,5,6}.d
25 # This is to fix a problem where if someone merges vmware and then
26 # before configuring vmware they upgrade or re-merge the vmware
27 # package which would rmdir the /etc/vmware/init.d/rc?.d directories.
28 keepdir "${config_dir}"/init.d/rc{0,1,2,3,4,5,6}.d
29 }
30
31 vmware_run_questions() {
32 vmware_determine_product
33 # Questions:
34 einfo "Adding answers to ${config_dir}/locations"
35 locations="${D}${config_dir}/locations"
36 echo "answer BINDIR ${VMWARE_INSTALL_DIR}/bin" >> ${locations}
37 echo "answer LIBDIR ${VMWARE_INSTALL_DIR}/lib" >> ${locations}
38 echo "answer MANDIR ${VMWARE_INSTALL_DIR}/man" >> ${locations}
39 echo "answer DOCDIR ${VMWARE_INSTALL_DIR}/doc" >> ${locations}
40 if [ "${product}" == "vmware" -o "${product}" == "vmware-tools" ]
41 then
42 echo "answer SBINDIR ${VMWARE_INSTALL_DIR}/sbin" >> ${locations}
43 echo "answer RUN_CONFIGURATOR no" >> ${locations}
44 echo "answer INITDIR ${config_dir}/init.d" >> ${locations}
45 echo "answer INITSCRIPTSDIR ${config_dir}/init.d" >> ${locations}
46 fi
47 }
48
49 vmware_determine_product() {
50 # Set the product category, and the category options
51 shortname=$(echo ${PN} | cut -d- -f2-)
52 case "${shortname}" in
53 workstation|server|player)
54 product="vmware"
55 config_program="vmware-config.pl"
56 ;;
57 server-console|esx-console|gsx-console)
58 product="vmware-console"
59 config_program="vmware-config-console.pl"
60 ;;
61 workstation-tools|esx-tools|gsx-tools|server-tools)
62 product="vmware-tools"
63 config_program="vmware-config-tools.pl"
64 ;;
65 *)
66 product="unknown"
67 ;;
68 esac
69 config_dir="/etc/${product}"
70
71 # Set per package options
72 case "${shortname}" in
73 workstation)
74 FULL_NAME="Workstation"
75 ;;
76 player)
77 FULL_NAME="Player"
78 ;;
79 server)
80 FULL_NAME="Server"
81 ;;
82 server-console)
83 FULL_NAME="Server Console"
84 config_program="vmware-config-server-console.pl"
85 config_dir="/etc/${PN}"
86 ;;
87 esx-console)
88 FULL_NAME="ESX Console"
89 ;;
90 esac
91 }
92
93 vmware_pkg_setup() {
94 vmware_determine_product
95 }
96
97 vmware_src_unpack() {
98 vmware_determine_product
99 case "${product}" in
100 vmware-tools)
101 # We grab our tarball from "CD"
102 einfo "You will need ${TARBALL} from the VMware installation."
103 einfo "Select VM->Install VMware Tools from VMware's menu."
104 cdrom_get_cds ${TARBALL}
105 ;;
106 esac
107 # If there is anything to unpack, at all, then we should be using MY_P.
108 if [[ -n "${MY_P}" ]]
109 then
110 if [[ -e "${CDROM_ROOT}"/${MY_P}.tar.gz ]]
111 then
112 tar xzf "${CDROM_ROOT}"/${MY_P}.tar.gz || die
113 else
114 unpack "${MY_P}".tar.gz
115 fi
116
117 if [[ -n "${ANY_ANY}" ]]
118 then
119 unpack "${ANY_ANY}".tar.gz
120 # Move the relevant ANY_ANY files now, so that they can be patched later...
121 mv -f "${ANY_ANY}"/services.sh "${S}"/installer/services.sh
122 # We should be able to get rid of this eventually,
123 # since we'll be using vmware-modules in future...
124 [[ "${product}" == "vmware" ]] && \
125 mv -f "${ANY_ANY}"/*.tar "${S}"/lib/modules/source
126 [[ -e lib/bin/vmware ]] && \
127 chmod 755 lib/bin/vmware
128 [[ -e bin/vmnet-bridge ]] && \
129 chmod 755 bin/vmnet-bridge
130 [[ -e lib/bin/vmware-vmx ]] && \
131 chmod 755 lib/bin/vmware-vmx
132 [[ -e lib/bin-debug/vmware-vmx ]] && \
133 chmod 755 lib/bin-debug/vmware-vmx
134 if [[ "${RUN_UPDATE}" == "yes" ]]
135 then
136 cd "${S}"/"${ANY_ANY}"
137 ./update vmware ../lib/bin/vmware || die
138 ./update bridge ../bin/vmnet-bridge || die
139 ./update vmx ../lib/bin/vmware-vmx || die
140 ./update vmxdebug ../lib/bin-debug/vmware-vmx || die
141 fi
142 fi
143
144 # Remove PAX MPROTECT flag from all applicable files in /bin, /sbin for
145 # the vmware package only (since modules, tools and console should not
146 # need to generate code on the fly in memory).
147 [[ "${product}" == "vmware" ]] && pax-mark -m \
148 $(list-paxables ${S}/{bin{,-debug},sbin}/{vmware-serverd,vmware-vmx})
149
150 # Run through any patches that might need to be applied
151 cd "${S}"
152 if [[ -d "${FILESDIR}/${PV}" ]]
153 then
154 EPATCH_SUFFIX="patch"
155 epatch "${FILESDIR}"/${PV}
156 fi
157 if [[ -n "${PATCHES}" ]]
158 then
159 for patch in ${PATCHES}
160 do
161 epatch "${FILESDIR}"/${patch}
162 done
163 fi
164 # Unpack our new libs
165 for a in ${A}
166 do
167 case ${a} in
168 vmware-libssl.so.0.9.7l.tar.bz2)
169 unpack vmware-libssl.so.0.9.7l.tar.bz2
170 ;;
171 vmware-libcrypto.so.0.9.7l.tar.bz2)
172 unpack vmware-libcrypto.so.0.9.7l.tar.bz2
173 ;;
174 esac
175 done
176 fi
177 }
178
179 vmware_src_install() {
180 # We won't want any perl scripts from VMware once we've finally got all
181 # of the configuration done, but for now, they're necessary.
182 #rm -f bin/*.pl
183
184 # As backwards as this seems, we're installing our icons first.
185 if [[ -e lib/share/icons/48x48/apps/${PN}.png ]]
186 then
187 doicon lib/share/icons/48x48/apps/${PN}.png
188 elif [[ -e doc/icon48x48.png ]]
189 then
190 newicon doc/icon48x48.png ${PN}.png
191 elif [[ -e "${DISTDIR}/${product}.png" ]]
192 then
193 newicon "${DISTDIR}"/${product}.png ${PN}.png
194 fi
195
196 # Since with Gentoo we compile everthing it doesn't make sense to keep
197 # the precompiled modules arround. Saves about 4 megs of disk space too.
198 rm -rf "${S}"/lib/modules/binary
199 # We also don't need to keep the icons around, or do we?
200 #rm -rf ${S}/lib/share/icons
201
202 # Just like any good monkey, we install the documentation and man pages.
203 [[ -d doc ]] && dodoc doc/*
204 if [[ -d man ]]
205 then
206 cd man
207 for x in *
208 do
209 doman ${x}/* || die "doman"
210 done
211 fi
212 cd "${S}"
213
214 # We remove the shipped libssl for bug #148682
215 if [ -d "${S}"/libssl.so.0.9.7 ]
216 then
217 rm -rf "${S}"/lib/lib/libssl.so.0.9.7
218 # Now, we move in our own
219 cp -pPR "${S}"/libssl.so.0.9.7 "${S}"/lib/lib
220 fi
221 # We remove the shipped libcrypto for bug #148682
222 if [ -d "${S}"/libcrypto.so.0.9.7 ]
223 then
224 rm -rf "${S}"/lib/lib/libcrypto.so.0.9.7
225 # Now, we move in our own
226 cp -pPR "${S}"/libcrypto.so.0.9.7 "${S}"/lib/lib
227 fi
228
229 # We loop through our directories and copy everything to our system.
230 for x in bin lib sbin
231 do
232 if [[ -e "${S}/${x}" ]]
233 then
234 dodir "${VMWARE_INSTALL_DIR}"/${x}
235 cp -pPR "${S}"/${x}/* "${D}""${VMWARE_INSTALL_DIR}"/${x} \
236 || die "copying ${x}"
237 fi
238 done
239
240 # If we have an /etc directory, we copy it.
241 if [[ -e "${S}/etc" ]]
242 then
243 dodir "${config_dir}"
244 cp -pPR "${S}"/etc/* "${D}""${config_dir}"
245 fowners root:${VMWARE_GROUP} "${config_dir}"
246 fperms 770 "${config_dir}"
247 fi
248
249 # If we have any helper files, we install them. First, we check for an
250 # init script.
251 if [[ -e "${FILESDIR}/${PN}.rc" ]]
252 then
253 newinitd "${FILESDIR}"/${PN}.rc ${product} || die "newinitd"
254 fi
255 # Then we check for an environment file.
256 if [[ -e "${FILESDIR}/90${PN}" ]]
257 then
258 doenvd "${FILESDIR}"/90${PN} || die "doenvd"
259 fi
260 # Last, we check for any mime files.
261 if [[ -e "${FILESDIR}/${PN}.xml" ]]
262 then
263 insinto /usr/share/mime/packages
264 doins "${FILESDIR}"/${PN}.xml || die "mimetypes"
265 fi
266
267 # Blame bug #91191 for this one.
268 if [[ -e doc/EULA ]]
269 then
270 insinto "${VMWARE_INSTALL_DIR}"/doc
271 doins doc/EULA || die "copying EULA"
272 fi
273
274 # Do we have vmware-ping/vmware-vmx? If so, make them setuid.
275 for p in /bin/vmware-ping /lib/bin/vmware-vmx /lib/bin-debug/vmware-vmx /lib/bin/vmware-vmx-debug /sbin/vmware-authd;
276 do
277 if [ -x "${D}${VMWARE_INSTALL_DIR}${p}" ]
278 then
279 fowners root:${VMWARE_GROUP} "${VMWARE_INSTALL_DIR}"${p}
280 fperms 4750 "${VMWARE_INSTALL_DIR}"${p}
281 fi
282 done
283
284 # This removed the user/group warnings
285 # But also broke vmware-server with FEATURES="userpriv" since it removes
286 # the set-UID bit
287 #chown -R root:${VMWARE_GROUP} ${D} || die
288
289 # We like desktop icons.
290 # TODO: Fix up the icon creation, across the board.
291 #make_desktop_entry ${PN} "VMware ${FULL_NAME}"
292
293 # We like symlinks for console users.
294 # TODO: Fix up the symlink creation, across the board.
295 # dosym ${VMWARE_INSTALL_DIR}/bin/${PN} /usr/bin/${PN}
296
297 # TODO: Replace this junk
298 # Everything after this point will hopefully go away once we can rid
299 # ourselves of the evil perl configuration scripts.
300
301 if [ "${product}" == "vmware" -o "${product}" == "vmware-tools" ]
302 then
303
304 # We have to create a bunch of rc directories for the init script
305 vmware_create_initd || die "creating rc directories"
306
307 # Now, we copy in our services.sh file
308 exeinto "${config_dir}"/init.d
309 newexe installer/services.sh ${product} || die "services.sh"
310
311 # Set the name
312 dosed "s:%LONGNAME%:Vmware ${FULL_NAME}:" \
313 "${config_dir}"/init.d/${product}
314 [ "${shortname}" == "server" ] && dosed "s:%SHORTNAME%:wgs:" \
315 "${config_dir}"/init.d/${product}
316 fi
317
318 # Finally, we run the "questions"
319 vmware_run_questions || die "running questions"
320 }
321
322 vmware_pkg_preinst() {
323 # This is run here due to bug #143150
324 [ -z "${product}" ] && vmware_determine_product
325
326 # This must be done after the install to get the mtimes on each file
327 # right.
328
329 #Note: it's a bit weird to use ${D} in a preinst script but it should work
330 #(drobbins, 1 Feb 2002)
331
332 einfo "Generating ${config_dir}/locations file."
333 d=`echo ${D} | wc -c`
334 for x in `find ${D}${VMWARE_INSTALL_DIR} ${D}${config_dir}` ; do
335 x="`echo ${x} | cut -c ${d}-`"
336 if [ -d "${D}/${x}" ] ; then
337 echo "directory ${x}" >> "${D}${config_dir}"/locations
338 else
339 echo -n "file ${x}" >> "${D}${config_dir}"/locations
340 if [ "${x}" == "${config_dir}/locations" ] ; then
341 echo "" >> "${D}${config_dir}"/locations
342 elif [ "${x}" == "${config_dir}/not_configured" ] ; then
343 echo "" >> "${D}${config_dir}"/locations
344 else
345 echo -n " " >> "${D}${config_dir}"/locations
346 find ${D}${x} -printf %T@ >> "${D}${config_dir}"/locations
347 echo "" >> "${D}${config_dir}"/locations
348 fi
349 fi
350 done
351 }
352
353 vmware_pkg_postinst() {
354 update-mime-database /usr/share/mime
355 [[ -d "${config_dir}" ]] && chown -R root:${VMWARE_GROUP} ${config_dir}
356
357 # This is to fix the problem where the not_configured file doesn't get
358 # removed when the configuration is run. This doesn't remove the file
359 # It just tells the vmware-config.pl script it can delete it.
360 einfo "Updating ${config_dir}/locations"
361 for x in "${config_dir}"/._cfg????_locations ; do
362 if [ -f $x ] ; then
363 cat $x >> "${config_dir}"/locations
364 rm $x
365 fi
366 done
367
368 echo
369 elog "You need to run "
370 elog " ${VMWARE_INSTALL_DIR}/bin/${config_program}"
371 elog "to complete the install."
372 echo
373 einfo "For VMware Add-Ons just visit"
374 einfo "http://www.vmware.com/download/downloadaddons.html"
375 echo
376 if [ "${PN}" == "vmware-player" ]
377 then
378 elog "After configuring, run vmplayer to launch"
379 else
380 elog "After configuring, run ${PN} to launch"
381 fi
382 echo
383 if [ "${product}" == "vmware" -o "${product}" == "vmware-tools" ]
384 then
385 elog "Also note that when you reboot you should run:"
386 elog " /etc/init.d/${product} start"
387 elog "before trying to run ${product}. Or you could just add it to"
388 elog "the default runlevel:"
389 elog " rc-update add ${product} default"
390 echo
391 ewarn "VMWare allows for the potential of overwriting files as root. Only"
392 ewarn "give VMWare access to trusted individuals."
393 echo
394 fi
395 ewarn "Remember, in order to run VMware ${FULL_NAME}, you have to"
396 ewarn "be in the '${VMWARE_GROUP}' group."
397 echo
398 }
399
400 vmware_pkg_postrm() {
401 [ -z "${product}" ] && vmware_determine_product
402 local product_extras
403 if [ "${product}" == "vmware" ]
404 then
405 product_extras=" and /etc/init.d/${product}"
406 fi
407 if ! has_version app-emulation/${PN}; then
408 echo
409 elog "To remove all traces of ${product} you will need to remove the files"
410 elog "in ${config_dir}${product_extras}."
411 elog "If the vmware-modules package is installed, you may no longer need it."
412 echo
413 fi
414 }

  ViewVC Help
Powered by ViewVC 1.1.20