VirtualBox

source: vbox/trunk/debian/rules@ 44676

Last change on this file since 44676 was 44676, checked in by vboxsync, 12 years ago

Installer/linux: no need to have two different versions of VBox.sh; more
tabs.

  • Property svn:executable set to *
File size: 16.4 KB
Line 
1#!/usr/bin/make -f
2#
3# Copyright (C) 2006-2012 Oracle Corporation
4#
5# This file is part of VirtualBox Open Source Edition (OSE), as
6# available from http://www.virtualbox.org. This file is free software;
7# you can redistribute it and/or modify it under the terms of the GNU
8# General Public License (GPL) as published by the Free Software
9# Foundation, in version 2 as it comes in the "COPYING" file of the
10# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
12#
13
14#export DH_VERBOSE=1
15export DH_COMPAT=4
16
17# possible overrides:
18# OSE=1 force VBOX_OSE
19# NOPARALLEL=1 compile with -j1
20# LINUX=<dir> compile vboxdrv against Linux found in <dir>
21# VERBOSE=1 verbose build
22# DEBUG=1 debug build
23# NOSUBVER=1 disable generation of the sub-version field (which is
24# either the subversion rev [if available] or the build date)
25# NODOCS=1 don't build docs, use precompiled UserManual.pdf and
26# VirtualBox.chm from $HOME
27# NOMODS=1 don't build any module
28# NOQT=1 don't build the Qt GUI
29# EFI=1 include the EFI binary from prebuild
30# HEADLESS=1 build the headless version
31# VNC=1 build VNC code
32# NOWEBSVC=1 don't build the webservice API, default for OSE
33# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
34# PKGDIR=<path> where to store the final package(s)
35# BLEEDING_EDGE=xyz
36
37package := virtualbox
38verpkg := virtualbox-ose
39current := $(shell pwd)
40vboxroot := $(shell pwd)
41pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ..; pwd))
42builddir := $(current)/debian/builddir
43moddir := $(current)/debian/modules
44prefix := $(current)/debian/$(verpkg)
45arch := $(shell dpkg --print-architecture)
46verfile := $(builddir)/version-generated.mk
47ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
48svnrev := 0
49NOMODS ?= $(ose)
50NOQT ?= $(HEADLESS)
51NOWEBSVC ?= $(ose)
52NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
53
54ifneq ($(wildcard $(verfile)),)
55include $(verfile)
56ver := $(VBOX_VERSION_STRING)
57archdir := $(prefix)/opt/VirtualBox-$(ver)
58endif
59
60ifneq ($(STAGEDISO),)
61 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
62 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
63 endif
64endif
65
66debrel := $(if $(shell which lsb_release),_$(shell lsb_release -si)_$(shell lsb_release -sc),unknown)
67
68# shipping Linux kernel modules with bleeding-edge releases doesn't make sense
69instmod := $(if $(filter _Ubuntu_lucid _Ubuntu_maverick _Ubuntu_natty _Ubuntu_oneiric _Debian_sid,$(debrel)),,1)
70
71# Location of custom built Qt libraries (see below)
72qtstdc6 := /home/vbox/Qt-4.7.4-stdc++6-$(arch)
73
74cfg_flags := $(if $(NOQT),--disable-qt,) \
75 $(if $(filter _Ubuntu_hardy _Debian_lenny,$(debrel)),--with-qt4-dir=$(qtstdc6)) \
76 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
77 $(if $(HEADLESS),--build-headless,) \
78 $(if $(DEBUG),--build-debug,) \
79 $(if $(NOWINE),,--setup-wine) \
80 $(if $(NOWEBSVC),,--enable-webservice) \
81 $(if $(VNC),--enable-vnc,) \
82 --disable-extpack
83
84bld_flags := AUTOCFG=$(current)/debian/AutoConfig.kmk \
85 LOCALCFG=$(current)/debian/LocalConfig.kmk \
86 PATH_OUT=$(builddir) \
87 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
88 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
89 VBOX_DO_STRIP= \
90 VBOX_DO_STRIP_MODULES= \
91 VBOX_WITH_MULTIVERSION_PYTHON= \
92 VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\"" \
93 $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
94 VBOX_SVN_REV=$(svnrev) \
95 $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
96 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
97 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
98 $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
99 $(if $(filter _Ubuntu_hardy,$(debrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
100
101configure: debian/configure-stamp
102debian/configure-stamp:
103 dh_testdir
104 cd $(vboxroot) && ./configure --odir=$(current)/debian $(cfg_flags)
105 touch debian/configure-stamp
106
107build: debian/configure-stamp debian/build-stamp
108debian/build-stamp $(verfile):
109 dh_testdir
110 . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
111 $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
112 $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
113 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
114 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
115 mkdir -p $(builddir)/bin/additions
116 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
117 . debian/env.sh && kmk -C $(vboxroot) $(bld_flags) \
118 VBOX_NO_LINUX_RUN_INSTALLER=1 \
119 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86-r$(svnrev).tar.bz2 \
120 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64-r$(svnrev).tar.bz2 \
121 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
122 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
123 packing
124 touch debian/build-stamp
125
126# Build modules for every kernel we find in /lib/modules/*
127modules: debian/build-stamp debian/modules-stamp
128debian/modules-stamp: debian/build-stamp
129 rm -rf $(moddir)
130 mkdir $(moddir)
131 make -C $(builddir)/bin/src/vboxdrv clean
132 for d in $(wildcard /lib/modules/*); do \
133 if [ -L $$d/build ]; then \
134 make -C $(builddir)/bin/src/vboxdrv KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
135 make -j4 -C $(builddir)/bin/src/vboxdrv KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
136 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
137 $(builddir)/bin/src/vboxdrv/vboxdrv.ko $(moddir)/$$(basename $$d)/vboxdrv.ko); \
138 make -C $(builddir)/bin/src/vboxnetflt KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
139 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetflt || true) && \
140 make -j4 -C $(builddir)/bin/src/vboxnetflt KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
141 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
142 $(builddir)/bin/src/vboxnetflt/vboxnetflt.ko $(moddir)/$$(basename $$d)/vboxnetflt.ko); \
143 make -C $(builddir)/bin/src/vboxnetadp KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
144 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxnetadp || true) && \
145 make -j4 -C $(builddir)/bin/src/vboxnetadp KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
146 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
147 $(builddir)/bin/src/vboxnetadp/vboxnetadp.ko $(moddir)/$$(basename $$d)/vboxnetadp.ko); \
148 make -C $(builddir)/bin/src/vboxpci KERN_DIR=$$d/build MODULE_DIR=$$d clean && \
149 (cp $(builddir)/bin/src/vboxdrv/Module.symvers $(builddir)/bin/src/vboxpci || true) && \
150 make -j4 -C $(builddir)/bin/src/vboxpci KBUILD_VERBOSE= KERN_DIR=$$d/build MODULE_DIR=$$d all \
151 $(if $(instmod),&& install -D -m 0644 -g 0 -o 0 \
152 $(builddir)/bin/src/vboxpci/vboxpci.ko $(moddir)/$$(basename $$d)/vboxpci.ko); \
153 fi; \
154 done
155 make -C $(builddir)/bin/src/vboxdrv clean
156 make -C $(builddir)/bin/src/vboxnetflt clean
157 make -C $(builddir)/bin/src/vboxnetadp clean
158 make -C $(builddir)/bin/src/vboxpci clean
159 touch debian/modules-stamp
160
161clean:
162 dh_testdir
163 dh_testroot
164 rm -f debian/preinst debian/postinst debian/prerm
165 rm -f debian/$(package).init debian/vboxdrv.init
166 rm -f debian/vboxballoonctrl-service.init debian/vboxautostart-service.init debian/vboxweb-service.init
167 rm -f debian/AutoConfig.kmk debian/configure.log debian/env.sh
168 rm -f debian/modules-stamp debian/build-stamp debian/configure-stamp
169 rm -f debian/virtualbox-*.substvars debian/virtualbox*.debhelper
170 rm -f debian/$(verpkg).mime
171 rm -rf $(builddir) $(moddir)
172 rm -rf debian/wine.*
173 dh_clean
174
175ifeq ($(VBOX_VERSION_MAJOR),)
176binary binary-arch binary-indep: build $(verfile)
177 $(MAKE) -f debian/rules binary
178else
179# Build architecture-dependent files here.
180binary binary-arch binary-indep: build $(if $(NOMODS),,modules)
181 dh_testdir
182 dh_testroot
183 dh_clean -k
184 dh_installdirs
185 tar -xjC $(prefix)/opt -f $(builddir)/bin/VirtualBox.tar.bz2
186 install -d -g 0 -o 0 $(prefix)/usr/share/applications
187 install -d -g 0 -o 0 $(prefix)/usr/lib
188 install -d -g 0 -o 0 $(prefix)/usr/bin
189 install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)
190 install -d -g 0 -o 0 $(prefix)/usr/share/$(package)
191 install -d -g 0 -o 0 $(prefix)/usr/share/doc/$(verpkg)
192 $(if $(NOQT),,mv $(archdir)/virtualbox.desktop \
193 $(prefix)/usr/share/applications/virtualbox.desktop)
194 install -d -g 0 -o 0 $(prefix)/usr/share/pixmaps
195 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor
196 cp $(archdir)/icons/128x128/virtualbox.png \
197 $(prefix)/usr/share/pixmaps/virtualbox.png
198 cd $(archdir)/icons; for i in *; do \
199 if [ -f $$i/virtualbox.png ]; then \
200 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/apps; \
201 mv $$i/virtualbox.png $(prefix)/usr/share/icons/hicolor/$$i/apps; \
202 fi; \
203 install -d -g 0 -o 0 $(prefix)/usr/share/icons/hicolor/$$i/mimetypes; \
204 mv $$i/* $(prefix)/usr/share/icons/hicolor/$$i/mimetypes || true; \
205 rmdir $$i; \
206 done
207 rmdir $(archdir)/icons
208 install -d -g 0 -o 0 $(prefix)/usr/lib/$(package)/ExtensionPacks
209 mv $(archdir)/virtualbox.xml debian/$(verpkg).sharedmimeinfo
210 install -d -g 0 -o 0 $(prefix)/usr/share/lintian/overrides
211 sed \
212 -e 's|%VERPKG%|$(verpkg)|g' \
213 debian/lintian-override.in > \
214 $(prefix)/usr/share/lintian/overrides/$(verpkg)
215 mv $(archdir)/VBoxEFI32.fd $(prefix)/usr/lib/$(package)
216 mv $(archdir)/VBoxEFI64.fd $(prefix)/usr/lib/$(package)
217 mv $(archdir)/VBox.png \
218 $(prefix)/usr/share/pixmaps/VBox.png
219 mv $(archdir)/*.gc $(prefix)/usr/lib/$(package)
220 mv $(archdir)/*.r0 $(prefix)/usr/lib/$(package)
221 mv $(archdir)/*.rel $(prefix)/usr/lib/$(package) || true
222 mv $(archdir)/VBoxNetDHCP $(prefix)/usr/lib/$(package)
223 mv $(archdir)/VBoxNetAdpCtl $(prefix)/usr/lib/$(package)
224 if [ -f $(archdir)/VBoxVolInfo ]; then
225 mv $(archdir)/VBoxVolInfo $(prefix)/usr/lib/$(package)
226 fi
227 mv $(archdir)/VBoxXPCOMIPCD $(prefix)/usr/lib/$(package)
228 mv $(archdir)/components $(prefix)/usr/lib/$(package)/components
229 mv $(archdir)/*.so $(prefix)/usr/lib/$(package)
230 mv $(archdir)/*.so.4 $(prefix)/usr/lib/$(package) || true
231 $(if $(NOQT),,mv $(archdir)/VBoxTestOGL $(prefix)/usr/lib/$(package))
232 $(if $(NOQT),,mv $(archdir)/nls $(prefix)/usr/share/$(package))
233 mv $(archdir)/src $(prefix)/usr/share/$(package)
234 rm $(archdir)/VBox.sh
235 export VBOX_INSTALL_PATH=/usr/lib/$(package) && \
236 cd ./debian/builddir/bin/sdk/installer && \
237 python ./vboxapisetup.py install --root $(prefix)
238 rm -rf $(archdir)/sdk/installer
239 mv $(archdir)/vboxshell.py $(prefix)/usr/lib/$(package)
240 mv $(archdir)/sdk $(prefix)/usr/lib/$(package)
241 install -D -g 0 -o 0 -m 644 $(vboxroot)/src/VBox/Installer/linux/VBox.sh $(prefix)/usr/bin/VBox
242 mv $(archdir)/VBoxSysInfo.sh $(prefix)/usr/share/$(package)
243 mv $(archdir)/VBoxCreateUSBNode.sh $(prefix)/usr/share/$(package)
244 for i in VBoxManage VBoxSVC $(if $(HEADLESS),,VBoxSDL) \
245 $(if $(NOQT),,VirtualBox) VBoxHeadless \
246 VBoxExtPackHelperApp VBoxBalloonCtrl VBoxAutostart \
247 $(if $(NOWEBSVC),,vboxwebsrv webtest); do \
248 mv $(archdir)/$$i $(prefix)/usr/lib/$(package); done
249 $(if $(VNC),mv $(archdir)/ExtensionPacks/VNC $(prefix)/usr/lib/$(package)/ExtensionPacks,)
250 mv $(archdir)/VBoxTunctl $(prefix)/usr/bin
251 $(if $(NOMODS),,for d in $(moddir)/*; do \
252 if [ -f $$d/vboxdrv.ko -a -f $$d/vboxnetflt.ko -a -f $$d/vboxnetadp.ko -a -f $$d/vboxpci.ko ]; then \
253 install -D -g 0 -o 0 -m 0644 \
254 $$d/vboxdrv.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxdrv.ko; \
255 install -D -g 0 -o 0 -m 0644 \
256 $$d/vboxnetflt.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetflt.ko; \
257 install -D -g 0 -o 0 -m 0644 \
258 $$d/vboxnetadp.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxnetadp.ko; \
259 install -D -g 0 -o 0 -m 0644 \
260 $$d/vboxpci.ko $(prefix)/lib/modules/$$(basename $$d)/misc/vboxpci.ko; \
261 fi \
262 done)
263ifeq ($(ose),)
264 $(if $(NOQT),,mv $(archdir)/kchmviewer $(prefix)/usr/lib/$(package))
265 dh_installdocs \
266 $(archdir)/UserManual*.pdf $(archdir)/VirtualBox*.chm \
267 $(addprefix $(archdir)/, LICENSE)
268 rm $(addprefix $(archdir)/,UserManual*.pdf VirtualBox*.chm \
269 LICENSE)
270 for i in rdesktop-vrdp.tar.gz additions/VBoxGuestAdditions.iso; do \
271 mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
272 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp $(prefix)/usr/bin)
273 $(if $(HEADLESS),,mv $(archdir)/rdesktop-vrdp-keymaps $(prefix)/usr/share/$(package))
274 if [ -d $(archdir)/accessible ]; then mv $(archdir)/accessible $(prefix)/usr/lib/virtualbox; fi
275else
276 dh_installdocs \
277 $(archdir)/UserManual*.pdf
278 rm $(addprefix $(archdir)/,UserManual*.pdf)
279 for i in additions/VBoxGuestAdditions.iso; do \
280 mv $(archdir)/$$i $(prefix)/usr/share/$(package); done
281endif
282 rmdir $(archdir)/additions
283 $(if $(VNC),rmdir $(archdir)/ExtensionPacks)
284 rmdir $(archdir)
285 rmdir $(prefix)/opt
286 dh_link \
287 $(if $(NOQT),,usr/bin/VBox usr/bin/VirtualBox) \
288 $(if $(NOQT),,usr/bin/VBox usr/bin/virtualbox) \
289 usr/bin/VBox usr/bin/VBoxManage \
290 usr/bin/VBox usr/bin/vboxmanage \
291 $(if $(HEADLESS),,usr/bin/VBox usr/bin/VBoxSDL) \
292 $(if $(HEADLESS),,usr/bin/VBox usr/bin/vboxsdl) \
293 $(if $(ose),,usr/bin/VBox usr/bin/VBoxVRDP) \
294 usr/bin/VBox usr/bin/VBoxHeadless \
295 usr/bin/VBox usr/bin/vboxheadless \
296 usr/bin/VBox usr/bin/VBoxBalloonCtrl \
297 usr/bin/VBox usr/bin/vboxballoonctrl \
298 usr/bin/VBox usr/bin/VBoxAutostart \
299 usr/bin/VBox usr/bin/vboxautostart \
300 $(if $(NOWEBSVC),,usr/bin/VBox usr/bin/vboxwebsrv) \
301 usr/share/virtualbox/src/vboxhost usr/src/vboxhost-$(ver)
302 dh_desktop
303 $(if $(NOMODS),,dh_installmodules)
304 sed \
305 -e 's|%NOLSB%||g' \
306 -e 's|%DEBIAN%|yes|g' \
307 -e 's|%PACKAGE%|virtualbox|g' \
308 -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
309 -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
310 $(vboxroot)/src/VBox/Installer/linux/vboxdrv.sh.in > debian/vboxdrv.init
311 dh_installinit --name=vboxdrv --noscripts
312 cp $(vboxroot)/src/VBox/Installer/linux/vboxballoonctrl-service.sh debian/vboxballoonctrl-service.init
313 dh_installinit --name=vboxballoonctrl-service --noscripts
314 cp $(vboxroot)/src/VBox/Installer/linux/vboxautostart-service.sh debian/vboxautostart-service.init
315 dh_installinit --name=vboxautostart-service --noscripts
316 cp $(vboxroot)/src/VBox/Installer/linux/vboxweb-service.sh debian/vboxweb-service.init
317 dh_installinit --name=vboxweb-service --noscripts
318 sed -e 's|%VER%|$(ver)|g' \
319 debian/preinst.in > debian/preinst
320 sed -e 's|%VER%|$(ver)|g' \
321 debian/prerm.in > debian/prerm
322 sed -e 's|%VER%|$(ver)|g' \
323 -e '/#include installer-common.sh/ {' \
324 -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
325 -e 'd' \
326 -e '}' \
327 debian/postinst.in > debian/postinst
328 dh_installdebconf
329 dh_installchangelogs
330 dh_installmenu
331 dh_installmime
332 dh_link
333ifeq ($(DEBUG),)
334 dh_strip --keep-debug --exclude=libQtCoreVBox.so.4 --exclude=libQtGuiVBox.so.4 --exclude=libQtNetworkVBox.so.4 --exclude=libQtOpenGLVBox.so.4 --exclude=libqtaccessiblewidgets.so
335 # manually strip our R0/GC modules, dh_strip cannot handle them
336 for f in \
337 $(prefix)/usr/lib/$(package)/*.r0 $(prefix)/usr/lib/$(package)/*.gc; do \
338 objcopy --only-keep-debug \
339 $$f \
340 $(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f`; \
341 strip -S --remove-section=.comment $$f; \
342 objcopy --add-gnu-debuglink=$(prefix)/usr/lib/debug/usr/lib/$(package)/`basename $$f` $$f; \
343 done
344endif
345 mkdir -p $(current)/debian/$(verpkg)-dbg/usr/lib
346ifeq ($(DEBUG),)
347 mv $(current)/debian/$(verpkg)/usr/lib/debug $(current)/debian/$(verpkg)-dbg/usr/lib
348endif
349 dh_pycentral
350 dh_compress -X.pdf -X.chm -X LICENSE -X.py
351 dh_fixperms
352 dh_makeshlibs
353 dh_installdeb
354 dh_perl
355 LD_LIBRARY_PATH=$(prefix)/usr/lib/virtualbox dh_shlibdeps
356 dh_gencontrol -- \
357 -Valsa=$(if $(HEADLESS),,libasound2) \
358 -Vpulse=$(if $(HEADLESS),,libpulse0) \
359 -Vsdlttf=$(if $(HEADLESS),,libsdl-ttf2.0-0) \
360 -Vdkms=$(if $(filter _Debian_lenny,$(debrel)),,dkms)
361 dh_md5sums
362 dh_builddeb --destdir $(pkgdir) -- -Zxz
363endif
364
365.PHONY: binary modules binary-arch binary-indep clean checkroot
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette