Bug 639884 - Teach packaging code how to create RPM files from normal builds r=glandium

This commit is contained in:
John Ford 2011-03-30 10:22:36 -07:00
parent fb902de373
commit 9ff702033c
5 changed files with 315 additions and 0 deletions

View File

@ -436,6 +436,7 @@ PBBUILD_BIN = @PBBUILD@
SDP = @SDP@ SDP = @SDP@
NSINSTALL_BIN = @NSINSTALL_BIN@ NSINSTALL_BIN = @NSINSTALL_BIN@
WGET = @WGET@ WGET = @WGET@
RPMBUILD = @RPMBUILD@
ifdef MOZ_NATIVE_JPEG ifdef MOZ_NATIVE_JPEG
JPEG_CFLAGS = @JPEG_CFLAGS@ JPEG_CFLAGS = @JPEG_CFLAGS@

View File

@ -1011,6 +1011,9 @@ if test -z "$XARGS" -o "$XARGS" = ":"; then
AC_MSG_ERROR([xargs not found in \$PATH .]) AC_MSG_ERROR([xargs not found in \$PATH .])
fi fi
MOZ_PATH_PROG(RPMBUILD, rpmbuild, :)
AC_SUBST(RPMBUILD)
if test "$COMPILE_ENVIRONMENT"; then if test "$COMPILE_ENVIRONMENT"; then
dnl ======================================================== dnl ========================================================

View File

@ -0,0 +1,53 @@
#filter substitution
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Basic Mozilla Application Desktop File.
#
# The Initial Developer of the Original Code is
# Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# John Ford <jhford@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
[Desktop Entry]
Version=1.0
Name=@MOZ_APP_DISPLAYNAME@
GenericName=Web Browser
Comment=Your web, the way you like it
Exec=@MOZ_APP_NAME@
Icon=@MOZ_APP_NAME@
Terminal=false
Type=Application
StartupWMClass=@MOZ_APP_NAME@-bin
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
StartupNotify=true
X-MultipleArgs=false
X-Desktop-File-Install-Version=0.16
Categories=Network;WebBrowser;

View File

