VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/rpm/rules@ 57792

Last change on this file since 57792 was 57792, checked in by vboxsync, 9 years ago

Installer/linux: set the RPM _topdir to be inside the build area.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 10.8 KB
Line 
1#!/usr/bin/make -f
2#
3# Copyright (C) 2006-2015 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# possible overrides:
15# OSE=1 force VBOX_OSE
16# NOPARALLEL=1 compile with -j1
17# LINUX=<dir> compile vboxdrv against Linux found in <dir>
18# VERBOSE=1 verbose build
19# DEBUG=1 debug build
20# NOSUBVER=1 disable generation of the sub-version field (which is
21# either the subversion rev [if available] or the build date)
22# NODOCS=1 don't build docs, use precompiled UserManual.pdf and
23# VirtualBox.chm from $HOME
24# NOMODS=1 don't build any module
25# NOQT=1 don't build the Qt GUI
26# NOSDL=1 don't build VBoxSDL
27# EFI=1 include the EFI binary from prebuild
28# VERSUFFIX=<suffix> set a particular package version suffix (e.g. _customer)
29# HEADLESS=1 build the headless version
30# VNC=1 build VNC code
31# NOWEBSVC=1 don't build the webservice API, default for OSE
32# STAGEDISO=<path> don't build the VBoxAdditions, use the precompiled .iso
33# PKGDIR=<path> where to store the final package(s)
34# BLEEDING_EDGE=xyz
35
36ifeq ($(wildcard rpm/rules),)
37$(error call rpm/rules from src/VBox/Installer/linux)
38endif
39
40ifneq ($(wildcard /usr/lib/rpm/find-requires.ksyms),)
41# don't allow to check for kernel syms, otherwise we depend on specific kernel versions!
42$(error /usr/lib/rpm/find-requires.ksyms must not be installed)
43endif
44ifneq ($(wildcard /usr/lib/rpm/find-supplements.ksyms),)
45# same for openSUSE
46$(error /usr/lib/rpm/find-supplements.ksyms must not be installed)
47endif
48ifeq ($(shell if grep -q '^/usr/lib/virtualbox' /etc/permissions* 2>/dev/null; then echo yes; fi),yes)
49# make sure openSUSE permissions fixes don't interfere with us
50$(error Fix /etc/permissions*)
51endif
52ifeq ($(shell if grep -q '^%disttag' /usr/lib/rpm/macros.d/mandriva 2>/dev/null; then echo yes; fi),yes)
53$(error Fix /usr/lib/rpm/macros.d/mandriva)
54endif
55
56verpkg := VirtualBox-5.0
57current := $(shell pwd)
58vboxroot := $(shell while ! test -r configure && ! test "$PWD" = "/"; do cd ..; done; pwd)
59pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd $(vboxroot)/..; pwd))
60builddir := $(current)/rpm/builddir
61rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
62arch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "i386"; fi)
63verfile := $(builddir)/version-generated.mk
64ose := $(if $(OSE),1,$(if $(wildcard $(vboxroot)/src/VBox/RDP/server),,1))
65-include $(vboxroot)/SVN_REVISION
66svnrev :=$(if $(svn_revision),$(svn_revision),)
67
68NOMODS ?= $(ose)
69NOQT ?= $(HEADLESS)
70NOWEBSVC ?= $(ose)
71NOWINE := $(if $(NODOCS),$(if $(STAGEDISO),1,),)$(ose)
72
73ifneq ($(MAKECMDGOALS),clean)
74 rpmrel := $(subst ol,el,$(subst rhel,el,$(shell cat /etc/distname)))
75 ifeq ($(rpmrel),)
76 # look for fedora
77 rpmrel := $(shell cat /etc/fedora-release | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
78 endif
79 ifeq ($(rpmrel),)
80 # look for OL
81 rpmrel := $(shell cat /etc/enterprise-release | sed -ne 's/^Enterprise Linux[a-zA-Z ]*\([1-9][0-9]*\).*/ol\1/p')
82 endif
83 ifeq ($(rpmrel),)
84 # look for CentOS
85 rpmrel := $(shell cat /etc/redhat-release | sed -ne 's/^CentOS[a-zA-Z ]*\([1-9][0-9]*\).*/centos\1/p')
86 endif
87 ifeq ($(rpmrel),)
88 # look for Red Hat
89 rpmrel := $(shell cat /etc/redhat-release | sed -ne 's/^Red Hat[a-zA-Z ]*\([1-9][0-9]*\).*/centos\1/p')
90 endif
91 ifeq ($(rpmrel),)
92 $(error failed to detect the release type. Add /etc/distname or hack the detection.)
93 endif
94
95 rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
96 ifeq ($(rpmdist),)
97 $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
98 endif
99
100 ifeq ($(filter-out el5 el6 ol5 ol6 el7 centos5 centos6 fedora17 fedora18 fedora19 fedora20 fedora21 fedora22,$(rpmrel)),)
101 rpmspec := rpm_redhat
102 endif
103 ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 openSUSE123 openSUSE131 openSUSE132 sles10.1 sles11.0,$(rpmrel)),)
104 rpmspec := rpm_suse
105 endif
106 ifeq ($(filter-out mdv2009.1 mdv2010.0 mdv2011.0,$(rpmrel)),)
107 rpmspec := rpm_mdv
108 endif
109 ifeq ($(rpmspec),)
110 $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
111 endif
112
113 # contrary to debian we need the verfile earlier to get the correct rpmname into the bld_flags
114 include $(verfile)
115$(verfile): rpm/configure-stamp
116 . rpm/env.sh && kmk -C $(vboxroot) $(verfile) $(bld_flags)
117
118endif
119
120ver := $(VBOX_VERSION_STRING)
121rpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(HEADLESS),_headless,)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
122archdir := $(current)/rpm/VirtualBox-$(ver)
123rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
124
125# never ship any modules
126instmod :=
127
128ifneq ($(STAGEDISO),)
129 ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
130 $(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
131 endif
132endif
133
134ifeq ($(wildcard /usr/share/doc/packages/bash),)
135 ifeq ($(wildcard /usr/share/doc/bash),)
136 # Mandriva 2007.1, Redhat
137 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(rpmname)\""
138 else
139 # Mandriva 2008.0
140 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
141 endif
142else
143 # Novell (OpenSUSE, SLES)
144 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
145endif
146
147cfg_flags := $(if $(NOQT),--disable-qt,) \
148 $(if $(NOSDL),--disable-vboxsdl,) \
149 $(if $(filter sles10.1,$(rpmrel)),--build-libxml2,) \
150 $(if $(filter el5 el6 sles10.1 sles11.0 mdv2011.0,$(rpmrel)),--build-libvpx,) \
151 $(if $(filter el5 ol5 centos5 sles10.1 sles11.0,$(rpmrel)),--build-libcurl,) \
152 $(if $(filter el5 centos5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
153 $(if $(filter sles10.1,$(rpmrel)),--disable-pulse,) \
154 $(if $(filter el5 ol5 centos5,$(rpmrel)),--enable-pulse,) \
155 $(if $(filter el5 ol5 centos5 el6 ol6 centos6 sles10.1 sles11.0,$(rpmrel)),--with-qt4-dir=/home/vbox/Qt-4.8.6-stdc++6-$(arch)) \
156 $(if $(ose),--ose,) $(if $(LINUX),--with-linux=$(LINUX),) \
157 $(if $(HEADLESS),--build-headless,) \
158 $(if $(DEBUG),--build-debug,) \
159 $(if $(NOWINE),,--setup-wine) \
160 $(if $(NOWEBSVC),,$(if $(ose),--enable-webservice,)) \
161 $(if $(VNC),--enable-vnc,) \
162 --disable-extpack
163
164bld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
165 LOCALCFG=$(current)/rpm/LocalConfig.kmk \
166 PATH_OUT=$(builddir) \
167 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
168 VBOX_WITHOUT_EXTPACK_VNC_PACKING=1 \
169 $(if $(filter el5 el6 sles10.1 sles11.0,$(rpmrel)),,VBOX_WITH_VMSVGA3D=1) \
170 VBOX_DO_STRIP= \
171 VBOX_WITH_MULTIVERSION_PYTHON= \
172 $(doc_dir) \
173 $(if $(ose),,VBOX_WITH_DOCS_CHM=1) \
174 VBOX_PACKAGE_DIST=$(rpmdist) \
175 $(if $(svnrev),VBOX_SVN_REV=$(svnrev),) \
176 $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
177 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
178 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
179 $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
180 $(if $(filter el5 ol5 centos5 sles10.1,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
181
182rpm/configure-stamp:
183 cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
184 touch rpm/configure-stamp
185
186rpm/build-stamp: rpm/configure-stamp
187 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(if $(NOPARALLEL),-j1,) all
188 $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
189 $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
190 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
191 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
192 mkdir -p $(builddir)/bin/additions
193 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
194 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) \
195 VBOX_NO_LINUX_RUN_INSTALLER=1 \
196 VBOX_LNX_ADD_ARCHIVE.x86=$(builddir)/bin/additions/VBoxGuestAdditions-x86.tar.bz2 \
197 VBOX_LNX_ADD_ARCHIVE.amd64=$(builddir)/bin/additions/VBoxGuestAdditions-amd64.tar.bz2 \
198 VBOX_PATH_ADDITIONS.linux.x86=$(builddir)/bin/additions \
199 VBOX_PATH_ADDITIONS.linux.amd64=$(builddir)/bin/additions \
200 packing
201 touch rpm/build-stamp
202
203clean:
204 rm -rf $(archdir)
205 rm -rf $(builddir) rpm/VirtualBox-*
206 rm -f rpm/VirtualBox.tar
207 rm -f rpm/VirtualBox.tar.bz2
208 rm -f rpm/VirtualBox.spec
209 rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
210 rm -f rpm/AutoConfig.kmk rpm/env.sh
211
212ifeq ($(VBOX_VERSION_MAJOR),)
213binary: rpm/build-stamp $(verfile)
214 $(MAKE) -f rpm/rules binary
215else
216binary: rpm/build-stamp
217 rm -rf rpm/VirtualBox-*
218 tar -xf $(builddir)/bin/VirtualBox.tar -C rpm
219 sed \
220 -e 's|%VER%|$(ver)|g' \
221 -e 's|%NAME%|$(verpkg)|g' \
222 -e 's|%BUILDVER%|$(rpmver)|g' \
223 -e 's|%BUILDREL%|$(rpmrel)|g' \
224 -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
225 -e 's|%LIB%|$(rpmlib)|g' \
226 -e 's|%OSE%|$(if $(ose),is_ose,not_ose)|g' \
227 -e 's|%SPEC%|$(rpmspec)|g' \
228 -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
229 -e 's|%INSTMOD%|$(instmod)|g' \
230 -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
231 -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
232 -e "s|%WEBSVC%|$(if $(NOWEBSVC),false,true)|g" \
233 -e '/#include installer-common.sh/ {' \
234 -e "r $(vboxroot)/src/VBox/Installer/linux/installer-common.sh" \
235 -e 'd' \
236 -e '}' \
237 rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
238 sed \
239 -e 's|%NOLSB%|yes|g' \
240 -e 's|%DEBIAN%||g' \
241 -e 's|%PACKAGE%|virtualbox|g' \
242 -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \
243 -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
244 vboxdrv.sh.in > $(archdir)/vboxdrv.init
245 cp vboxballoonctrl-service.sh $(archdir)/vboxballoonctrl-service.init
246 cp vboxautostart-service.sh $(archdir)/vboxautostart-service.init
247 cp vboxweb-service.sh $(archdir)/vboxweb-service.init
248 cp VBox.sh $(archdir)
249 mv rpm/VirtualBox-$(ver) rpm/$(rpmname)
250 tar -cf rpm/VirtualBox.tar -C rpm $(rpmname)
251 rm -f rpmbuild/RPMS/*/VirtualBox*rpm
252 rm -f rpmbuild/SPECS/*
253 (cd rpm; rpmbuild --define '_topdir $(current)/rpmbuild' -tb --clean VirtualBox.tar)
254 mv rpmbuild/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
255 file=`find rpmbuild/RPMS -name $(verpkg)*rpm -print`; \
256 mv $$file $(pkgdir)
257# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
258# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
259endif
260
261.PHONY: binary clean
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