VirtualBox

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

Last change on this file since 35650 was 35230, checked in by vboxsync, 14 years ago

deb/rpm: adaptions to r69058

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1#!/usr/bin/make -f
2
3#
4# Copyright (C) 2006-2010 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
31
32verpkg := VirtualBox-4.0
33current := $(shell pwd)
34vboxroot := $(shell cd ../../../../; pwd)
35pkgdir := $(shell cd ../../../../..; pwd)
36builddir := $(current)/rpm/builddir
37rpmlib := $(shell if [ `uname -m` = "x86_64" ]; then echo "lib64"; else echo "lib"; fi)
38arch := $(shell if [ `uname -m` = "x86_64" ]; then echo "amd64"; else echo "i386"; fi)
39verfile := $(builddir)/version-generated.mk
40-include $(vboxroot)/SVN_REVISION
41svnrev :=$(if $(svn_revision),$(svn_revision),0)
42
43ifneq ($(MAKECMDGOALS),clean)
44 rpmrel := $(shell cat /etc/distname)
45 ifeq ($(rpmrel),)
46 # look for fedora
47 rpmrel := $(shell cat /etc/fedora-release | sed -e 's/^Fedora *release *\([1-9][0-9]*\) .*/fedora\1/')
48 endif
49 ifeq ($(rpmrel),)
50 $(error failed to detect the release type. Add /etc/distname or hack the detection.)
51 endif
52
53 rpmdist := $(strip $(shell grep $(rpmrel) $(current)/distributions_rpm | cut -d'=' -f2))
54 ifeq ($(rpmdist),)
55 $(error Cannot detect package distribution (rpmrel=$(rpmrel)))
56 endif
57
58 ifeq ($(filter-out rhel4 rhel5 rhel6 fedora9 fedora11 fedora12 fedora13 fedora14 pclinuxos2007 turbolinux11,$(rpmrel)),)
59 rpmspec := rpm_redhat
60 endif
61 ifeq ($(filter-out openSUSE110 openSUSE111 openSUSE112 openSUSE113 sles10.1 sles11.0,$(rpmrel)),)
62 rpmspec := rpm_suse
63 endif
64 ifeq ($(filter-out mdv2009.1 mdv2010.0,$(rpmrel)),)
65 rpmspec := rpm_mdv
66 endif
67 ifeq ($(rpmspec),)
68 $(error failed to detect the .spec file (rpmrel=$(rpmrel)))
69 endif
70
71 include $(verfile)
72$(verfile): rpm/configure-stamp
73 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) $(verfile)
74endif
75
76ver := $(VBOX_VERSION_STRING)
77rpmver :=$(ver)$(if $(NOSUBVER),,$(if $(svn_revision),_$(svn_revision),)$(VERSUFFIX)$(if $(DEBUG),_dbg,))$(if $(BLEEDING_EDGE),_$(BLEEDING_EDGE),)
78archdir := $(current)/rpm/VirtualBox-$(ver)
79rpmname := $(verpkg)-$(rpmver)_$(rpmrel)
80
81# Fedora13/14 is bleeding edge, the other jails have outdated kernel headers
82instmod := $(if $(filter rhel4 rhel5 rhel6 sles10.1 sles11.0 pclinuxos2007 fedora13 fedora14,$(rpmrel)),,install_rpm)
83
84ifneq ($(STAGEDISO),)
85ifeq ($(wildcard $(STAGEDISO)/VBoxGuestAdditions.iso),)
86$(error STAGEDISO='$(STAGEDISO)/VBoxGuestAdditions.iso' not found)
87endif
88endif
89
90ifeq ($(wildcard /usr/share/doc/packages/bash),)
91 ifeq ($(wildcard /usr/share/doc/bash),)
92 # Mandriva 2007.1, Redhat
93 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(rpmname)\""
94 else
95 # Mandriva 2008.0
96 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/$(verpkg)\""
97 endif
98else
99 # Novell (OpenSUSE, SLES)
100 doc_dir := VBOX_PATH_PACKAGE_DOCS="\"/usr/share/doc/packages/$(verpkg)\""
101endif
102
103cfg_flags := $(if $(filter rhel4 sles10.1,$(rpmrel)),--build-libxml2,) \
104 $(if $(filter rhel4 sles10.1,$(rpmrel)),--build-libxslt,) \
105 $(if $(filter rhel4,$(rpmrel)),--build-libssl,) \
106 $(if $(filter rhel4 rhel5 sles10.1,$(rpmrel)),--build-libcurl,) \
107 $(if $(filter rhel5 sles10.1,$(rpmrel)),--disable-sdl-ttf,) \
108 $(if $(filter sles10.1 turbolinux11,$(rpmrel)),--disable-pulse,) \
109 $(if $(filter rhel4 rhel5,$(rpmrel)),--enable-pulse,) \
110 $(if $(filter rhel4 rhel5 sles10.1 turbolinux11,$(rpmrel)),--with-qt4-dir=/home/vbox/Qt-4.4.3-stdc++6-$(arch)) \
111 $(if $(DEBUG),--build-debug,)
112
113bld_flags := AUTOCFG=$(current)/rpm/AutoConfig.kmk \
114 LOCALCFG=$(current)/rpm/LocalConfig.kmk \
115 PATH_OUT=$(builddir) \
116 VBOX_DO_STRIP= \
117 VBOX_WITH_MULTIVERSION_PYTHON= \
118 $(doc_dir) \
119 VBOX_WITH_DOCS_CHM=1 \
120 VBOX_PACKAGE_DIST=$(rpmdist) \
121 VBOX_SVN_REV=$(svnrev) \
122 $(if $(NODOCS),VBOX_WITH_DOCS= ,) \
123 $(if $(VERBOSE),--print-directory KBUILD_VERBOSE=2,--no-print-directory) \
124 $(if $(STAGEDISO),VBOX_WITHOUT_ADDITIONS=1,) \
125 $(if $(BLEEDING_EDGE),VBOX_BLEEDING_EDGE=$(BLEEDING_EDGE),) \
126 $(if $(filter rhel4 rhel5 fedora9 fedora10 sles10.1 turbolinux11,$(rpmrel)),,VBOX_WITH_SYSFS_BY_DEFAULT=1)
127
128rpm/configure-stamp:
129 cd $(vboxroot) && ./configure --odir=$(current)/rpm $(cfg_flags)
130 touch $(current)/rpm/configure-stamp
131
132rpm/build-stamp: rpm/configure-stamp
133 . rpm/env.sh && kmk -C $(vboxroot) $(if $(NOPARALLEL),-j1,) $(bld_flags) all
134 $(if $(NODOCS),,. rpm/env.sh && kmk -C $(vboxroot)/src/VBox/Main $(bld_flags) docs)
135 $(if $(NODOCS),cp $(vboxroot)/prebuild/UserManual*.pdf $(builddir)/bin,)
136 $(if $(NODOCS),cp $(vboxroot)/prebuild/VirtualBox*.chm $(builddir)/bin,)
137 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI32.fd $(builddir)/bin,)
138 $(if $(EFI),cp $(vboxroot)/prebuild/VBoxEFI64.fd $(builddir)/bin,)
139 mkdir -p $(builddir)/bin/additions
140 $(if $(STAGEDISO),cp $(STAGEDISO)/VBoxGuestAdditions.iso $(builddir)/bin/additions,)
141 . rpm/env.sh && kmk -C $(vboxroot) $(bld_flags) \
142 VBOX_NO_LINUX_RUN_INSTALLER=1 \
143 packing
144 touch rpm/build-stamp
145
146clean:
147 rm -rf $(archdir)
148 rm -rf $(builddir) rpm/VirtualBox-*
149 rm -f rpm/VirtualBox.tar.bz2
150 rm -f rpm/VirtualBox.spec
151 rm -f rpm/build-stamp rpm/configure-stamp rpm/configure.log
152 rm -f rpm/AutoConfig.kmk rpm/env.sh
153
154ifeq ($(VBOX_VERSION_MAJOR),)
155binary: rpm/build-stamp $(verfile)
156 $(MAKE) -f rpm/rules binary
157else
158binary: rpm/build-stamp
159 rm -rf rpm/VirtualBox-*
160 tar -xjf $(builddir)/bin/VirtualBox.tar.bz2 -C rpm
161 sed \
162 -e 's|%VER%|$(ver)|g' \
163 -e 's|%NAME%|$(verpkg)|g' \
164 -e 's|%BUILDVER%|$(rpmver)|g' \
165 -e 's|%BUILDREL%|$(rpmrel)|g' \
166 -e 's|%BUILDROOT%|$(current)/rpm/buildroot|g' \
167 -e 's|%LIB%|$(rpmlib)|g' \
168 -e 's|%SPEC%|$(rpmspec)|g' \
169 -e 's|%MACROSPYTHON%|$(if $(wildcard /usr/lib/rpm/macros.python),%include /usr/lib/rpm/macros.python,)|g' \
170 -e 's|%INSTMOD%|$(instmod)|g' \
171 -e 's|%LIBASOUND%|$(if $(filter lib64,$(rpmlib)),libasound.so.2()(64bit),libasound.so.2)|g' \
172 rpm/VirtualBox.tmpl.spec > $(archdir)/VirtualBox.spec
173 sed \
174 -e 's|%NOLSB%|yes|g' \
175 -e 's|%DEBIAN%||g' \
176 -e 's|%PACKAGE%|virtualbox|g' \
177 -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \
178 vboxdrv.sh.in > $(archdir)/vboxdrv.init
179 sed \
180 -e 's|%NOLSB%|yes|g' \
181 -e 's|%DEBIAN%||g' \
182 -e 's|%PACKAGE%|virtualbox|g' \
183 vboxweb-service.sh.in > $(archdir)/vboxweb-service.init
184 cp debian/VBox.sh $(archdir)
185 mv rpm/VirtualBox-$(ver) rpm/$(rpmname)
186 tar -cjf rpm/VirtualBox.tar.bz2 -C rpm $(rpmname)
187 rm -f /usr/src/packages/RPMS/*/VirtualBox*rpm
188 rm -f /usr/src/packages/SPECS/*
189 rpmbuild -tb --clean rpm/VirtualBox.tar.bz2
190 mv /usr/src/packages/RPMS/*/$(verpkg)-debug* $(vboxroot)/.. || true
191 file=`find /usr/src/packages/RPMS -name $(verpkg)*rpm -print`; \
192 mv $$file $(pkgdir)
193# Note! if rpmbuild fails: sudo chmod a+rw /usr/src/redhat/* /usr/src/redhat/RPMS/*
194# Note! if find/mv fails: sudo ln -s redhat/ /usr/src/packages
195endif
196
197.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