1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 |
---|
2 | # $Id: Portfile 146517 2016-03-10 17:49:28Z raimue@macports.org $ |
---|
3 | |
---|
4 | PortSystem 1.0 |
---|
5 | |
---|
6 | name virtualbox |
---|
7 | version 4.2.16 |
---|
8 | revision 1 |
---|
9 | # Note: On virtualbox version changes please update the checksums of all |
---|
10 | # subports, and update extension_pack_build to match the current build |
---|
11 | # of the extension pack. |
---|
12 | # Also remember to revision bump port ld64 |
---|
13 | set extension_pack_build 86992 |
---|
14 | |
---|
15 | categories emulators |
---|
16 | platforms darwin |
---|
17 | license GPL-2 |
---|
18 | maintainers nomaintainer |
---|
19 | |
---|
20 | description open source virtualization technology from Oracle |
---|
21 | long_description \ |
---|
22 | VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for \ |
---|
23 | enterprise as well as home use. Not only is VirtualBox an extremely \ |
---|
24 | feature rich, high performance product for enterprise customers, it is \ |
---|
25 | also the only professional solution that is freely available as Open \ |
---|
26 | Source Software. |
---|
27 | |
---|
28 | homepage http://www.virtualbox.org/ |
---|
29 | master_sites http://download.virtualbox.org/virtualbox/${version} |
---|
30 | |
---|
31 | if {${name} == ${subport}} { |
---|
32 | |
---|
33 | PortGroup qt4 1.0 |
---|
34 | # virtualbox installs a kernel extension so it has to build |
---|
35 | # for the same architecture as the kernel |
---|
36 | set kernel_arch [exec uname -m] |
---|
37 | switch ${kernel_arch} { |
---|
38 | i386 - |
---|
39 | x86_64 { |
---|
40 | supported_archs ${kernel_arch} |
---|
41 | } |
---|
42 | default { |
---|
43 | supported_archs i386 x86_64 |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | universal_variant no |
---|
48 | |
---|
49 | distname VirtualBox-${version} |
---|
50 | use_bzip2 yes |
---|
51 | |
---|
52 | checksums rmd160 a49d044f6935199a71f6bdf94fd9082f9888d2d6 \ |
---|
53 | sha256 ff0f8916d039120554d9d73c7cae1863d6161933374374ec2f5313892046d45a |
---|
54 | |
---|
55 | depends_lib-append port:curl \ |
---|
56 | port:libidl \ |
---|
57 | port:libxml2 \ |
---|
58 | port:libxslt \ |
---|
59 | path:lib/libssl.dylib:openssl \ |
---|
60 | port:libsdl |
---|
61 | |
---|
62 | patchfiles patch-build.diff \ |
---|
63 | patch-startup.diff |
---|
64 | platform darwin 11 { |
---|
65 | patchfiles-append patch-src-VBox-GuestHost-OpenGL-include-GL-glext.h.diff |
---|
66 | } |
---|
67 | |
---|
68 | configure.compiler gcc-4.2 |
---|
69 | |
---|
70 | # Use the apple-gcc-4.2 compiler because Xcode 4.2 no longer |
---|
71 | # provides gcc-4.2 and builds with llvm-gcc-4.2 crash. |
---|
72 | if {![file executable ${configure.cc}]} { |
---|
73 | |
---|
74 | depends_build-append port:apple-gcc42 |
---|
75 | depends_skip_archcheck-append apple-gcc42 |
---|
76 | patchfiles-append patch-apple-gcc42.diff |
---|
77 | configure.compiler apple-gcc-4.2 |
---|
78 | } |
---|
79 | |
---|
80 | configure.pre_args-delete --prefix=${prefix} |
---|
81 | |
---|
82 | configure.args --with-qt-dir=${prefix} \ |
---|
83 | --with-openssl-dir=${prefix} \ |
---|
84 | --with-gcc=${configure.cc} \ |
---|
85 | --with-g++=${configure.cxx} |
---|
86 | |
---|
87 | # VirtualBox uses kBuild. |
---|
88 | build.cmd ". env.sh && kmk" |
---|
89 | build.env-append VERBOSE=1 |
---|
90 | build.args-append KBUILD_VERBOSE=full |
---|
91 | |
---|
92 | # This is the open source edition of VirtualBox. |
---|
93 | worksrcdir VirtualBox-${version} |
---|
94 | |
---|
95 | set kext_dir /Library/Extensions |
---|
96 | set startup_items_dir /Library/StartupItems |
---|
97 | |
---|
98 | post-patch { |
---|
99 | if {[vercmp $xcodeversion "4.4"] >= 0} { |
---|
100 | set oldest_supported_SDK 10.7 |
---|
101 | } elseif {[vercmp $xcodeversion "4.1"] >= 0} { |
---|
102 | set oldest_supported_SDK 10.6 |
---|
103 | } else { |
---|
104 | set oldest_supported_SDK "10.[expr [lindex [split ${macosx_deployment_target} "."] 1] - 1]" |
---|
105 | } |
---|
106 | |
---|
107 | reinplace "s|@APPLICATIONS_DIR@|${applications_dir}|g" \ |
---|
108 | ${worksrcpath}/LocalConfig.kmk |
---|
109 | reinplace "s|@MACOSX_DEPLOYMENT_TARGET@|${oldest_supported_SDK}|g" \ |
---|
110 | ${worksrcpath}/LocalConfig.kmk |
---|
111 | reinplace "s|@KEXT_DIR@|${prefix}${kext_dir}|g" \ |
---|
112 | ${worksrcpath}/src/VBox/Installer/darwin/VBoxStartupItems/VirtualBox/VirtualBox |
---|
113 | |
---|
114 | if {[variant_isset vde2]} { |
---|
115 | reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/include/VBox/VDEPlugSymDefs.h |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | destroot { |
---|
120 | |
---|
121 | set release_dir [lindex [glob -- ${worksrcpath}/out/darwin.*/release/dist] 0] |
---|
122 | |
---|
123 | xinstall -m 755 -d ${destroot}${applications_dir} |
---|
124 | copy ${release_dir}/VirtualBox.app ${destroot}${applications_dir} |
---|
125 | copy ${release_dir}/sdk ${destroot}${applications_dir}/VirtualBox.app |
---|
126 | |
---|
127 | # Set the owner and group to root:wheel, which is required for kernel extensions |
---|
128 | # and possibly startup items. |
---|
129 | |
---|
130 | xinstall -m 755 -o root -g wheel -d ${destroot}${prefix}${kext_dir} |
---|
131 | |
---|
132 | foreach kext [glob -- ${release_dir}/*.kext] { |
---|
133 | copy ${kext} ${destroot}${prefix}${kext_dir} |
---|
134 | } |
---|
135 | |
---|
136 | xinstall -m 755 -o root -g wheel -d ${destroot}${prefix}${startup_items_dir} |
---|
137 | copy ${worksrcpath}/src/VBox/Installer/darwin/VBoxStartupItems/VirtualBox ${destroot}${prefix}${startup_items_dir} |
---|
138 | |
---|
139 | # Create proxies for binaries bundled with VirtualBox.app. |
---|
140 | |
---|
141 | foreach app_proxy [list VirtualBox VBoxBalloonCtrl VBoxManage VBoxHeadless] { |
---|
142 | |
---|
143 | set app_proxy_file [open ${destroot}${prefix}/bin/${app_proxy} w] |
---|
144 | |
---|
145 | puts $app_proxy_file "#!/usr/bin/env bash" |
---|
146 | puts $app_proxy_file "exec -- ${applications_dir}/VirtualBox.app/Contents/MacOS/${app_proxy} \"\$@\"" |
---|
147 | |
---|
148 | close $app_proxy_file |
---|
149 | |
---|
150 | file attributes ${destroot}${prefix}/bin/${app_proxy} -permissions "+x" |
---|
151 | } |
---|
152 | |
---|
153 | foreach executable [list VirtualBox VirtualBoxVM VBoxHeadless VBoxNetAdpCtl VBoxNetDHCP] { |
---|
154 | file attributes ${destroot}${applications_dir}/VirtualBox.app/Contents/MacOS/${executable} -permissions "u+s" |
---|
155 | } |
---|
156 | } |
---|
157 | |
---|
158 | pre-activate { |
---|
159 | |
---|
160 | set head_path ${applications_dir} |
---|
161 | |
---|
162 | while {${head_path} != "/"} { |
---|
163 | |
---|
164 | if {[file attributes ${head_path} -owner] != "root" || [file attributes ${head_path} -group] != "admin" |
---|
165 | || [expr [file attributes ${head_path} -permissions] & 00002] != 0} { |
---|
166 | error "VirtualBox requires the \"${applications_dir}\" directory and its parent directories to be\ |
---|
167 | root:admin owned and not world writeable." |
---|
168 | } |
---|
169 | |
---|
170 | set head_path [file dirname ${head_path}] |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | variant vde2 description {Enable support for VDE} { |
---|
175 | |
---|
176 | depends_lib-append port:vde2 |
---|
177 | patchfiles-append patch-vde.diff |
---|
178 | configure.args-append --enable-vde |
---|
179 | } |
---|
180 | |
---|
181 | variant vnc description {Enable support for VNC} { |
---|
182 | |
---|
183 | depends_lib-append port:LibVNCServer |
---|
184 | configure.args-append --enable-vnc |
---|
185 | } |
---|
186 | |
---|
187 | default_variants +vde2 +vnc |
---|
188 | |
---|
189 | startupitem.create yes |
---|
190 | startupitem.name VirtualBox |
---|
191 | startupitem.start "${prefix}${startup_items_dir}/VirtualBox/VirtualBox start" |
---|
192 | startupitem.stop "${prefix}${startup_items_dir}/VirtualBox/VirtualBox stop" |
---|
193 | startupitem.restart "${prefix}${startup_items_dir}/VirtualBox/VirtualBox restart" |
---|
194 | startupitem.pidfile none |
---|
195 | |
---|
196 | livecheck.type regex |
---|
197 | if {[lindex [split ${version} .] 2] == 0} { |
---|
198 | livecheck.version [join [lrange [split ${version} .] 0 1] .] |
---|
199 | } |
---|
200 | livecheck.url ${homepage} |
---|
201 | livecheck.regex "VirtualBox (\\d+\\.\\d+(?:\\.\\d+)?) released!" |
---|
202 | |
---|
203 | } |
---|
204 | |
---|
205 | subport virtualbox-guest-additions { |
---|
206 | |
---|
207 | license VirtualBoxPUEL |
---|
208 | |
---|
209 | description guest additions for VirtualBox |
---|
210 | |
---|
211 | long_description ${description} |
---|
212 | |
---|
213 | supported_archs noarch |
---|
214 | |
---|
215 | distfiles VBoxGuestAdditions_${version}.iso |
---|
216 | |
---|
217 | checksums rmd160 335365fbe7406aa0a0d3c0b886f0330b611b6ece \ |
---|
218 | sha256 cf2b0722da984a5f41a7814ee288262cbdf4c785630b2a7726c3daa6c5caa0c5 |
---|
219 | |
---|
220 | depends_run port:virtualbox |
---|
221 | |
---|
222 | extract.only |
---|
223 | |
---|
224 | use_configure no |
---|
225 | |
---|
226 | build {} |
---|
227 | |
---|
228 | destroot { |
---|
229 | set dir ${destroot}${applications_dir}/VirtualBox.app/Contents/MacOS/additions |
---|
230 | xinstall -d ${dir} |
---|
231 | copy ${distpath}/${distfiles} ${dir}/VBoxGuestAdditions.iso |
---|
232 | } |
---|
233 | |
---|
234 | livecheck.type none |
---|
235 | } |
---|
236 | |
---|
237 | subport virtualbox-extension-pack { |
---|
238 | |
---|
239 | # We want to match the supported arch |
---|
240 | set kernel_arch [exec uname -m] |
---|
241 | switch ${kernel_arch} { |
---|
242 | i386 - |
---|
243 | x86_64 { |
---|
244 | supported_archs ${kernel_arch} |
---|
245 | } |
---|
246 | default { |
---|
247 | supported_archs i386 x86_64 |
---|
248 | } |
---|
249 | } |
---|
250 | array set archs_map { |
---|
251 | i386 "darwin.x86" |
---|
252 | x86_64 "darwin.amd64" |
---|
253 | } |
---|
254 | set extension_archs {} |
---|
255 | foreach {arch} ${supported_archs} { |
---|
256 | lappend extension_archs $archs_map($arch) |
---|
257 | } |
---|
258 | set name_extpack Oracle_VM_VirtualBox_Extension_Pack |
---|
259 | set app_dir VirtualBox.app |
---|
260 | set lib_dir ${app_dir}/Contents/MacOS |
---|
261 | set ext_dir ${lib_dir}/ExtensionPacks |
---|
262 | |
---|
263 | version ${version}-${extension_pack_build} |
---|
264 | |
---|
265 | license VirtualBoxPUEL |
---|
266 | |
---|
267 | description Oracle VM VirtualBox Extension Pack |
---|
268 | long_description ${description} |
---|
269 | |
---|
270 | depends_run port:virtualbox |
---|
271 | |
---|
272 | distname ${name_extpack}-${version} |
---|
273 | |
---|
274 | checksums rmd160 b41596eba7d8b402e0030eaa651898cacc8b1d3b \ |
---|
275 | sha256 8f88b1ebe69b770103e9151bebf6681c5e049eb5fac45ae8d52c43440aa0fa0d |
---|
276 | |
---|
277 | worksrcdir ${name_extpack} |
---|
278 | extract.suffix .vbox-extpack |
---|
279 | extract.mkdir yes |
---|
280 | |
---|
281 | use_configure no |
---|
282 | |
---|
283 | build { |
---|
284 | |
---|
285 | # The pre-built libraries use weird prefixes and Oracle recommends setting |
---|
286 | # DYLD_LIBRARY_PATH to deal with this. I would rather fix the paths in the |
---|
287 | # libraries at install time. |
---|
288 | foreach {arch} $extension_archs { |
---|
289 | |
---|
290 | foreach lib [glob -directory ${worksrcpath}/${arch} *.dylib*] { |
---|
291 | |
---|
292 | system "install_name_tool -id ${applications_dir}/${ext_dir}/${name_extpack}/${arch}/[strsed ${lib} /^.*\\///] ${lib}" |
---|
293 | |
---|
294 | # Then for each dependent dylib with a weird path that this dylib |
---|
295 | # references, fix the reference to use ${lib_dir}. |
---|
296 | foreach dep [exec otool -L ${lib}] { |
---|
297 | |
---|
298 | if [string match "/Applications/${lib_dir}/*" ${dep}] { |
---|
299 | |
---|
300 | system "install_name_tool -change ${dep} ${applications_dir}/${lib_dir}/[strsed ${dep} /^.*\\///] ${lib}" |
---|
301 | } |
---|
302 | } |
---|
303 | } |
---|
304 | } |
---|
305 | } |
---|
306 | |
---|
307 | destroot { |
---|
308 | |
---|
309 | xinstall -d -o root -g admin -m 755 ${destroot}${applications_dir}/${ext_dir}/${name_extpack} |
---|
310 | foreach {f} [glob -directory ${worksrcpath} -type f *] { |
---|
311 | |
---|
312 | xinstall -o "root" -g "admin" -m 0644 ${f} \ |
---|
313 | ${destroot}${applications_dir}/${ext_dir}/${name_extpack} |
---|
314 | } |
---|
315 | foreach {arch} $extension_archs { |
---|
316 | |
---|
317 | xinstall -o "root" -g "admin" -m 0755 -d \ |
---|
318 | ${destroot}${applications_dir}/${ext_dir}/${name_extpack}/${arch} |
---|
319 | foreach {f} [glob -directory ${worksrcpath}/${arch} *] { |
---|
320 | |
---|
321 | xinstall -o "root" -g "admin" -m 0644 ${f} \ |
---|
322 | ${destroot}${applications_dir}/${ext_dir}/${name_extpack}/${arch} |
---|
323 | } |
---|
324 | } |
---|
325 | } |
---|
326 | |
---|
327 | livecheck.type regex |
---|
328 | livecheck.url https://www.virtualbox.org/wiki/Downloads |
---|
329 | livecheck.regex "/Oracle_VM_VirtualBox_Extension_Pack-(\\d(?!\\${extract.suffix}).*)\\${extract.suffix}" |
---|
330 | } |
---|