File LibreWolf.spec of Package LibreWolf
#
# spec file for package LibreWolf
#
# Copyright (c) 2024 SUSE LLC
# Copyright (c) 2006-2024 Wolfgang Rosenauer <wr@rosenauer.org>
# Copyright (c) 2021-2024 zzndb001 <zzndb001@gmail.com>
# Copyright (c) 2024 Boian Berberov
#
# 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 https://bugs.opensuse.org/
#
### Conditional Build Options ###
%bcond_with ccache
%bcond_without clang_build
%bcond_with lto_cond
%define lto_parallelism 1
%bcond_with pgo_cond
### Build Configuration ###
# Handle executables or shared libraries containing more than COUNT debugging
# information entries in their .debug_info section using a slower and more
# memory usage friendly mode and don’t attempt to optimize that object in
# multifile mode. The default is 10 million DIEs. There is a risk that for
# very large amounts of debugging information in a single shared library or
# executable there might not be enough memory (especially when dwz tool is
# 32‐bit binary, it might run out of available virtual address space even
# sooner). Specifying none as argument disables the limit.
# OBS Default: _dwz_low_mem_die_limit 10000000
# , ,
%define _dwz_low_mem_die_limit 40000000
# Don’t attempt to optimize executables or shared libraries containing more
# than COUNT DIEs at all. The default is 50 million DIEs. Specifying `none`
# as argument disables the limit.
# OBS Default: _dwz_max_die_limit 50000000
# , ,
%define _dwz_max_die_limit 200000000
# Firefox only supports i686 with SSE2
%ifarch %ix86
ExclusiveArch: i586 i686 pentium4
BuildArch: i686
%{expand:%%global optflags %(echo "%optflags"|sed -e s/i586/i686/) -march=i686 -mtune=generic -msse2}
%endif
%if 0%{with lto_cond}
%{expand:%%global optflags $(echo "%optflags" | sed -e s/-flto=[[:alnum:]]*//) -flto=%{lto_parallelism} }
%else
%{expand:%%global optflags $(echo "%optflags" | sed -e s/-flto=[[:alnum:]]*//) }
%endif
### General Build Definitions ###
%define up_name firefox
%define up_version 131.0.2
%define up_srcdir %{up_name}-%{up_version}
# https://github.com/mozilla-l10n/firefox-l10n
%define up_l10n_rev 763e687f86fd289223d0d2c5ca9442318b1f9721
%define up_l10n_srcdir firefox-l10n-%{up_l10n_rev}
# https://github.com/openSUSE/firefox-maintenance
# 130.0
%define openSUSE_rev e90c1984168bbbce9890cda8a0a6e018c218576d
%define openSUSE_srcdir firefox-maintenance-%{openSUSE_rev}
# https://codeberg.org/librewolf/source
%define lw_src_rel 1
%define lw_src_srcdir source
# https://codeberg.org/librewolf/settings
# 8.4
%define lw_set_rev d2761c34d82082b4459ed5eee37af03766c613f7
%define lw_set_srcdir settings
%define softname librewolf
### Package ###
Name: LibreWolf
Version: %{up_version}
Release: %{lw_src_rel}.0
Group: Productivity/Networking/Web/Browsers
Summary: A custom version of Firefox, focused on privacy, security and freedom
License: MPL-2.0
URL: https://librewolf.net/
Source0: https://archive.mozilla.org/pub/%{up_name}/releases/%{up_version}/source/%{up_srcdir}.source.tar.xz
Source1: https://github.com/mozilla-l10n/firefox-l10n/archive/%{up_l10n_rev}.tar.gz
Source2: https://github.com/openSUSE/firefox-maintenance/archive/%{openSUSE_rev}.tar.gz
Source3: https://codeberg.org/librewolf/source/archive/%{version}-%{lw_src_rel}.tar.gz
Source4: https://codeberg.org/librewolf/settings/archive/%{lw_set_rev}.tar.gz
Source5: openSUSE-firefox-maintenance-patches.txt
BuildRequires: autoconf213
BuildRequires: fdupes
BuildRequires: findutils
BuildRequires: makeinfo
BuildRequires: memory-constraints
BuildRequires: update-desktop-files
BuildRequires: xz
BuildRequires: zip unzip
%if 0%{with ccache}
BuildRequires: ccache
%endif
# BuildRequires: Assemblers
BuildRequires: nasm >= 2.14
BuildRequires: yasm
# BuildRequires: GCC
%if 0%{?is_opensuse}
%if 0%{?sle_version} <= 150600
%if 0%{?sle_version} == 150600
BuildRequires: gcc13
BuildRequires: gcc13-c++
%global gcc_ver gcc-13
%global gpp_ver g++-13
%else
%if 0%{?sle_version} == 150500
BuildRequires: gcc12
BuildRequires: gcc12-c++
%global gcc_ver gcc-12
%global gpp_ver g++-12
%else
BuildRequires: gcc >= 10
BuildRequires: gcc-c++ >= 10
%global gcc_ver gcc
%global gpp_ver g++
%endif
%endif
%else
BuildRequires: gcc
BuildRequires: gcc-c++
%global gcc_ver gcc
%global gpp_ver g++
%endif
%else
BuildRequires: gcc
%global gcc_ver gcc
%endif
# BuildRequires: Clang
BuildRequires: clang-devel >= 5
# BuildRequires: Rust TODO
%if 0%{?sle_version}
BuildRequires: cargo1.78
BuildRequires: rust1.78
%else
BuildRequires: cargo
BuildRequires: rust
%endif
BuildRequires: rust-cbindgen >= 0.26
# BuildRequires: Python TODO
%if 120000 <= 0%{?sle_version} && 0%{?sle_version} < 150000
BuildRequires: libXtst-devel
BuildRequires: python-libxml2
BuildRequires: python39
BuildRequires: python39-curses
BuildRequires: python39-devel
%else
%if 150000 <= 0%{?sle_version} && 0%{?sle_version} <= 150600
BuildRequires: python39
BuildRequires: python39-curses
BuildRequires: python39-devel
%else
# python3 <= 3.11
BuildRequires: python3 >= 3.8
BuildRequires: python3-curses
BuildRequires: python3-devel
# TODO BUG Telemetry?!
# # BuildRequires: python3-glean == 60.4.0
# BuildRequires: python3-psutil >= 5.4.2
# # BuildRequires: python3-psutil <= 5.9.4
# BuildRequires: python3-zstandard >= 0.11.1
# BuildRequires: python3-zstandard <= 0.22.0
%endif
%endif
# BuildRequires: nodejs TODO
%if 150000 <= 0%{?sle_version} && 0%{?sle_version} <= 150600
BuildRequires: nodejs12 >= 12.22.12
%else
BuildRequires: nodejs >= 12.22.12
%endif
# BuildRequires: Headers
BuildRequires: alsa-devel
BuildRequires: dbus-1-glib-devel
BuildRequires: libcurl-devel
BuildRequires: libiw-devel
BuildRequires: libproxy-devel
BuildRequires: libXcomposite-devel
BuildRequires: Mesa-devel
BuildRequires: mozilla-nspr-devel >= 4.35
BuildRequires: mozilla-nss-devel >= 3.102.1
BuildRequires: xorg-x11-libXt-devel
# BuildRequires: pkgconfig()
%if 0%{?suse_version} < 1550
BuildRequires: pkgconfig(gconf-2.0) >= 1.2.1
%endif
BuildRequires: pkgconfig(glib-2.0) >= 2.22
BuildRequires: pkgconfig(gobject-2.0)
BuildRequires: pkgconfig(gtk+-3.0) >= 3.14.0
BuildRequires: pkgconfig(gtk+-unix-print-3.0)
BuildRequires: pkgconfig(libffi) > 3.0.9
BuildRequires: pkgconfig(libpulse)
# BuildRequires: pkgconfig(icu-i18n) >= 73.1 # Fails to build
BuildRequires: pkgconfig(zlib) >= 1.2.3
# BuildRequires: Other
BuildRequires: dejavu-fonts
%if 0%{with pgo_cond}
BuildRequires: xvfb-run
%endif
# Requires: Libraries
Requires: libfreetype6 >= 2.13.2
Requires: mozilla-nspr >= 4.35
Requires: mozilla-nss >= 3.102.1
Requires(post): shared-mime-info desktop-file-utils
Requires(postun): shared-mime-info desktop-file-utils
Provides: appdata()
Provides: appdata(firefox.appdata.xml)
Provides: web_browser
ExcludeArch: armv6l armv6hl ppc ppc64
# BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
A custom version of Firefox, focused on privacy, security and freedom.
### Build Steps ###
%prep
%setup -q -c -a 1 -a 2 -a 3 -a 4
cd %{_builddir}/%{name}-%{version}/%{up_srcdir}
# OBS memory-constraints settings
# NOTE: must be set before any use of %{jobs}
%limit_build -m 8000
# ###
# LibreWolf Patches, etc.
# From https://codeberg.org/librewolf/source/src/branch/main/scripts/librewolf-patches.py, Line 87
# ###
# create the right mozconfig file
%__cp -v ../%{lw_src_srcdir}/assets/mozconfig.new.without-bootstrap mozconfig
# copy branding files
%__cp -rv ../%{lw_src_srcdir}/themes/browser .
# copy the right search-config.json file
%__cp -v ../%{lw_src_srcdir}/assets/search-config.json services/settings/dumps/main/search-config.json
# read lines of .txt file into 'patches'
while read patch_filename
do
%__patch -p1 -i ../%{lw_src_srcdir}/${patch_filename}
done < ../%{lw_src_srcdir}/assets/patches.txt
# apply xmas.patch seperately because not all builders use this repo the same way,
# and we don't want to disturbe those workflows
%__patch -p1 -i ../%{lw_src_srcdir}/patches/xmas.patch
# vs_pack.py issue... should be temporary
%__cp -v ../%{lw_src_srcdir}/patches/pack_vs.py build/vs/
# Apply most recent `settings` repository files.
%__mkdir -p lw
%__cp -v ../%{lw_set_srcdir}/librewolf.cfg lw/
%__cp -v ../%{lw_set_srcdir}/distribution/policies.json lw/
%__cp -v ../%{lw_set_srcdir}/defaults/pref/local-settings.js lw/
#
# pref-pane patches
#
# 1) patch it in
%__patch -p1 -i ../%{lw_src_srcdir}/patches/pref-pane/pref-pane-small.patch
# 2) new files
%__cp -v ../%{lw_src_srcdir}/patches/pref-pane/category-librewolf.svg browser/themes/shared/preferences/category-librewolf.svg
%__cp -v ../%{lw_src_srcdir}/patches/pref-pane/librewolf.css browser/themes/shared/preferences/librewolf.css
%__cp -v ../%{lw_src_srcdir}/patches/pref-pane/librewolf.inc.xhtml browser/components/preferences/librewolf.inc.xhtml
%__cp -v ../%{lw_src_srcdir}/patches/pref-pane/librewolf.js browser/components/preferences/librewolf.js
# 3) append our locale string values to preferences.ftl
%__cat \
../%{lw_src_srcdir}/patches/pref-pane/preferences.ftl \
>> browser/locales/en-US/browser/preferences/preferences.ftl
# provide a script that fetches and bootstraps Nightly and some mozconfigs
# %__cp -v ../%{lw_src_srcdir}/scripts/mozfetch.sh lw/
# %__cp -v \
# ../%{lw_src_srcdir}/assets/mozconfig.new \
# ../%{lw_src_srcdir}/assets/mozconfig.new.without-bootstrap \
# ../%{lw_src_srcdir}/scripts/setup-wasi-linux.sh \
# lw/
#
# override the firefox version
echo "%{version}-%{release}" > browser/config/version.txt
echo "%{version}-%{release}" > browser/config/version_display.txt
#
# generate locales
%__mkdir_p browser/locales/l10n
while read shipped_locale; do
if [ ${shipped_locale} == 'en-US' ]
then
continue
fi
%__cp -R ../%{up_l10n_srcdir}/${shipped_locale} browser/locales/l10n/
%__mv browser/locales/l10n/${shipped_locale}/browser/branding/official \
browser/locales/l10n/${shipped_locale}/browser/branding/%{softname}
find browser/locales/l10n/${shipped_locale} -type f \
-exec %__sed -i -e 's/Mozilla Firefox/LibreWolf/g' {} \;
find browser/locales/l10n/${shipped_locale} -type f \
-exec %__sed -i -e 's/Mozilla/LibreWolf/g' -e 's/Firefox/LibreWolf/g' {} \;
done < browser/locales/shipped-locales
# ###
# openSUSE patches
# ###
# read lines of .txt file into 'patches'
while read patch_filename
do
if [[ "${patch_filename:0:1}" == '#' ]]
then
continue
else
%__patch -p1 -i ../%{openSUSE_srcdir}/${patch_filename}
fi
done < %{SOURCE5}
# ###
# openSUSE configuration
# ###
# Rust SIMD is architecture specific
%__sed -i -e '/able-rust-simd/d' mozconfig
# ###
# LibreWolf configuration
# ###
cat << EOF >> mozconfig
# MOZBUILD_STATE_PATH
mk_add_options MOZ_MAKE_FLAGS=%{?jobs:-j%jobs}
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obj
mk_add_options MOZ_CRASHREPORTER=0
mk_add_options MOZ_DATA_REPORTING=0
mk_add_options MOZ_SERVICES_HEALTHREPORT=0
mk_add_options MOZ_TELEMETRY_REPORTING=0
ac_add_options --disable-bootstrap
ac_add_options --prefix=%{_prefix}
ac_add_options --libdir=%{_libdir}
ac_add_options --includedir=%{_includedir}
ac_add_options --enable-release
ac_add_options --enable-update-channel=release
ac_add_options --enable-hardening # Default is same as enable
ac_add_options --disable-crashreporter
ac_add_options --disable-debug
ac_add_options --disable-tests
ac_add_options --disable-updater
# Branding
ac_add_options --disable-official-branding
ac_add_options --with-app-name=%{name}
# ac_add_options --with-app-softname=%{softname} # defaults to lowercase of --with-app-name
ac_add_options --with-branding=browser/branding/%{softname}
ac_add_options --with-distribution-id=net.librewolf
ac_add_options --allow-addon-sideload
ac_add_options --with-unsigned-addon-scopes=app,system
# Features
ac_add_options --enable-alsa
# # ac_add_options --enable-libproxy
ac_add_options --enable-default-toolkit=cairo-gtk3
# System libraries
ac_add_options --with-system-ffi
# ac_add_options --with-system-icu # NOTE Fails to build
# NOTE firefox-130.0.1/intl/lwbrk/LineBreaker.cpp:453:17:
# NOTE error: static assertion failed due to requirement 'U_LB_COUNT == mozilla::ArrayLength(sUnicodeLineBreakToClass)':
# NOTE Gecko vs ICU LineBreak class mismatch
ac_add_options --with-system-nspr
ac_add_options --with-system-nss
ac_add_options --with-system-zlib
# ac_add_options --with-system-webp
# ac_add_options --with-system-libvpx
# ac_add_options --with-system-jpeg
# ac_add_options --with-system-png
# ac_add_options --with-system-libevent
# at least temporary until the "wasi-sysroot" issue is solved
ac_add_options --without-wasm-sandboxed-libraries
# Architecture-specific
%ifarch x86_64 aarch64
ac_add_options --enable-rust-simd # x86_64 aarch64
%else
ac_add_options --disable-rust-simd # not x86_64 aarch64
%endif
%ifarch %arm
ac_add_options --with-fpu=vfpv3-d16 # %arm
ac_add_options --with-float-abi=hard # %arm
%ifarch armv6l armv6hl
ac_add_options --with-arch=armv6 # armv6l armv6hl
%endif
%ifarch armv7l armv7hl armv7hnl
ac_add_options --with-arch=armv7-a # armv7l armv7hl armv7hnl
%endif
%endif
# LTO
# LTO needs newer toolchain stack only (at least GCC 8.2.1 (r268506)
%if 0%{with lto}
ac_add_options --enable-lto
%else
ac_add_options --disable-lto
%endif
# PGO
%if 0%{with pgo_cond}
ac_add_options MOZ_PGO=1
%else
# ac_add_options MOZ_PGO=1
%endif
# --enable-linker={bfd, gold, ld64, lld, lld-*, mold}
EOF
%build
cd %{_builddir}/%{name}-%{version}/%{up_srcdir}
%set_build_flags
# export MOZ_OPTIMIZE_FLAGS
#ifarch %ix86
# Not enough memory on 32-bit systems, reduce debug info.
export CFLAGS="${CFLAGS} -g1"
export CXXFLAGS="${CXXFLAGS} -g1"
#endif
export LDFLAGS="${LDFLAGS} -fPIC -Wl,-z,relro,-z,now"
%if 0%{with clang_build}
export CC=clang
export CXX=clang++
%else
export CC=%{gcc_ver}
export CXX=%{gpp_ver}
%endif
export MOZ_NOSPAM=1
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
export MOZBUILD_STATE_PATH=%{_builddir}/%{name}-%{version}/mozbuild
./mach configure
./mach build --verbose
%install
cd %{_builddir}/%{name}-%{version}/%{up_srcdir}
DESTDIR=%{buildroot} ./mach install
%__mkdir -p %{buildroot}%{_libdir}/%{softname}/browser/extensions
# install %{_builddir}/langpacks_artifacts/* %{buildroot}%{_libdir}/%{softname}/browser/extensions/
%__mkdir -p %{buildroot}%{_libdir}/%{softname}/distribution/extensions
%__mkdir -p %{buildroot}%{_libdir}/%{softname}/browser/defaults/preferences
# install -m 644 %{SOURCE9} %{buildroot}%{progdir}/browser/defaults/preferences/firefox.js
# Desktop file
# Icons
%post
# update mime and desktop database
%mime_database_post
%desktop_database_post
%icon_theme_cache_post
exit 0
%postun
# update mime and desktop database
%desktop_database_postun
%mime_database_postun
%icon_theme_cache_postun
exit 0
%files
%license %{up_srcdir}/LICENSE
# %doc add-docs-here
%{_libdir}/%{softname}/browser/chrome/icons/
%{_libdir}/%{softname}/browser/features/
%{_libdir}/%{softname}/defaults/pref/
%dir %{_libdir}/%{softname}/distribution
%dir %{_libdir}/%{softname}/distribution/extensions
%{_libdir}/%{softname}/distribution/policies.json
%{_libdir}/%{softname}/fonts/
%{_libdir}/%{softname}/gmp-clearkey/
%{_libdir}/%{softname}/*.so
%{_libdir}/%{softname}/pingsender
%{_libdir}/%{softname}/vaapitest
%changelog