File palemoon.spec of Package palemoon
#
# spec file for package palemoon
#
# Copyright (c) 2022 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# Build "palemoon" or "newmoon" - see https://www.palemoon.org/branding.shtml to decide...
%bcond_without modified
# things we may or may not want
%bcond_without pulseaudio
# use system libs wherever possible
%bcond_without system_icu
%bcond_without system_sqlite
%bcond_without system_libvpx
%bcond_without system_libevent
%bcond_without system_hunspell
%bcond_without system_nss
%bcond_without system_nspr
%bcond_without system_bz2
%bcond_without system_cairo
%bcond_without system_ffi
%bcond_without system_pixman
%bcond_without system_zlib
%if %{without modified}
%define pkgname palemoon
%define capname PaleMoon
%define _dash_n %{nil}
%else
%define pkgname newmoon
%define capname NewMoon
%define _dash_n -n %{pkgname}
%endif
%define _lto_cflags %{nil}
%define _app_name palemoon
%define _app_ver 31.3.0.1_Release
%define _locale_name palemoon-localizations
%define _locale_ver 31.3.0
%define _locale %(zcat %{_sourcedir}/%{_locale_name}-%{_locale_ver}.tar.gz | sed -n '/set\ LOCALES/s/.*\=//p')
%define _localeprov %(echo %_locale | tr ' ' ';')
# filtering provides and requires
%define _use_internal_dependency_generator 0
%define __find_provides sh %{SOURCE98}
%define __find_requires sh %{SOURCE99}
Name: %{_app_name}
Version: %{_app_ver}
Release: 0
Summary: Goanna-based, efficient and easy to use web browser
License: MPL-2.0 and GPL-2.0 and LGPL-2.1
Group: Productivity/Networking/Web/Browsers
Url: http://www.palemoon.org/
Source0: %{name}-%{version}.tar.gz
Source1: %{_locale_name}-%{_locale_ver}.tar.gz
Source2: %{name}.in
Source3: %{name}.desktop
Source4: %{name}-mimeinfo.xml
Source5: spellcheck.js
Source6: default-prefs.js
Source7: distribution.ini.in
Source97: %{name}.rpmlintrc
Source98: find-internal-provides.sh
Source99: find-external-requires.sh
# PATCH-FIX-OPENSUSE vendor.patch -- Change the default name
Patch0: palemoon-vendor.patch
# PATCH-FIX-OPENSUSE profile.patch -- Change default preferences
Patch1: palemoon-profile.patch
# PATCH-FIX-UPSTREAM nongnome-proxies.patch -- Don't use gconf for proxy settings
Patch2: palemoon-nongnome-proxies.patch
# PATCH-FIX-UPSTREAM fix_building_with_binutil_2.41.patch
Patch3: fix_building_with_binutil_2.41.patch
BuildRequires: autoconf213
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: gcc7-c++
BuildRequires: gtk3-devel
BuildRequires: hicolor-icon-theme
BuildRequires: libXss-devel
BuildRequires: pkgconfig
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(bzip2)
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(gl)
BuildRequires: pkgconfig(gtk+-2.0)
BuildRequires: pkgconfig(hunspell)
BuildRequires: pkgconfig(icu-io)
BuildRequires: pkgconfig(libevent)
BuildRequires: pkgconfig(libffi)
BuildRequires: pkgconfig(libnotify)
%if %{with pulseaudio}
BuildRequires: pkgconfig(libpulse)
%endif
BuildRequires: pkgconfig(libstartup-notification-1.0)
BuildRequires: pkgconfig(nspr)
BuildRequires: pkgconfig(nss)
BuildRequires: pkgconfig(pixman-1)
BuildRequires: pkgconfig(python)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(vpx)
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(xt)
BuildRequires: pkgconfig(zlib)
BuildRequires: python-xml
BuildRequires: unzip
BuildRequires: update-desktop-files
BuildRequires: yasm
BuildRequires: zip
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: %ix86 x86_64
%py_requires
# these only make sense if we're using system mozilla-{nss,nspr}
Requires: mozilla-nspr >= %(rpm -q --queryformat '%%{VERSION}' mozilla-nspr)
Requires: mozilla-nss >= %(rpm -q --queryformat '%%{VERSION}' mozilla-nss)
%if %{with modified}
%description
__unused__
%package %{_dash_n}
Summary: Goanna-based, efficient and easy to use web browser
Group: Productivity/Networking/Web/Browsers
Provides: %{name} = %{version}
Obsoletes: %{name} < %{version}
%endif
%description %{_dash_n}
Pale Moon offers you a browsing experience in a browser completely built
from its own, independently developed source that has been forked off from
Firefox/Mozilla code, with carefully selected features and optimizations to
improve the browser's speed*, resource use, stability and user experience,
while offering full customization and a growing collection of extensions
and themes to make the browser truly your own.
%if %{with modified}
Note: This is an unofficial build of the Pale Moon browser.
%endif
%{expand:%(\
for lang in %{_locale}; do \
echo "%%{expand:%%(cat << EOF >&1
%package -n %{pkgname}-trans-$lang
Summary: Translation for package %{pkgname}
Group: System/Localization
Provides: locale(%{pkgname}:$lang)
Requires: %{pkgname} = %{version}
%description -n %{pkgname}-trans-$lang
This package contains translation for the user interface of %{pkgname}.
%files -n %{pkgname}-trans-$lang -f $lang.lang
%defattr(-,root,root)
EOF)}"; \
done)}
%prep
%setup -b1
%if %{with modified}
%autopatch -p1
%endif
# create .desktop file
for _file in %{SOURCE3}; do
sed -e 's|@NAME@|%{capname}|g' \
-e 's|@EXEC@|%{pkgname}|g' \
-e 's|@ICON@|%{pkgname}|g' \
< $_file > %{pkgname}.desktop
done
%if %{with modified}
# set plugindir default
sed -e 's,%{_libdir}/mozilla/plugins,%{_libdir}/browser-plugins,g' \
-i $(grep -wrl '%{_libdir}/mozilla/plugins')
%endif
# don't compile in DATE and TIME
BUILDDATE=$(LC_ALL=C date -ur %{_sourcedir}/%{name}.changes +'%b %d %Y')
BUILDTIME=$(LC_ALL=C date -ur %{_sourcedir}/%{name}.changes +'%H:%M')
sed -e "s/__DATE__/\"$BUILDDATE\"/g" \
-e "s/__TIME__/\"$BUILDTIME\"/g" \
-i $(grep -rl '__DATE__\|__TIME__')
# openSUSE info
%if 0%{?is_opensuse}
DISTRIBUTION=openSUSE
%else
DISTRIBUTION=SLE
%endif
VERSION=%{suse_version}
BUILDTIME="$BUILDDATE $BUILDTIME"
sed -e "s/@DISTRIBUTION@/$DISTRIBUTION/" \
-e "s/@VERSION@/$VERSION/" \
-e "s/@BUILDTIME@/$BUILDTIME/" \
< %{SOURCE7} > distribution.ini
# use RPM_OPT_FLAGS
sed -e '/^OS_CFLAGS/s/$/\ \$\(NSS_OPT_FLAGS\)/' \
-i $(find -iname linux.mk | xargs grep -l '^OS_CFLAGS.*=')
sed -e '/^AM_CFLAGS.=/s/$/\ \$\(FFI_OPT_FLAGS\)/' \
-i $(grep -rl 'JC1FLAGS' platform/js)
%build
export CC=gcc-7
export CXX=g++-7
CFLAGS="$(echo %{optflags} | sed -r 's/\ \-\<g\>//;s/\ \-fstack-clash-protection//;s/\-flto=([0-9]+|[a-z]+)//')"
CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
export PM_OPT_FLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
%ifarch %ix86
export CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
export PM_OPT_FLAGS="$PM_OPT_FLAGS -msse2 -mfpmath=sse"
%endif
export CXXFLAGS="$CFLAGS -std=gnu++11"
export LDFLAGS="-Wl,--as-needed -Wl,-z,now"
export NSS_OPT_FLAGS="$CFLAGS"
export FFI_OPT_FLAGS="$CFLAGS"
%if %{with modified}
export MOZILLA_OFFICIAL=0
%else
export MOZILLA_OFFICIAL=1
%endif
export MOZ_TELEMETRY_REPORTING=0
export MOZ_PKG_SPECIAL=gtk3
export MOZCONFIG=$PWD/mozconfig
# cap make threads to avoid OOMs
THREADS="$(echo %{?_smp_mflags} | sed -e's/.*-j\([0-9]\+\).*/\1/')"
[ -z "$THREADS" ] || [ "$THREADS" -gt 16 ] && THREADS=16
_SMP_MFLAGS="$(echo %{?_smp_mflags} | sed -e's/-j[0-9]\+/-j'$THREADS'/')"
cat << EOF > $MOZCONFIG
# base options
mk_add_options MOZ_MAKE_FLAGS="$_SMP_MFLAGS"
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../pmbuild
ac_add_options --prefix=%{_prefix}
ac_add_options --libdir=%{_libdir}
ac_add_options --disable-accessibility
ac_add_options --enable-application=%{name}
ac_add_options --enable-alsa
ac_add_options --enable-av1
ac_add_options --enable-default-toolkit=cairo-gtk3
ac_add_options --disable-debug
ac_add_options --disable-debug-symbols
ac_add_options --enable-eme
ac_add_options --enable-ffmpeg
ac_add_options --disable-gamepad
ac_add_options --disable-gconf
ac_add_options --enable-jemalloc
%if %{with modified}
ac_add_options --disable-official-branding
%else
ac_add_options --enable-official-branding
%endif
ac_add_options --enable-optimize="$PM_OPT_FLAGS"
ac_add_options --disable-necko-wifi
ac_add_options --disable-parental-controls
ac_add_options --enable-phoenix-extensions
ac_add_options --enable-pie
ac_add_options --with-pthreads
%if %{with pulseaudio}
ac_add_options --enable-pulseaudio
%else
ac_add_options --disable-pulseaudio
%endif
ac_add_options --enable-startup-notification
ac_add_options --enable-strip
ac_add_options --disable-tests
ac_add_options --disable-updater
ac_add_options --enable-webrtc
ac_add_options --x-libraries=%{_libdir}
## use system libs
%{!?with_system_bz2: ac_add_options --with-system-bz2}
%{!?with_system_cairo: ac_add_options --enable-system-cairo}
%{!?with_system_ffi: ac_add_options --enable-system-ffi}
%{!?with_system_hunspell: ac_add_options --enable-system-hunspell}
%{!?with_system_icu: ac_add_options --with-system-icu}
%{!?with_system_libevent: ac_add_options --with-system-libevent}
%{!?with_system_libvpx: ac_add_options --with-system-libvpx}
%{!?with_system_nspr: ac_add_options --with-system-nspr}
%{!?with_system_nss: ac_add_options --with-system-nss}
%{!?with_system_pixman: ac_add_options --enable-system-pixman}
%{!?with_system_sqlite: ac_add_options --enable-system-sqlite}
%{!?with_system_zlib: ac_add_options --with-system-zlib}
EOF
make -f client.mk clobber
make -f client.mk build
%install
export CC=gcc-7
export CXX=g++-7
CFLAGS="$(echo %{optflags} | sed -r 's/\ \-\<g\>//;s/\ \-fstack-clash-protection//;s/\-flto=([0-9]+|[a-z]+)//')"
CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
export PM_OPT_FLAGS="-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
%ifarch %ix86
export CFLAGS="$CFLAGS -msse2 -mfpmath=sse"
export PM_OPT_FLAGS="$PM_OPT_FLAGS -msse2 -mfpmath=sse"
%endif
export CXXFLAGS="$CFLAGS -std=gnu++11"
export LDFLAGS="-Wl,--as-needed -Wl,-z,now"
export NSS_OPT_FLAGS="$CFLAGS"
export FFI_OPT_FLAGS="$CFLAGS"
%if %{with modified}
export MOZILLA_OFFICIAL=0
%else
export MOZILLA_OFFICIAL=1
%endif
export MOZ_TELEMETRY_REPORTING=0
export MOZ_PKG_SPECIAL=gtk3
export MOZCONFIG=$PWD/mozconfig
# see: config/baseconfig.mk
make -f client.mk \
DESTDIR=%{buildroot} \
idldir=%{_datadir}/idl/%{pkgname} \
includedir=%{_includedir}/%{pkgname} \
installdir=%{_libdir}/%{pkgname} \
sdkdir=%{_libdir}/%{pkgname}-devel \
install
rm -rf %{buildroot}%{_datadir}/idl/%{pkgname} \
%{buildroot}%{_includedir}/%{pkgname} \
%{buildroot}%{_libdir}/%{pkgname}-devel
# startup script
pushd %{buildroot}
app_launcher() {
rm -f .{%{_bindir},%{_libdir}/%{pkgname}}/%{name}
install -Dm0755 %{SOURCE2} .%{_libdir}/%{pkgname}/%{pkgname}
ln -sf ../%{_lib}/%{pkgname}/%{pkgname} .%{_bindir}/%{pkgname}
}
if [ -L .%{_bindir}/%{name} ]; then
find -type f | xargs file | grep ELF | grep %{name} | cut -f 1 -d : | while read bin; do
if $(echo $bin | grep -q %{name}-bin); then
if [ "$bin" != ".%{_libdir}/%{pkgname}/%{pkgname}-bin" ] ; then
mv $bin .%{_libdir}/%{pkgname}/%{pkgname}-bin
fi
app_launcher
break
elif ! ls .%{_libdir}/%{name}/%{name}-bin &> /dev/null; then
install -Dm0755 $bin .%{_libdir}/%{pkgname}/%{pkgname}-bin
app_launcher
fi
done
fi
# set LD_LIBRARY_PATH
pushd .%{_libdir}/%{pkgname}
libs=$(find ./*/ -name \*.so \
| xargs dirname \
| uniq \
| sed 's/^\./\$HERE/' \
| tr '\n' ':')
if [ -n "$libs" ]; then
sed -i "/LD_LIBRARY_PATH/s|\"\(.*\)\"|\"$libs\1\"|" %{pkgname}
fi
popd
popd
# install gre prefs
install -Dm0644 %{SOURCE5} %{buildroot}%{_libdir}/%{pkgname}/defaults/pref/spellcheck.js
%if %{with modified}
# install browser prefs
install -Dm0644 %{SOURCE6} %{buildroot}/%{_libdir}/%{pkgname}/browser/defaults/preferences/%{pkgname}.js
# openSUSE bookmarks, homepage and info
install -Dm0644 {,%{buildroot}%{_libdir}/%{pkgname}/distribution/}distribution.ini
%endif
# additional mime-types
install -Dm0644 %{SOURCE4} %{buildroot}%{_datadir}/mime/packages/%{pkgname}.xml
# install icon files
%if %{with modified}
pushd palemoon/branding/unofficial
%else
pushd palemoon/branding/official
%endif
for size in 16 32 48 128 256; do
find -name \*$size.png | while read icon; do
size=$(echo $icon | sed 's/[^0-9]//g')
install -Dm0644 $icon %{buildroot}%{_datadir}/icons/hicolor/${size}x${size}/apps/%{pkgname}.png
done
done
popd
# install .desktop files
%suse_update_desktop_file -i %{pkgname}
%fdupes %{buildroot}%{_datadir}
%fdupes %{buildroot}%{_libdir}
# function to get a list of files
# $1 - output file name
# $2 - only include files from this subdirectory down
# $3 - exclude pattern (regex)
gen_filelist() {
listfile=$PWD/$1
rm -f $listfile
pushd %{buildroot}
find "./$2" | while read file; do
[ -n "$3" ] && [[ $file =~ "$3" ]] && continue
[ -d "$file" ] && echo "%dir ${file#.}" >> $listfile
[ -d "$file" ] || echo "${file#.}" >> $listfile
done
popd
}
gen_filelist file.list "" langpack
# install langs
mkdir -p %{buildroot}%{_libdir}/%{pkgname}/browser/extensions
find ../%{_locale_name}-%{_locale_ver}/ -type f -iname '.*' -exec rm -f {} \;
for lang in %{_locale}; do
%if %{with modified}
find ../%{_locale_name}-%{_locale_ver}/$lang \( -name brand.properties -o -name brand.dtd \) -exec sed -i '/brand/s/Pale\ Moon/New Moon/' {} \;
%endif
find ../%{_locale_name}-%{_locale_ver}/$lang -depth -name AB-CD -type d | while read _dir; do
mv ${_dir%/*}/{${_dir##*/},$lang}
done
cp -rL ../%{_locale_name}-%{_locale_ver}/$lang %{buildroot}%{_libdir}/%{pkgname}/browser/extensions/langpack-$lang@palemoon.org
gen_filelist $lang.lang %{_libdir}/%{pkgname}/browser/extensions/langpack-$lang@palemoon.org
done
%pre %{_dash_n}
if [ "$1" -eq 1 ] ; then
grep ^flags /proc/cpuinfo | grep -qs sse2
if [ $? -ne 0 ]; then
echo "This computer cannot run %{pkgname} because its hardware is no longer supported." 1>&2; exit 1
fi
fi
%post %{_dash_n}
%mime_database_post
%icon_theme_cache_post
%desktop_database_post
%postun %{_dash_n}
%mime_database_postun
%icon_theme_cache_postun
%desktop_database_postun
%files %{_dash_n} -f file.list
%defattr(-,root,root)
%doc AUTHORS LICENSE
%changelog