summaryrefslogtreecommitdiffstats
path: root/src/VBox/Additions/darwin/Installer/Makefile.kmk
blob: a1e78c161db4315f0f046529d9e69073f8a943f0 (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# $Id: Makefile.kmk $
## @file
# Install misc stuff and create dist packages for Mac OS X Guest Additions.
#

#
# Copyright (C) 2006-2019 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#

SUB_DEPTH = ../../../../..
include $(KBUILD_PATH)/subheader.kmk


#
# Globals
#
VBOX_ADD_PATH_DI_SRC := $(PATH_SUB_CURRENT)
VBOX_ADD_DI_OUT_DIR  := $(PATH_TARGET)/additions/Installer
BLDDIRS += $(VBOX_ADD_DI_OUT_DIR)

ifdef VBOX_WITH_COMBINED_PACKAGE
 ifeq ($(KBUILD_TARGET_ARCH),x86)
  VBOX_PATH_DIST_32 = $(VBOX_PATH_DIST)/additions
  VBOX_PATH_DIST_64 = $(PATH_OUT_BASE)/darwin.amd64/$(KBUILD_TYPE)/dist/additions
 else
  VBOX_PATH_DIST_64 = $(VBOX_PATH_DIST)/additions
  VBOX_PATH_DIST_32 = $(PATH_OUT_BASE)/darwin.x86/$(KBUILD_TYPE)/dist
 endif
 VBOX_DI_FN_DEP_BOTH = $(VBOX_PATH_DIST_32)/$1 $(VBOX_PATH_DIST_64)/$2
 VBOX_DI_FN_DEP_32   = $(VBOX_PATH_DIST_32)/$1
 VBOX_DI_FN_DEP_64   = $(VBOX_PATH_DIST_64)/$1
 VBOX_DI_LIPO = lipo
else
 VBOX_DI_FN_DEP_BOTH = $(VBOX_PATH_DIST)/additions/$1
 ifeq ($(KBUILD_TARGET_ARCH),x86)
  VBOX_DI_FN_DEP_32  = $(VBOX_PATH_DIST)/additions/$1
  VBOX_DI_FN_DEP_64  =
 else
  VBOX_DI_FN_DEP_64  = $(VBOX_PATH_DIST)/additions/$1
  VBOX_DI_FN_DEP_32  =
 endif
endif

# Unset this to speed up things during makefile hacking.
VBOX_DARWIN_INST_DEP_ON_MAKEFILE := $(MAKEFILE_CURRENT)

# The location of the pkgbuild program.
ifndef VBOX_PKGBUILD
 VBOX_PKGBUILD := pkgbuild
endif

# The location of the productbuild program.
ifndef VBOX_PRODUCTBUILD
 VBOX_PRODUCTBUILD := productbuild
endif

# Where we do the packing (override this in LocalConfig.kmk if building on smbfs).
ifndef VBOX_PATH_PACK_TMP
 VBOX_PATH_PACK_TMP := $(VBOX_ADD_DI_OUT_DIR)
endif


#
# The packing.
#
PACKING += \
	$(PATH_STAGE)/$(INST_ADDITIONS)VBoxGuestAdditions.pkg \
	$(PATH_STAGE)/$(INST_ADDITIONS)VBoxDarwinAdditionsUninstall.tool

#OTHER_CLEAN = TODO


include $(FILE_KBUILD_SUB_FOOTER)


#
# We're running commands as root here, take some care and assertion
# a sane environment.
#
ifeq ($(strip $(VBOX_PATH_DIST)),)
 $(error VBOX_PATH_DIST=$(VBOX_PATH_DIST))
endif
ifeq ($(strip $(VBOX_PATH_DIST)),/)
 $(error VBOX_PATH_DIST=$(VBOX_PATH_DIST))
endif
ifeq ($(strip $(VBOX_PATH_PACK_TMP)),)
 $(error VBOX_PATH_PACK_TMP=$(VBOX_PATH_PACK_TMP))
endif
ifeq ($(strip $(VBOX_PATH_PACK_TMP)),/)
 $(error VBOX_PATH_PACK_TMP=$(VBOX_PATH_PACK_TMP))
endif

#
# The packing targets.
#
$(PATH_STAGE)/$(INST_ADDITIONS)VBoxGuestAdditions.pkg: $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditions.pkg
	$(MKDIR) -p "$(@D)"
	$(INSTALL) -m 0644 -- "$<" "$@"

$(PATH_STAGE)/$(INST_ADDITIONS)VBoxDarwinAdditionsUninstall.tool: $(VBOX_ADD_PATH_DI_SRC)/DiskImage/Uninstall.tool
	$(MKDIR) -p "$(@D)"
	$(INSTALL) -m 0755 -- "$<" "$@"


#
# The meta-package.
#
$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditions.pkg: \
		$(VBOX_PATH_PACK_TMP)/Packages/VBoxGuestAdditionsKEXTs.pkg \
		$(VBOX_PATH_PACK_TMP)/Packages/VBoxGuestAdditionsToolsAndServices.pkg \
		$$(wildcard $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/* \
		            $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/*.lproj/*) \
		$(foreach f,$(VBOX_INSTALLER_ADD_LANGUAGES), $(VBOX_BRAND_$(f)_VIRTUALBOX_WELCOME_RTF)) \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/Welcome.rtf \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/Conclusion.rtf \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/distribution-$(KBUILD_TARGET_ARCH).dist \
		$(VBOX_DARWIN_INST_DEP_ON_MAKEFILE)
	$(call MSG_TOOL,productbuild,,,$@)
	@# Cleanup any previously failed attempts.
	sudo rm -Rf \
		$@ \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.root \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.desc \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res
	@# Correct directory permissions are important.
	$(MKDIR) -p \
		$(@D) \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.desc \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/English.lproj

	@# Do keyword replacement in the package info and description files.
	$(SED) \
		-e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
		-e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
		-e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
		-e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
		-e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
		-e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
		-e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
		--output $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/English.lproj/Welcome.rtf \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/Welcome.rtf
	@# Copy the resources.
	$(INSTALL) -m 0644 $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/Conclusion.rtf $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/English.lproj/Conclusion.rtf

	$(SED) \
		-e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
		-e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
		-e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
		--output $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/English.lproj/Localizable.strings \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/Localizable.strings
	$(INSTALL) -m 0644 $(VBOX_BRAND_DARWIN_INSTALLER_BG)                          $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/background.tif

	$(foreach f,$(VBOX_INSTALLER_ADD_LANGUAGES), \
		$(MKDIR) -p \
			$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/$(VBOX_INSTALLER_$(f)_DARWIN_TARGET).lproj$(NLTAB) \
		$(SED) \
			-e 's/@VBOX_VERSION_STRING@/$(VBOX_VERSION_STRING)/g' \
			-e 's/@VBOX_VERSION_MAJOR@/$(VBOX_VERSION_MAJOR)/g' \
			-e 's/@VBOX_VERSION_MINOR@/$(VBOX_VERSION_MINOR)/g' \
			-e 's/@VBOX_VERSION_BUILD@/$(VBOX_VERSION_BUILD)/g' \
			--output $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/$(VBOX_INSTALLER_$(f)_DARWIN_TARGET).lproj/Welcome.rtf \
			$(VBOX_BRAND_$(f)_VIRTUALBOX_WELCOME_RTF)$(NLTAB) \
		$(INSTALL) -m 0644 $(VBOX_BRAND_$(f)_VIRTUALBOX_CONCLUSION_RTF)           $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/$(VBOX_INSTALLER_$(f)_DARWIN_TARGET).lproj/Conclusion.rtf$(NLTAB) \
		$(SED) \
			-e 's/@VBOX_VENDOR@/$(VBOX_VENDOR)/g' \
			-e 's/@VBOX_PRODUCT@/$(VBOX_PRODUCT)/g' \
			-e 's/@VBOX_C_YEAR@/$(VBOX_C_YEAR)/g' \
			--output $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res/$(VBOX_INSTALLER_$(f)_DARWIN_TARGET).lproj/Localizable.strings \
			$(VBOX_BRAND_$(f)_VIRTUALBOX_LOCALIZABLE_STRINGS)$(NLTAB) \
	)

	@# Build the package.
	$(VBOX_PRODUCTBUILD) \
		--distribution $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditions_mpkg/distribution-$(KBUILD_TARGET_ARCH).dist \
		--package-path $(VBOX_PATH_PACK_TMP)/Packages \
		--resources $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res \
		--identifier org.VirtualBox.mpkg.GuestAdditions \
		--version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
		$(if $(VBOX_MACOSX_INSTALLER_SIGN),--sign "$(VBOX_MACOSX_INSTALLER_SIGN)",) \
		$@

	@# Cleanup.
	sudo rm -Rf \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.root \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.desc \
		$(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.dist.res

VBoxDarwinAdditions.pkg:: $(VBOX_PATH_PACK_TMP)/VBoxDarwinAdditions.pkg

#
# The VirtualBox Kernel extensions.
#
VBOX_ADD_DI_KEXTS_UNIVERSAL = VBoxGuest
VBOX_ADD_DI_KEXTS = $(VBOX_ADD_DI_KEXTS_UNIVERSAL)

$(VBOX_PATH_PACK_TMP)/Packages/VBoxGuestAdditionsKEXTs.pkg: \
		$(foreach kext,$(VBOX_ADD_DI_KEXTS_UNIVERSAL), $(call VBOX_DI_FN_DEP_BOTH,$(kext).kext/Contents/MacOS/$(kext))) \
		$(foreach kext,$(VBOX_ADD_DI_KEXTS), $(VBOX_PATH_DIST)/additions/$(kext).kext/Contents/Info.plist) \
		$$(wildcard $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsKEXTs/* \
		            $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsKEXTs/*.lproj/*) \
		$(foreach f,$(VBOX_INSTALLER_ADD_LANGUAGES), \
			$(VBOX_BRAND_$(f)_VBOXKEXTS_DESCRIPTION_PLIST) \
			$(VBOX_BRAND_$(f)_VBOXKEXTS_README_HTML) \
			$(VBOX_BRAND_$(f)_VBOXKEXTS_INSTALLATIONCHECK_STRINGS)) \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsKEXTs/postflight \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsKEXTs/PkgBuildComponent.plist \
		$(VBOX_DARWIN_INST_DEP_ON_MAKEFILE)
	$(call MSG_TOOL,pkgbuild,,,$@)
	@# Cleanup any previously failed attempts.
	sudo rm -Rf \
		$@ \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.desc \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.res
	@# Correct directory permissions are important.
	$(MKDIR) -p \
		$(@D) \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.desc \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.res \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.res/English.lproj
	$(MKDIR) -p -m 1775 $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library
	$(MKDIR) -p -m 0755 \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions \
		$(foreach kext,$(VBOX_ADD_DI_KEXTS), \
			$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions/$(kext).kext \
			$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions/$(kext).kext/Contents \
			$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions/$(kext).kext/Contents/MacOS )
	@# Copy the common files (Info.plist).
	$(foreach kext,$(VBOX_ADD_DI_KEXTS), \
		$(NLTAB)$(INSTALL) -m 0644 $(VBOX_PATH_DIST)/additions/$(kext).kext/Contents/Info.plist $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions/$(kext).kext/Contents/)
	@# Copy the binaries and invoking lipo.
ifdef VBOX_WITH_COMBINED_PACKAGE
	$(foreach kext,$(VBOX_ADD_DI_KEXTS_UNIVERSAL), \
		$(NLTAB)$(VBOX_DI_LIPO) -create \
			$(VBOX_PATH_DIST_32)/additions/$(kext).kext/Contents/MacOS/$(kext) \
			$(VBOX_PATH_DIST_64)/additions/$(kext).kext/Contents/MacOS/$(kext) \
			-output $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions/$(kext).kext/Contents/MacOS/$(kext))
else
	$(foreach kext,$(VBOX_ADD_DI_KEXTS), \
		$(NLTAB)$(INSTALL) -m 0755 $(VBOX_PATH_DIST)/additions/$(kext).kext/Contents/MacOS/$(kext) $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions/$(kext).kext/Contents/MacOS/)
endif
	@# Signed the kext bundles.
ifdef VBOX_SIGNING_MODE
	$(foreach kext,$(VBOX_ADD_DI_KEXTS), \
		$(NLTAB)$(call VBOX_SIGN_BUNDLE_FN,$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions/$(kext).kext,) )
endif
	@# Set the correct owners.
	sudo chown    root:admin $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library
	sudo chown -R root:wheel $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions

	# Copy package internal files
	$(INSTALL) $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsKEXTs/PkgBuildComponent.plist $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.desc/PkgBuildComponent.plist

	# Copy installer scripts
	$(INSTALL) -m 0755 $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsKEXTs/postflight $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.res

	@# Build the package.
	$(VBOX_PKGBUILD) \
		--root   $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root/Library/Extensions/ \
		--component-plist $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.desc/PkgBuildComponent.plist \
		--script $(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.res \
		--identifier org.virtualbox.pkg.additions.kexts \
		--version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
		--install-location /Library/Extensions/ \
		--ownership preserve \
		$(if $(VBOX_MACOSX_INSTALLER_SIGN),--sign "$(VBOX_MACOSX_INSTALLER_SIGN)",) \
		$@
	@# Cleanup
	sudo rm -Rf \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.root \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.desc \
		$(VBOX_PATH_PACK_TMP)/VBoxGuestAdditionsKEXTs.pkg.res

#
# The VirtualBox Guest Additions Tools & Services.
#

VBOX_GA_PKG=VBoxGuestAdditionsToolsAndServices.pkg
VBOX_DI_VB_GA_BINARIES=VBoxClient VBoxControl VBoxService
$(VBOX_PATH_PACK_TMP)/Packages/$(VBOX_GA_PKG): \
		$(foreach f, $(VBOX_DI_VB_GA_BINARIES)\
			,$(call VBOX_DI_FN_DEP_BOTH,$(f)) ) \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsToolsAndServices/org.virtualbox.additions.vboxclient.plist \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsToolsAndServices/org.virtualbox.additions.vboxservice.plist \
		$(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsToolsAndServices/VBoxServiceWrapper \
		$(VBOX_ADD_PATH_DI_SRC)/DiskImage/Uninstall.tool \
		$(VBOX_DARWIN_INST_DEP_ON_MAKEFILE)
	$(call MSG_TOOL,pkgbuild,,,$@)
	@# Cleanup any previously failed attempts.
	sudo rm -Rf \
		$@ \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).desc \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).res
	@# Correct directory permissions are important.
	$(MKDIR) -p \
		$(@D) \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).desc \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).res \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).res/English.lproj

	@# Create directory structure within a package w/ proper permittions
	$(MKDIR) -p -m 0775 \
	    "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/Application Support/VirtualBox Guest Additions" \
	    "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/LaunchAgents" \
	    "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/LaunchDaemons"

	@# Install binaries
ifdef VBOX_WITH_COMBINED_PACKAGE
	$(foreach binary, $(VBOX_DI_VB_GA_BINARIES) \
		,$(VBOX_DI_LIPO) -create \
			$(VBOX_PATH_DIST_32)/additions/$(binary) \
			$(VBOX_PATH_DIST_64)/additions/$(binary) \
			-output "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/Application Support/VirtualBox Guest Additions/$(binary)"$(NLTAB))
	$(foreach binary, $(VBOX_DI_VB_GA_BINARIES), \
		$(NLTAB)$(INSTALL) -m 0755 $(VBOX_PATH_DIST_32)/additions/$(binary) "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/Application Support/VirtualBox Guest Additions/$(binary)-x86" \
		$(NLTAB)$(INSTALL) -m 0755 $(VBOX_PATH_DIST_64)/additions/$(binary) "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/Application Support/VirtualBox Guest Additions/$(binary)-amd64" )
else
	$(foreach binary, $(VBOX_DI_VB_GA_BINARIES) \
		,$(INSTALL) -m 0755 $(VBOX_PATH_DIST)/additions/$(binary)           "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/Application Support/VirtualBox Guest Additions/$(binary)"$(NLTAB))
	$(foreach binary, $(VBOX_DI_VB_GA_BINARIES) \
		,$(INSTALL) -m 0755 $(VBOX_PATH_DIST)/additions/$(binary)           "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/Application Support/VirtualBox Guest Additions/$(binary)-$(KBUILD_TARGET_ARCH)"$(NLTAB))
endif
	# Add Uninstall.tool
	$(INSTALL) $(VBOX_ADD_PATH_DI_SRC)/DiskImage/Uninstall.tool  "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/Application Support/VirtualBox Guest Additions/" \

	@# Install launchd stuff
	$(INSTALL) -m 0755 $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsToolsAndServices/VBoxServiceWrapper \
	                                                                         "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/Application Support/VirtualBox Guest Additions/"
	$(INSTALL) -m 644 $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsToolsAndServices/org.virtualbox.additions.vboxclient.plist \
	                                                                         "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/LaunchAgents/"
	$(INSTALL) -m 644 $(VBOX_ADD_PATH_DI_SRC)/VBoxGuestAdditionsToolsAndServices/org.virtualbox.additions.vboxservice.plist \
	                                                                         "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/LaunchDaemons/"

	@# Correct ownership
	sudo chown -R root:wheel "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/"

	@# Build the package.
	$(VBOX_PKGBUILD) \
		--root   "$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root/Library/" \
		--script $(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).res \
		--identifier org.virtualbox.pkg.additions.tools-and-services \
		--version $(VBOX_VERSION_MAJOR).$(VBOX_VERSION_MINOR).$(VBOX_VERSION_BUILD) \
		--install-location "/Library/" \
		--ownership preserve \
		$(if $(VBOX_MACOSX_INSTALLER_SIGN),--sign "$(VBOX_MACOSX_INSTALLER_SIGN)",) \
		$@
	@# Cleanup
	sudo rm -Rf \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).root \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).desc \
		$(VBOX_PATH_PACK_TMP)/$(VBOX_GA_PKG).res