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/
#
#do not requires/provides libraries present in %%_libdir/%%pkgname
%define __provides_exclude ^(libfreeblpriv3\\.so.*|libhunspell\\.so.*|liblgpllibs\\.so.*|libmozavcodec\\.so.*|libmozavutil\\.so.*|libmozgtk\\.so.*|libmozsqlite3\\.so.*|libnspr4\\.so.*|libnss3\\.so.*|libnssckbi\\.so.*|libnssutil3\\.so.*|libplc4\\.so.*|libplds4\\.so.*|libsmime3\\.so.*|libsoftokn3\\.so.*|libssl3\\.so.*|libxul\\.so.*)$
%define __requires_exclude ^(libfreeblpriv3\\.so.*|libhunspell\\.so.*|liblgpllibs\\.so.*|libmozavcodec\\.so.*|libmozavutil\\.so.*|libmozgtk\\.so.*|libmozsqlite3\\.so.*|libnspr4\\.so.*|libnss3\\.so.*|libnssckbi\\.so.*|libnssutil3\\.so.*|libplc4\\.so.*|libplds4\\.so.*|libsmime3\\.so.*|libsoftokn3\\.so.*|libssl3\\.so.*|libxul\\.so.*)$
# 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
%bcond_with clang
# Applies to either g++ or clang
%if 0%{?suse_version} <= 1600
%define compiler_version 13
%else
%define compiler_version 14
%endif
%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 33.7.0_Release
%define _locale_name palemoon-localizations
%define _locale_ver 33.7.0
%define _locale %(zcat %{_sourcedir}/%{_locale_name}-%{_locale_ver}.tar.gz | sed -n '/set\ LOCALES/s/.*\=//p')
%define _localeprov %(echo %_locale | tr ' ' ';')
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
Source8: Python-2.7.18.tar.xz
# 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
BuildRequires: dos2unix
BuildRequires: fdupes
%if %{with clang}
BuildRequires: clang%{compiler_version}
%else
BuildRequires: gcc%{compiler_version}-c++
%endif
BuildRequires: gtk2-devel
BuildRequires: gtk3-devel
BuildRequires: libevent
BuildRequires: m4
BuildRequires: pkgconfig
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(bzip2)
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(gl)
BuildRequires: pkgconfig(hunspell)
BuildRequires: pkgconfig(libffi)
%if %{with pulseaudio}
BuildRequires: pkgconfig(libpulse)
%endif
BuildRequires: pkgconfig(libstartup-notification-1.0)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(pixman-1)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(xt)
BuildRequires: pkgconfig(zlib)
BuildRequires: unzip
BuildRequires: update-desktop-files
BuildRequires: yasm
BuildRequires: zip
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: %ix86 x86_64
%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
%build
#python 2.7 is required to build palemoon
#tumbleweed and Leap 16.0 do not provide it anymore
mkdir aux
tar fx %SOURCE8 -C aux
P27DEST=$PWD/aux
cd aux/Python-2.7.18
./configure --prefix=$P27DEST
%make_build
make install
cd ../..
PATH=$P27DEST/bin:$PATH
### TODO: Get LTO working.
### TODO: Also see if elf-hack can be enabled.
%if %{with clang}
export CC=clang-%{compiler_version}
export CXX=clang++-%{compiler_version}
%else
export CC=gcc-%{compiler_version}
export CXX=g++-%{compiler_version}
%endif
# STRONG recommendation of upstream
export PM_OPT_FLAGS="-O2 -w"
%if %{with modified}
export MOZILLA_OFFICIAL=0
%else
export MOZILLA_OFFICIAL=1
%endif
export MOZCONFIG=$PWD/.mozconfig
export MOZ_PKG_SPECIAL=gtk3
# 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
%if %{with pulseaudio}
ac_add_options --enable-pulseaudio
%else
ac_add_options --disable-pulseaudio
%endif
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-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-pie
ac_add_options --with-pthreads
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}
EOF
make -f client.mk clobber
make -f client.mk build
%install
#include in PATH python 2.7 binaries
PATH=$PWD/aux/bin:$PATH
### NOTE: Keep this in sync with the %%build section above or Bad Things(tm) could happen...
%if %{with clang}
export CC=clang-%{compiler_version}
export CXX=clang++-%{compiler_version}
%else
export CC=gcc-%{compiler_version}
export CXX=g++-%{compiler_version}
%endif
# STRONG recommendation of upstream
export PM_OPT_FLAGS="-O2 -w"
%if %{with modified}
export MOZILLA_OFFICIAL=0
%else
export MOZILLA_OFFICIAL=1
%endif
export MOZCONFIG=$PWD/.mozconfig
export MOZ_PKG_SPECIAL=gtk3
# 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}
# 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
#remove rpmlint warning: standard-dir-owned-by-package
sed -r -i '\@^%dir (/|/usr|/usr/bin|/usr/include|/usr/lib64|/usr/share|/usr/share/icons)$@d' file.list
# 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
%fdupes %{buildroot}%{_datadir}
%fdupes %{buildroot}%{_libdir}
%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