summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: c37609845b48d756afbc22cb970b4ff0c3609736 (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
#!/usr/bin/make -f

# Name of the source packages
psource:=virtualbox-source
pdkms:=virtualbox-dkms

# The short upstream name
sname:=virtualbox
sxname:=virtualbox-qt
gname:=virtualbox-guest
uname:=virtualbox-guest-utils
uxname:=virtualbox-guest-x11

INSTALL_PATH:=/usr/lib/virtualbox
MAKE:=kmk

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NJOBS := -j $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

include /usr/share/dpkg/default.mk
VERSION ?= $(shell echo $(DEB_VERSION_UPSTREAM) |cut -f 1 -d "-")

DIST_NAME := $(shell lsb_release -si)
DIST_RELEASE := $(DIST_NAME)/$(shell lsb_release -sc)

SERVER_DEPENDS = $(shell cat /usr/share/xserver-xorg/videodrvdep 2>/dev/null)

export DEB_BUILD_HARDENING=1
export DEB_BUILD_HARDENING_PIE=0
export DEB_BUILD_HARDENING_FORMAT=0
export DEB_BUILD_HARDENING_BINDNOW=0

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with python3,dkms

override_dh_auto_configure:
	@echo Building for $(DIST_RELEASE)

ifeq ($(strip $(SERVER_DEPENDS)),)
	@echo 'error: SERVER_DEPENDS is empty'
	@exit 1
endif

	mkdir -p out
	./configure \
	    --ose \
	    --odir=$(abspath out) \
	    --with-linux="/usr" \
	    --disable-kmods \
	    --enable-webservice \
	    --enable-vde \
	    --enable-vnc

override_dh_python3:
	dh_python3 --no-ext-rename

override_dh_auto_build:
	# Building package
	. out/env.sh && $(MAKE) $(NJOBS) \
	    AUTOCFG=$(abspath out/AutoConfig.kmk) \
	    LOCALCFG=$(abspath debian/LocalConfig.kmk) \
	    PATH_OUT=$(abspath out) \
	    TOOL_YASM_AS=yasm \
	    VBOX_USE_SYSTEM_XORG_HEADERS=1 \
	    VBOX_USE_SYSTEM_GL_HEADERS=1 \
	    VBOX_NO_LEGACY_XORG_X11=1 \
	    VBOX_BUILD_PUBLISHER=_$(DIST_NAME) \
	    VBOX_WITH_REGISTRATION_REQUEST= \
	    VBOX_WITH_UPDATE_REQUEST= \
	    KBUILD_VERBOSE=2 \
	    VBOX_WITH_EXTPACK_VBOXDTRACE=

	xsltproc --nonet --stringparam section.autolabel 1 \
	    -o debian/README.Debian.html \
	    /usr/share/xml/docbook/stylesheet/nwalsh/html/docbook.xsl \
	    debian/virtualbox.files/README.Debian.xml

	chmod 755 debian/lynx-dump-postprocess
	export LC_ALL=C; lynx -force_html -dump debian/README.Debian.html | \
	    ./debian/lynx-dump-postprocess > debian/virtualbox.README.Debian.tmp
	mv debian/virtualbox.README.Debian.tmp debian/virtualbox.README.Debian

override_dh_auto_install:
	dh_auto_install

ifneq (,$(filter $(sname), $(shell dh_listpackages)))
	export VBOX_INSTALL_PATH=$(INSTALL_PATH) && \
	    cd out/bin/sdk/installer && \
	    python3 ./vboxapisetup.py install --root $(CURDIR)/debian/$(sname)
endif

	sed -e 's/CVERSION/$(VERSION)/g' < debian/$(pdkms).links.in > debian/$(pdkms).links

	# Build install files for the dkms'ified sources
	sed -e 's/CVERSION/$(VERSION)/g' < debian/$(pdkms).install.in > debian/$(pdkms).install

	echo "xserver:Depends=$(SERVER_DEPENDS)" >> debian/$(uxname).substvars

ifeq ($(DIST_NAME),Ubuntu)
	echo "modaliases=vboxx11(pci:v000080EEd0000BEEFsv00000000sd00000000bc*sc*i*)" >> debian/$(uxname).substvars
endif

override_dh_install:
ifneq (,$(filter $(sname), $(shell dh_listpackages)))
	dh_install -p$(sname) -X out/bin/VBoxDbg.so
endif
	dh_install --remaining-packages
#ifneq (,$(filter $(uxname), $(shell dh_listpackages)))
#	install -m 644 -p -D out/bin/additions/vboxvideo_drv_system.so \
#	    debian/$(uxname)/usr/lib/xorg/modules/drivers/vboxvideo_drv.so
#endif

ifeq ($(DIST_NAME),Ubuntu)
	install -m 644 -p -D debian/apport-hook.py \
	    debian/$(sname)/usr/share/apport/package-hooks/source_$(sname).py
endif

override_dh_fixperms:
	dh_fixperms

# check if arch-any packages are being built
ifneq (,$(filter $(sname), $(shell dh_listpackages)))
	chmod +s debian/$(sname)$(INSTALL_PATH)/VBoxSDL;
	chmod +s debian/$(sname)$(INSTALL_PATH)/VBoxHeadless;
	chmod +s debian/$(sname)$(INSTALL_PATH)/VBoxNetNAT;
	chmod +s debian/$(sname)$(INSTALL_PATH)/VBoxNetDHCP;
	chmod +s debian/$(sname)$(INSTALL_PATH)/VBoxNetAdpCtl;
	chmod 644 debian/$(sname)$(INSTALL_PATH)/*.r0;

	chmod 644 debian/$(sname)$(INSTALL_PATH)/sdk/bindings/xpcom/python/xpcom/*.py;
	chmod 644 debian/$(sname)$(INSTALL_PATH)/sdk/bindings/xpcom/python/xpcom/server/*.py;
	chmod 644 debian/$(sname)$(INSTALL_PATH)/sdk/bindings/xpcom/python/xpcom/client/*.py;
	chmod 644 debian/$(sname)$(INSTALL_PATH)/sdk/bindings/xpcom/java/vboxjxpcom.jar;

	chmod 755 debian/$(sname)/usr/share/virtualbox/VBox.sh;
endif

ifneq (,$(filter $(sxname), $(shell dh_listpackages)))
	chmod +s debian/$(sxname)$(INSTALL_PATH)/VirtualBoxVM;
endif

ifneq (,$(filter $(uxname), $(shell dh_listpackages)))
	chmod 755 debian/$(uxname)/usr/share/virtualbox/x11config.pl;
endif

# check if arch-all packages are being built
ifneq (,$(filter $(psource), $(shell dh_listpackages)))
	# These files have incorrect permissions, fixing it.
	chmod 755 debian/$(psource)/usr/src/modules/$(sname)/debian/rules

	# this needs all prior work to be finished
	cd debian/$(psource)/usr/src && \
	    tar -cjf $(sname).tar.bz2 modules && \
	    rm -rf modules

	chmod 644 debian/$(psource)/usr/src/$(sname).tar.bz2
endif

override_dh_installinit:
	dh_installinit -p$(uxname) --no-start --update-rcd-params="start 45 S ."
	dh_installinit --remaining-packages --no-start

override_dh_systemd_enable:
	dh_systemd_enable -p$(uname) debian/$(uname).service

override_dh_dkms:
	dh_dkms -V $(VERSION)

override_dh_strip:
ifneq (,$(filter $(sname), $(shell dh_listpackages)))
	dh_strip --dbgsym-migration='$(sname)-dbg'

	# strip files not handled by dh_strip
ifeq (,$(filter nostrip,$(DEB_BUILD_OPTIONS)))
	set -e && for file in debian/$(sname)/usr/lib/virtualbox/*.r0; do \
	    strip --strip-debug --remove-section=.comment --remove-section=.note $${file}; \
	done
endif
	# I don't see a reason to have these. If any user complains, we can try ship it.
	rm -f debian/$(sname)/usr/lib/virtualbox/VMMRC.debug
	rm -f debian/$(sname)/usr/lib/virtualbox/VMMR0.debug
endif

override_dh_shlibdeps:
ifneq (,$(filter $(sname), $(shell dh_listpackages)))
	dh_shlibdeps -p$(sname) -X debian/$(sname)$(INSTALL_PATH)/VBoxTestOGL -- \
	    -dRecommends debian/$(sname)$(INSTALL_PATH)/VBoxTestOGL -dDepends
endif
	dh_shlibdeps --remaining-packages

override_dh_compress:
	dh_compress -X.pdf

override_dh_auto_clean:
	dh_auto_clean

	# Cleaning package
	rm -rf out
	rm -f build-stamp
	rm -f debian/virtualbox.README.Debian debian/README.Debian.html
	rm -f debian/$(pdkms).install
	rm -f debian/$(pdkms).links

	find . -name "*.pyc" -exec rm -f {} \;