VirtualBox

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

Last change on this file since 39214 was 39214, checked in by vboxsync, 13 years ago

deb/rpm: if we use our own Qt package, use Qt 4.7.4 now

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1#!/usr/bin/make -f
2
3#
4# Copyright (C) 2006-2011 Oracle Corporation
5#
6# This file is part of VirtualBox Open Source Edition (OSE), as
7# available from http://www.virtualbox.org. This file is free software;
8# you can redistribute it and/or modify it under the terms of the GNU
9# General Public License as published by the Free Software Foundation,
10# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
11# distribution. VirtualBox OSE is distributed in the hope that it will
12# be useful, but WITHOUT ANY WARRANTY of any kind.
13#
14
15ifeq ($(wildcard rpm/rules),)
16$(error call rpm/rules from src/VBox/Installer/linux)
17endif
18
19ifneq ($(wildcard /usr/lib/rpm/find-requires.ksyms),)
20# don't allow to check for kernel syms, otherwise we depend on specific kernel versions!
21$(error /usr/lib/rpm/find-requires.ksyms must not be installed)
22endif
23ifneq ($(wildcard /usr/lib/rpm/find-supplements.ksyms),)
24# same for openSUSE
25$(error /usr/lib/rpm/find-supplements.ksyms must not be installed)
26endif
27ifeq ($(shell if grep -q '^/usr/lib/virtualbox' /etc/permissions* 2>/dev/null; then echo yes; fi),yes)
28# make sure openSUSE permissions fixes don't interfere with us
29$(error Fix /etc/permissions*)
30endif
31ifeq ($(shell if grep -q '^%disttag' /usr/lib/rpm/macros.d/mandriva 2>/dev/null; then echo yes; fi),yes)
32$(error Fix /usr/lib/rpm/macros.d/mandriva)
33endif
34
35verpkg := VirtualBox-4.1
36current := $(shell pwd)
37vboxroot := $(shell cd ../../../../; pwd)
38pkgdir := $(if $(PKGDIR),$(PKGDIR),$(shell cd ../../../../..; pwd))
39builddir := $(current)/rpm/builddir
40rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
41arch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "i386"; fi)
42verfile := $(builddir)/version-generated.mk
43-include $(vboxroot)/SVN_REVISION
44svnrev :=$(if $(svn_revision),$(svn_revision),0)
45
46ifneq ($(MAKECMDGOALS),clean)
47 rpmrel := $(shell cat /etc/distname)
48 ifeq ($(rpmrel),)
49 # look for fedora
50 rpmrel := $(shell cat /etc/fedora-release | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
51 endif
52 ifeq ($(rpmrel),)
53 $(error failed to detect the release type. Add /etc/distname or hack the detection.)
54 endif
55
56 rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
57 ifeq ($(rpmdist),)
58 $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
59 endif
60
61 ifeq ($(filter-out rhel4 rhel5 rhel6 ol4 ol5 ol6 centos4 centos5 centos6 fedora9 fedora11 fedora12 fedora13 fedora14 fedora15 fedora16 turbolinux11,$(rpmrel)),)
62 rpmspec := rpm_redhat
63 endif
64 ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 openSUSE114 sles10.1 sles11.0,$(rpmrel)),)
65 rpmspec := rpm_suse
66 endif
67 ifeq ($(filter-out mdv2009.1 mdv2010.0 mdv2011.0,$(rpmrel)),)
68 rpmspec := rpm_mdv
69 endif
70 ifeq ($(rpmspec),)
71 $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
72 endif
73
74 include $(verfile)
75$(verfile): rpm/configure-stamp
76 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(verfile)
77endif
78
79ver := $(VBOX_VERSION_STRING)
80rpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
81archdir := $(current)/rpm/VirtualBox-$(ver)
82rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
83
84# Fedora13/14 is bleeding edge, the other jails have outdated kernel headers
85instmod := $(if $(filter rhel4 rhel5 rhel6 ol4 ol5 ol6 centos4 centos5 centos6 sles10.1 sles11.0 fedora13 fedora14 fedora15 fedora16,$(rpmrel)),,install_rpm)
86
87ifneq ($(STAGEDISO),)
88ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
89$(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
90endif
91endif
92
93ifeq ($(wildcard /usr/share/doc/packages/bash),)
94 ifeq ($(wildcard /usr/share/doc/bash),)
95 # Mandriva 2007.1, Redhat
96 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(rpmname)\""
97 else
98 # Mandriva 2008.0
99 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
100 endif
101else
102 # Novell (OpenSUSE, SLES)
103 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
104endif
105
106cfg_flags := $(if $(filter rhel4 sles10.1,$(rpmrel)),--build-libxml2,) \
107 $(if $(filter rhel4 sles10.1,$(rpmrel)),--build-libxslt,) \
108 $(if $(filter rhel4,$(rpmrel)),--build-libssl,) \
109 $(if $(filter rhel4 rhel5 ol4 ol5 centos4 centos5 sles10.1,$(rpmrel)),--build-libcurl,) \
110 $(if $(filter rhel5 centos5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
111 $(if $(filter sles10.1 turbolinux11,$(rpmrel)),--disable-pulse,) \
112 $(if $(filter rhel4 rhel5 ol4 ol5 centos4 centos5,$(rpmrel)),--enable-pulse,) \
113 $(if $(filter rhel4 rhel5 ol4 ol5 centos4 centos5 sles10.1 turbolinux11,$(rpmrel)),--with-qt4-dir=/home/vbox/Qt-4.7.4-stdc++6-$(arch)) \
114 $(if $(DEBUG),--build-debug,)
115
116bld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
117 LOCALCFG=$(current)/rpm/LocalConfig.kmk \
118 PATH_OUT=$(builddir) \
119 VBOX_WITHOUT_EXTPACK_PUEL_PACKING=1 \
120 VBOX_DO_STRIP= \
121 VBOX_WITH_MULTIVERSION_PYTHON= \
122 $(doc_dir) \
123 VBOX_WITH_DOCS_CHM=1 \
124 VBOX_PACKAGE_DIST=$(rpmdist) \
125 VBOX_SVN_REV=$(svnrev) \
126 $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
127 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
128 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
129 $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
130 $(if $(filter rhel4 rhel5 ol4 ol5 centos4 centos5 fedora9 fedora10 sles10.1 turbolinux11,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
131
132rpm/configure-stamp:
133 cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
134 touch $(current)/rpm/configure-stamp
135
136rpm/build-stamp: rpm/configure-stamp
137 . rpm/env.sh && kmk -C $(vboxroot) $(if $(NOPARALLEL),-j1,) $(bld_flags) all
138 $(if $(NODOCS),,. rpm/env.sh && kmk -C $(vboxroot)/src/VBox/Main $(bld_flags) docs)
139 $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
140 $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
141 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
142 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
143 mkdir -p $(builddir)/bin/additions
144 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
145 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) \
146 VBOX_NO_LINUX_RUN_INSTALLER=1 \
147 packing
148 touch rpm/build-stamp
149
150clean:
151 rm -rf $(archdir)
152 rm -rf $(builddir) rpm/VirtualBox-*
153 rm -f rpm/VirtualBox.tar.bz2
154 rm -f rpm/VirtualBox.spec
155 rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
156 rm -f rpm/AutoConfig.kmk rpm/env.sh
157
158ifeq ($(VBOX_VERSION_MAJOR),)
159binary: rpm/build-stamp $(verfile)
160 $(MAKE) -f rpm/rules binary
161else
162binary: rpm/build-stamp
163 rm -rf rpm/VirtualBox-*
164 tar -xjf $(builddir)/bin/VirtualBox.tar.bz2 -C rpm
165 sed \
166 -e 's|%VER%|$(ver)|g' \
167 -e 's|%NAME%|$(verpkg)|g' \
168 -e 's|%BUILDVER%|$(rpmver)|g' \
169 -e 's|%BUILDREL%|$(rpmrel)|g' \
170 -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
171 -e 's|%LIB%|$(rpmlib)|g' \
172 -e 's|%SPEC%|$(rpmspec)|g' \
173 -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
174 -e 's|%INSTMOD%|$(instmod)|g' \
175 -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
176 -e 's|%INITSCRIPTS%|$(if $(filter fedora,$(rpmspec)),initscripts,)|g' \
177 -e '/#include installer-utils.sh/ {' \
178 -e "r $(vboxroot)/src/VBox/Installer/linux/installer-utils.sh" \
179 -e 'd' \
180 -e '}' \
181 rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
182 sed \
183 -e 's|%NOLSB%|yes|g' \
184 -e 's|%DEBIAN%||g' \
185 -e 's|%PACKAGE%|virtualbox|g' \
186 -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
187 vboxdrv.sh.in > $(archdir)/vboxdrv.init
188 sed \
189 -e 's|%NOLSB%|yes|g' \
190 -e 's|%DEBIAN%||g' \
191 -e 's|%PACKAGE%|virtualbox|g' \
192 vboxballoonctrl-service.sh.in > $(archdir)/vboxballoonctrl-service.init
193 sed \
194 -e 's|%NOLSB%|yes|g' \
195 -e 's|%DEBIAN%||g' \
196 -e 's|%PACKAGE%|virtualbox|g' \
197 vboxweb-service.sh.in > $(archdir)/vboxweb-service.init
198 cp debian/VBox.sh $(archdir)
199 mv rpm/VirtualBox-$(ver) rpm/$(rpmname)
200 tar -cjf rpm/VirtualBox.tar.bz2 -C rpm $(rpmname)
201 rm -f /usr/src/packages/RPMS/*/VirtualBox*rpm
202 rm -f /usr/src/packages/SPECS/*
203 (cd rpm; rpmbuild -tb --clean VirtualBox.tar.bz2)
204 mv /usr/src/packages/RPMS/*/$(verpkg)-debug* $(pkgdir) || true
205 file=`find /usr/src/packages/RPMS -name $(verpkg)*rpm -print`; \
206 mv $$file $(pkgdir)
207# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
208# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
209endif
210
211.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