VirtualBox

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

Last change on this file since 47363 was 46890, checked in by vboxsync, 11 years ago

deb/rpm: stripping modules not necessary/supported anymore

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