@ -0,0 +1,167 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla Application packaging specific RPM Spec file.
#
# The Initial Developer of the Original Code is
# Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# John Ford <jhford@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
%global __jar_repack %{nil}
#Use a consistent string to refer to the package by
%define pr_name "%{moz_app_displayname} %{moz_app_version}"
Name: %{moz_app_name}
Version: %{moz_numeric_app_version}
Release: %{?moz_rpm_release:%{moz_rpm_release}}%{?buildid:.%{buildid}}
Summary: %{pr_name}
Group: Applications/Internet
License: MPLv1.1 or GPLv2+ or LGPLv2+
Vendor: Mozilla
URL: http://www.mozilla.org/projects/firefox/
Source0: %{name}.desktop
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
#AutoProv: no
BuildRequires: desktop-file-utils
%description
%{pr_name}. This package was built from
%{moz_source_repo}/rev/%{moz_source_stamp}
#We only want a subpackage for the SDK if the required
#files were generated. Like the tests subpackage, we
#probably only need to conditionaly define the %files
#section.
%if %{?createdevel:1}
%package devel
Summary: %{pr_name} SDK
Group: Development/Libraries
requires: %{name} = %{version}-%{release}
%description devel
%{pr_name} SDK libraries, headers and interface descriptions
%endif
%if %{?createtests:1}
%package tests
Summary: %{pr_name} tests
Group: Developement/Libraries
requires: %{name} = %{version}-%{release}
%description tests
%{pr_name} test harness files and test cases
%endif
%prep
echo No-op prep
%build
echo No-op build
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
desktop-file-validate %{SOURCE0}
desktop-file-install --vendor mozilla \
--dir $RPM_BUILD_ROOT%{_datadir}/applications \
%{SOURCE0}
#In order to make branding work in a generic way, We find
#all the icons that are likely to be used for desktop files
#and install them appropriately
find %{moz_branding_directory} -name "default*.png" | tee icons.list
for i in $(cat icons.list) ; do
size=$(echo $i | sed "s/.*default\([0-9]*\).png$/\1/")
icondir=$RPM_BUILD_ROOT/%{_datadir}/icons/hicolor/${size}x${size}/apps/
mkdir -p $icondir
cp -a $i ${icondir}%{name}.png
done
rm icons.list #cleanup
%if %{?createtests:1}
#wastefully creates a zip file, but ensures that we stage all test suites
make package-tests
testdir=$RPM_BUILD_ROOT/%{_datadir}/%{_testsinstalldir}/tests
mkdir -p $testdir
cp -a dist/test-package-stage/* $testdir/
%endif
%clean
rm -rf $RPM_BUILD_ROOT
%post
#this is needed to get gnome-panel to update the icons
update-desktop-database &> /dev/null || :
touch --no-create %{_datadir}/icons/hicolor || :
if [ -x %{_bindir}/gtk-update-icon-cache ] ; then
%{_bindir}/gtk-update-icon-cache --quiet ${_datadir}/icons/hicolor &> /dev/null || :
fi
%postun
#this is needed to get gnome-panel to update the icons
update-desktop-database &> /dev/null || :
touch --no-create %{_datadir}/icons/hicolor || :
if [ -x %{_bindir}/gtk-update-icon-cache ] ; then
%{_bindir}/gtk-update-icon-cache --quiet ${_datadir}/icons/hicolor &> /dev/null || :
fi
%files
%defattr(-,root,root,-)
%{_installdir}
%{_bindir}
%{_datadir}/applications/
%{_datadir}/icons/
%doc
%if %{?createdevel:1}
%files devel
%defattr(-,root,root,-)
%{_includedir}
%{_sdkdir}
%{_idldir}
%endif
%if %{?createtests:1}
%files tests
%{_datadir}/%{_testsinstalldir}/tests/
%endif
#%changelog
#* %{name} %{version} %{moz_rpm_release}
#- Please see %{moz_source_repo}/shortlog/%{moz_source_stamp}

View File

@ -151,6 +151,97 @@ INNER_MAKE_PACKAGE = rm -f app.7z && \
INNER_UNMAKE_PACKAGE = $(CYGWIN_WRAPPER) 7z x $(UNPACKAGE) && \ INNER_UNMAKE_PACKAGE = $(CYGWIN_WRAPPER) 7z x $(UNPACKAGE) && \
mv core $(MOZ_PKG_DIR) mv core $(MOZ_PKG_DIR)
endif endif
#Create an RPM file
ifeq ($(MOZ_PKG_FORMAT),RPM)
PKG_SUFFIX = .rpm
MOZ_NUMERIC_APP_VERSION = $(shell echo $(MOZ_PKG_VERSION) | sed "s/[^0-9.].*//" )
MOZ_RPM_RELEASE = $(shell echo $(MOZ_PKG_VERSION) | sed "s/[0-9.]*//" )
RPMBUILD_TOPDIR=$(_ABS_DIST)/rpmbuild
RPMBUILD_RPMDIR=$(_ABS_DIST)
RPMBUILD_SRPMDIR=$(_ABS_DIST)
RPMBUILD_SOURCEDIR=$(RPMBUILD_TOPDIR)/SOURCES
RPMBUILD_SPECDIR=$(topsrcdir)/toolkit/mozapps/installer/linux/rpm
RPMBUILD_BUILDDIR=$(_ABS_DIST)/..
SPEC_FILE = $(RPMBUILD_SPECDIR)/mozilla.spec
RPM_INCIDENTALS=$(topsrcdir)/toolkit/mozapps/installer/linux/rpm
RPM_CMD = \
echo Creating RPM && \
mkdir -p $(RPMBUILD_SOURCEDIR) && \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py \
-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
-DMOZ_APP_DISPLAYNAME=$(MOZ_APP_DISPLAYNAME) \
< $(RPM_INCIDENTALS)/mozilla.desktop \
> $(RPMBUILD_SOURCEDIR)/$(MOZ_APP_NAME).desktop && \
rm -rf $(_ABS_DIST)/$(TARGET_CPU) && \
$(RPMBUILD) -bb \
$(SPEC_FILE) \
--target $(TARGET_CPU) \
--buildroot $(RPMBUILD_TOPDIR)/BUILDROOT \
--define "moz_app_name $(MOZ_APP_NAME)" \
--define "moz_app_displayname $(MOZ_APP_DISPLAYNAME)" \
--define "moz_app_version $(MOZ_APP_VERSION)" \
--define "moz_numeric_app_version $(MOZ_NUMERIC_APP_VERSION)" \
--define "moz_rpm_release $(MOZ_RPM_RELEASE)" \
--define "buildid $(BUILDID)" \
--define "moz_source_repo $(MOZ_SOURCE_REPO)" \
--define "moz_source_stamp $(MOZ_SOURCE_STAMP)" \
--define "moz_branding_directory $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)" \
--define "_topdir $(RPMBUILD_TOPDIR)" \
--define "_rpmdir $(RPMBUILD_RPMDIR)" \
--define "_sourcedir $(RPMBUILD_SOURCEDIR)" \
--define "_specdir $(RPMBUILD_SPECDIR)" \
--define "_srcrpmdir $(RPMBUILD_SRPMDIR)" \
--define "_builddir $(RPMBUILD_BUILDDIR)" \
--define "_prefix $(prefix)" \
--define "_libdir $(libdir)" \
--define "_bindir $(bindir)" \
--define "_datadir $(datadir)" \
--define "_installdir $(installdir)"
ifdef ENABLE_TESTS
RPM_CMD += \
--define "createtests yes" \
--define "_testsinstalldir $(shell basename $(installdir))"
endif
ifdef INSTALL_SDK
RPM_CMD += \
--define "createdevel yes" \
--define "_idldir $(idldir)" \
--define "_sdkdir $(sdkdir)" \
--define "_includedir $(includedir)"
endif
#For each of the main, tests, sdk rpms we want to make sure that
#if they exist that they are in objdir/dist/ and that they get
#uploaded and that they are beside the other build artifacts
MAIN_RPM= $(MOZ_APP_NAME)-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX)
UPLOAD_EXTRA_FILES += $(MAIN_RPM)
RPM_CMD += && mv $(TARGET_CPU)/$(MAIN_RPM) $(_ABS_DIST)/
ifdef ENABLE_TESTS
TESTS_RPM=$(MOZ_APP_NAME)-tests-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX)
UPLOAD_EXTRA_FILES += $(TESTS_RPM)
RPM_CMD += && mv $(TARGET_CPU)/$(TESTS_RPM) $(_ABS_DIST)/
endif
ifdef INSTALL_SDK
SDK_RPM=$(MOZ_APP_NAME)-devel-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX)
UPLOAD_EXTRA_FILES += $(SDK_RPM)
RPM_CMD += && mv $(TARGET_CPU)/$(SDK_RPM) $(_ABS_DIST)/
endif
INNER_MAKE_PACKAGE = $(RPM_CMD)
#Avoiding rpm repacks, going to try creating/uploading xpi in rpm files instead
INNER_UNMAKE_PACKAGE = $(error Try using rpm2cpio and cpio)
endif #Create an RPM file
ifeq ($(MOZ_PKG_FORMAT),APK) ifeq ($(MOZ_PKG_FORMAT),APK)
# we have custom stuff for Android # we have custom stuff for Android