3d0e11c
### Naming ###
6bb399e
# Set to true if it's going to be submitted as update
faa9693
%global release_build 1
8ca9e9c
3d0e11c
# Set new source-code build version
3d0e11c
# This tag indicates a new rebuild for Fedora
27357af
%global redhat_ver rh1
3d0e11c
d4d149b
# Exclude ARM for the following error:
d4d149b
#  terminate called after throwing an instance of 'std::bad_alloc'
d4d149b
#   what():  std::bad_alloc
d4d149b
#   error: could not compile `gkrust`
d4d149b
ExcludeArch: %{arm}
d4d149b
627198b
# Build is failing because of
627198b
# include/mozilla/FloatingPoint.h:212:31: error: inlining failed in call to ‘always_inline’ ‘bool mozilla::IsNegativeZero(T) [with T = double]’: indirect function call with a yet undetermined callee
02aad29
%if 0%{?fedora}
0f7991b
ExcludeArch: s390x
627198b
%endif
627198b
3d0e11c
####################
3d0e11c
3d0e11c
### Optimization ###
3d0e11c
# Builds for debugging
db252ab
%global debug_build   0
3d0e11c
3d0e11c
# Downgrade optimization
687dfc9
%global less_optbuild 0
3d0e11c
3d0e11c
# Use mozilla hardening option?
3d0e11c
%global hardened_build 1
3d0e11c
####################
6bb399e
42bafbe
# Build PGO+LTO on x86_64 and aarch64 only due to build issues
42bafbe
# on other arches.
42bafbe
%ifarch x86_64
10e8270
%if 0%{?release_build}
096d883
%global build_with_pgo 0
096d883
%global pgo_wayland    0
42bafbe
%else
6e5b0b7
%global build_with_pgo 0
6e5b0b7
%endif
42bafbe
%endif
6e5b0b7
1ab65a6
%global launch_wayland_compositor 0
1ab65a6
%if 0%{?build_with_pgo}
1ab65a6
%global launch_wayland_compositor 1
1ab65a6
%endif
1ab65a6
6e5b0b7
# Disable LTO to work around rhbz#1883904
6e5b0b7
%define _lto_cflags %{nil}
6e5b0b7
####################
6e5b0b7
9fa6161
# Active/Deactive language files handling
33047ef
%global build_langpacks 1
78aec85
9fa6161
# Define installation directories
7743008
%global icecatappdir %{_libdir}/%{name}
7743008
%global icecat_ver   %{name}-%{version}
7743008
%global icecat_devel %{name}-devel-%{version}
sagitter a7fb410
9fa6161
# Define language files directory
7743008
%global langpackdir  %{icecatappdir}/langpacks
sagitter a7fb410
7743008
%global toolkit_gtk3  1
8aab9fe
78aec85
# Big endian platforms
78aec85
%ifarch ppc64 s390x
78aec85
# Javascript Intl API is not supported on big endian platforms right now:
78aec85
# https://bugzilla.mozilla.org/show_bug.cgi?id=1322212
7743008
%global big_endian    1
78aec85
%endif
78aec85
02aad29
%if 0%{?fedora}
4cbb214
%global system_nss  1
02aad29
%else
02aad29
%global system_nss  0
02aad29
%endif
6383430
%if %{?system_nss}
ebbe1bb
%global nspr_version 4.32
1063c33
%global nspr_build_version %{nspr_version}
02aad29
%global nss_version 3.88
1063c33
%global nss_build_version %{nss_version}
78aec85
%endif
78aec85
9fa6161
# Audio backends
cdd01b1
%bcond_without pulseaudio
a7c0ab2
%bcond_with alsa
cdd01b1
2e134ee
%global with_vpx 1
6383430
%if %{?with_vpx}
7aca989
%global libvpx_version 1.8.2
2e134ee
%endif
c355d1f
746e53f
%global disable_elfhack 1
dc2b379
664509a
# cbingen
7743008
%global use_bundled_cbindgen 1
664509a
664509a
# Use clang?
664509a
%global build_with_clang  0
664509a
c3c341e
# https://bugzilla.redhat.com/show_bug.cgi?id=1908792
87f2b73
# https://bugzilla.redhat.com/show_bug.cgi?id=2255254
c3c341e
%global __provides_exclude_from ^%{icecatappdir}
87f2b73
%global __requires_exclude ^(%%(find %{buildroot}%{icecatappdir} -name '*.so' | xargs -n1 basename | sort -u | paste -s -d '|' -))
c3c341e
3ea2473
Name:    icecat
90fab27
Epoch:   2
87f2b73
Version: 115.6.0
3ea2473
Release: %autorelease -e %{redhat_ver}
sagitter a7fb410
Summary: GNU version of Firefox browser
sagitter a7fb410
664509a
# Tri-licensing scheme for Gnuzilla/IceCat in parentheses, and licenses for the extensions included
faa9693
License: (MPL-1.1 or GPL-2.0-or-later or LGPL-2.1-or-later) and GPL-3.0-or-later and MIT and BSD and ISC and Apache-2.0 and MPL-2.0
7743008
URL:   http://www.gnu.org/software/gnuzilla/
c2e5d02
c2e5d02
## Source archive created by scripts based on Gnuzilla files.
c2e5d02
## Modified files are hosted in a dedicated fork repository:
4ea503f
## https://gitlab.com/anto.trande/icecat
28c6e64
Source0: %{name}-%{version}-%{redhat_ver}.tar.bz2
45ce475
sagitter a7fb410
Source2: %{name}.png
sagitter f6527ea
Source3: %{name}-mozconfig-common
sagitter a7fb410
664509a
# Language files downloaded by source7 script
80d4c17
%if 0%{?build_langpacks}
d2194b6
Source4:  %{name}-%{version}-langpacks.tar.gz
8aab9fe
%endif
sagitter a7fb410
664509a
# All license files
664509a
# Download from http://www.gnu.org/licenses
664509a
# Download from http://www.mozilla.org/MPL/1.1/index.txt
664509a
# Download from https://www.mozilla.org/MPL/2.0/index.txt
sagitter f6527ea
Source5: %{name}-COPYING-licensefiles.tar.gz
sagitter a7fb410
3e5f341
Source7: %{name}-lang_download.sh
c355d1f
45ce475
# Desktop files
daa7f89
Source9:  %{name}-wayland.desktop
c355d1f
Source10: %{name}.appdata.xml
daa7f89
Source12: %{name}-wayland.sh.in
c355d1f
Source13: %{name}.sh.in
45ce475
Source14: %{name}.desktop
daa7f89
Source15: %{name}-x11.sh.in
daa7f89
Source16: %{name}-x11.desktop
b367d8e
664509a
# cbingen
664509a
Source17: cbindgen-vendor.tar.xz
664509a
Source18: node-stdout-nonblocking-wrapper
664509a
1ab65a6
Source19: run-wayland-compositor
1ab65a6
c355d1f
# Build patches
aadd0f7
# Fixes installation of those addons which don't have ID on IceCat ("Cannot find id for addon" error).
9c9a59f
Patch1: %{name}-fix_addon_installation.patch
aeeb816
Patch2: %{name}-commasplit.patch
9c9a59f
Patch5: rhbz-1219542-s390-build.patch
855ee44
a939d1f
# With clang LLVM 16 rust-bindgen 0.56.0 is too old, combined
a939d1f
# https://github.com/rust-lang/rust-bindgen/pull/2319
a939d1f
# https://github.com/rust-lang/rust-bindgen/pull/2339
a939d1f
Patch7:  rust-bindgen-2319-2339.patch
a939d1f
a939d1f
# Needed with rust 1.70
a939d1f
# https://github.com/mozilla/mp4parse-rust/commit/8b5b652d38e007e736bb442ccd5aa5ed699db100
a939d1f
Patch8:  mp4parse-rust-8b5b652d38e007e736bb442ccd5aa5ed699db100.patch 
a939d1f
c2b9206
Patch40: build-aarch64-skia.patch
c2b9206
Patch41: build-disable-elfhack.patch
c2b9206
Patch44: build-arm-libopus.patch
ba3d3fd
Patch54: mozilla-1669639.patch
ba3d3fd
8aab9fe
# Fedora specific patches
0502e0f
Patch219: rhbz-1173156.patch
91d1df5
Patch220: firefox-nss-version.patch
eb79d9f
Patch221: firefox-nss-addon-hack.patch
6f9ab8e
Patch223: %{name}-glibc-dynstack.patch
5b01f78
Patch224: %{name}-GLIBCXX-fix-for-GCC-12.patch
c355d1f
c38e668
# ARM run-time patch
0502e0f
Patch226: rhbz-1354671.patch
78aec85
8aab9fe
# Upstream patches
5b58b66
Patch401: icecat-1742849.patch
91d1df5
Patch402: mozilla-1196777.patch
5a3ba38
Patch403: icecat-python3.11-open-U.patch
5a3ba38
Patch404: icecat-python3.11-regex-inline-flags.patch
91d1df5
Patch412: mozilla-1337988.patch
91d1df5
Patch422: mozilla-1580174-webrtc-popup.patch
6d50ea1
dd3dc84
# Fix crash on ppc64le (mozilla#1512162)
dd3dc84
Patch423: mozilla-1512162.patch
223056b
42bafbe
# PGO/LTO patches
3dab25d
Patch600: %{name}-pgo.patch
3dab25d
Patch602: mozilla-1516803.patch
42bafbe
9c9a59f
BuildRequires: alsa-lib-devel
9c9a59f
BuildRequires: autoconf213
9c9a59f
BuildRequires: bzip2-devel
9c9a59f
BuildRequires: cairo-devel
9c9a59f
BuildRequires: cargo
664509a
%if !0%{?use_bundled_cbindgen}
9c9a59f
BuildRequires: cbindgen	
664509a
%endif
9c9a59f
BuildRequires: ccache
9c9a59f
BuildRequires: dbus-devel
9c9a59f
BuildRequires: dbus-glib-devel
b225abb
BuildRequires: dbus-x11
9c9a59f
BuildRequires: dconf
9c9a59f
BuildRequires: desktop-file-utils
9c9a59f
BuildRequires: dos2unix
9c9a59f
BuildRequires: gcc, gcc-c++
bb9fb2f
BuildRequires: make
9c9a59f
BuildRequires: freetype-devel
9c9a59f
BuildRequires: gdk-pixbuf2
9c9a59f
BuildRequires: glib2-devel
9c9a59f
BuildRequires: pkgconfig(gtk+-2.0)
664509a
%if 0%{?toolkit_gtk3}
9c9a59f
BuildRequires: pkgconfig(gtk+-3.0)
8aab9fe
%endif
9c9a59f
BuildRequires: gstreamer1-devel
9c9a59f
BuildRequires: gstreamer1-plugins-base-devel
9c9a59f
BuildRequires: hunspell-devel
9c9a59f
BuildRequires: ImageMagick, autotrace
9c9a59f
BuildRequires: intltool
9c9a59f
BuildRequires: libappstream-glib
eebaa1f
BuildRequires: libavcodec-free-devel
9c9a59f
BuildRequires: libevent-devel
9c9a59f
BuildRequires: libjpeg-turbo-devel
9c9a59f
BuildRequires: libjpeg-devel
9c9a59f
BuildRequires: libX11-devel
9c9a59f
BuildRequires: libXt-devel
9c9a59f
BuildRequires: libXrender-devel
9c9a59f
BuildRequires: libyuv-devel
9c9a59f
BuildRequires: libXinerama-devel
9c9a59f
BuildRequires: libffi-devel
9c9a59f
BuildRequires: libnotify-devel
9c9a59f
BuildRequires: libpng-devel
6383430
%if %{?with_vpx}
2e134ee
BuildRequires: libvpx-devel >= %{libvpx_version}
2bf20d4
%endif
9c9a59f
BuildRequires: libzip-devel
9c9a59f
BuildRequires: mesa-libGL-devel
9c9a59f
BuildRequires: nodejs
9c9a59f
BuildRequires: nasm >= 1.13
9c9a59f
BuildRequires: strace
91d1df5
6383430
%if %{?system_nss}
6383430
BuildRequires: pkgconfig(nspr) >= %{nspr_version}
9c9a59f
BuildRequires: pkgconfig(nss) >= %{nss_version}
9c9a59f
BuildRequires: nss-static >= %{nss_version}
78aec85
%endif
c2e5d02
9c9a59f
BuildRequires: pango-devel
9c9a59f
BuildRequires: pipewire-devel
27357af
BuildRequires: python3-devel
27357af
BuildRequires: python3-setuptools
a02439e
BuildRequires: python3.11-devel
a3622ec
BuildRequires: perl-interpreter
9c9a59f
BuildRequires: pkgconfig(xrender)
9c9a59f
BuildRequires: pkgconfig(libstartup-notification-1.0)
9c9a59f
BuildRequires: pkgconfig(dri)
9c9a59f
BuildRequires: pkgconfig(libcurl)
cdd01b1
%if %{with pulseaudio}
9c9a59f
BuildRequires: pulseaudio-libs-devel
cdd01b1
%endif
9c9a59f
BuildRequires: yasm
9c9a59f
BuildRequires: llvm
9c9a59f
BuildRequires: llvm-devel
9c9a59f
BuildRequires: clang
9c9a59f
BuildRequires: clang-libs
9c9a59f
BuildRequires: clang-devel
664509a
%if 0%{?build_with_clang}
9c9a59f
BuildRequires: lld
664509a
%endif
9c9a59f
BuildRequires: rust
1f611d5
%if 0%{?pgo_wayland}
1f611d5
BuildRequires:  mutter
1f611d5
BuildRequires:  gsettings-desktop-schemas
1f611d5
BuildRequires:  gnome-settings-daemon
1f611d5
BuildRequires:  mesa-dri-drivers
f7f92ca
BuildRequires:  xorg-x11-server-Xwayland
1f611d5
%endif
1f611d5
%if 0%{?build_with_pgo}
1f611d5
BuildRequires:  xorg-x11-server-Xvfb
1f611d5
%endif
78aec85
6f918a1
%if 0%{?big_endian}
6f918a1
BuildRequires: icu
6f918a1
%endif
6f918a1
9c9a59f
Requires: dconf
9c9a59f
Requires: mozilla-filesystem
9c9a59f
Requires: p11-kit-trust
c2e5d02
6383430
%if %{?system_nss}
6383430
Requires: nspr >= %{nspr_build_version}
9c9a59f
Requires: nss >= %{nss_build_version}
78aec85
%endif
91d1df5
02aad29
%if 0%{?fedora}
02aad29
BuildRequires: fedora-bookmarks
9c9a59f
Requires: fedora-bookmarks
02aad29
%endif
sagitter f6527ea
02aad29
Suggests: mozilla-ublock-origin
9c9a59f
Provides: webclient
sagitter 7c80051
sagitter a7fb410
%description
b6c017a
GNU IceCat is the GNU version of the Firefox ESR browser.
32e1fcc
Extensions included to this version of IceCat:
13ed580
319b482
 * LibreJS
8841e52
   GNU LibreJS aims to address the JavaScript problem described in the article
06564d1
   "The JavaScript Trap" of Richard Stallman.
319b482
d2194b6
 * HTTPS Everywhere
5ca740a
   HTTPS Everywhere is an extension that encrypts your communications with
06564d1
   many major websites, making your browsing more secure.
4612a38
06564d1
 * A set of companion extensions for LibreJS by Nathan Nichols
06564d1
   are pre-installed, and provide workarounds to use some services at USPS,
efa8e56
   RSF.org, SumOfUs.org, pay.gov, McDonalds, goteo.org and Google Docs
06564d1
   without using nonfree JavaScript.
06564d1
06564d1
 * A series of configuration changes and tweaks were applied to ensure that
06564d1
   IceCat does not initiate network connections that the user has not explicitly
06564d1
   requested. This implies not downloading feeds, updates, blacklists or any
06564d1
   other similar data needed during startup.
319b482
45ce475
%package x11
45ce475
Summary: GNU IceCat X11 launcher
19166c6
Requires: %{name}%{?_isa}
45ce475
%description x11
45ce475
The %{name}-x11 package contains launcher and desktop file
5ca740a
to run GNU IceCat native on X11.
0252c7f
45ce475
%package wayland
45ce475
Summary: GNU IceCat Wayland launcher
19166c6
Requires: %{name}%{?_isa}
f72e804
Obsoletes: %{name} < 0:78.6.1-1
45ce475
%description wayland
45ce475
The icecat-wayland package contains launcher and desktop file
5ca740a
to run GNU IceCat native on Wayland.
45ce475
sagitter a7fb410
%prep
664509a
%autosetup -N -n %{name}-%{version}
sagitter a7fb410
8ac4fe3
# Copy license files
c355d1f
tar -xf %{SOURCE5}
sagitter dda22cb
a939d1f
%patch -P 1 -p 1 -b .fix_addon_installation
a939d1f
%patch -P 2 -p 1 -b .commasplit
8ef0a9f
%ifarch s390
a939d1f
%patch -P 5 -p 1 -b .rhbz-1219542-s390
a939d1f
%endif
a939d1f
746e53f
%if 0%{?disable_elfhack}
a939d1f
%patch -P 41 -p 1 -b .disable-elfhack
746e53f
%endif
c355d1f
78aec85
# Fedora patches
a939d1f
%patch -P 219 -p 1 -b .rhbz-1173156
02aad29
%if 0%{?fedora}
a939d1f
%patch -P 221 -p 1 -b .firefox-nss-addon-hack
02aad29
%endif
a939d1f
%patch -P 224 -p 1 -b .glibcxx
c355d1f
746e53f
# ARM run-time patch
78aec85
%ifarch aarch64
a939d1f
%patch -P 40 -p 1 -b .aarch64-skia
a939d1f
%patch -P 226 -p 1 -b .1354671
bdc44c0
%endif
bdc44c0
c355d1f
%ifarch %{arm}
a939d1f
%patch -P 44  -p 1 -b .build-arm-libopus
c355d1f
%endif
8a88598
a939d1f
%patch -P 402 -p 1 -b .1196777
0163a46
%ifarch %{power64}
a939d1f
%patch -P 423 -p 1 -b .1512162
0163a46
%endif
91d1df5
a939d1f
%patch -P 54 -p 1 -b .1669639
ba3d3fd
42bafbe
# PGO patches
10e8270
%if 0%{?build_with_pgo}
42bafbe
%if !%{build_with_clang}
a939d1f
%patch -P 600 -p 1 -b .pgo
a939d1f
%patch -P 602 -p 1 -b .1516803
42bafbe
%endif
42bafbe
%endif
42bafbe
746e53f
# Remove default configuration and copy the customized one
45ce475
rm -f .mozconfig
78aec85
cp -p %{SOURCE3} .mozconfig
sagitter a7fb410
1badc0d
# Disable signature checking for extensions that are bundled with IceCat.
1badc0d
# Add these options to allow loading unsigned add-ons in app and system scopes.
1badc0d
echo "ac_add_options --with-unsigned-addon-scopes=app,system" >> .mozconfig
1badc0d
echo "ac_add_options --allow-addon-sideload" >> .mozconfig
622a5d2
c355d1f
echo "ac_add_options --enable-default-toolkit=cairo-gtk3-wayland" >> .mozconfig
78aec85
echo "ac_add_options --enable-official-branding" >> .mozconfig
78aec85
echo "ac_add_options --disable-webrtc" >> .mozconfig
sagitter a7fb410
8e06f28
# Hide DRM Content option
0af939c
# This option does not work on other architectures
0af939c
%ifarch x86_64 %{ix86}
8e06f28
echo "ac_add_options --disable-eme" >> .mozconfig
0af939c
%endif
8e06f28
78aec85
%if %{with pulseaudio}
78aec85
echo "ac_add_options --enable-pulseaudio" >> .mozconfig
sagitter 7c80051
%endif
sagitter 7c80051
9fa6161
%if %{with alsa}
9fa6161
echo "ac_add_options --enable-alsa" >> .mozconfig
9fa6161
%endif
9fa6161
6b171b7
%ifarch s390x
78aec85
echo "ac_add_options --disable-jemalloc" >> .mozconfig
8aab9fe
%endif
8aab9fe
6383430
%if %{?system_nss}
017c32f
echo "ac_add_options --with-system-nspr" >> .mozconfig
6e889e0
echo "ac_add_options --with-system-nss" >> .mozconfig
58e4ba0
echo 'ac_add_options BINDGEN_CFLAGS="%(pkg-config nspr pixman-1 --cflags)"' >> .mozconfig
017c32f
%else
ab19fa9
echo "ac_add_options --without-system-nspr" >> .mozconfig
6e889e0
echo "ac_add_options --without-system-nss" >> .mozconfig
78aec85
%endif
eb28d6f
# Workaround for mozbz#1341234
eb28d6f
echo "ac_add_options --allow-addon-sideload" >> .mozconfig
78aec85
echo "ac_add_options --enable-system-pixman" >> .mozconfig
e2a7e8d
echo "ac_add_options --with-system-libevent" >> .mozconfig
2bf20d4
%if %{?with_vpx}
78aec85
echo "ac_add_options --with-system-libvpx" >> .mozconfig
2bf20d4
%else
2bf20d4
echo "ac_add_options --without-system-libvpx" >> .mozconfig
2bf20d4
%endif
213be47
78aec85
echo "ac_add_options --with-system-jpeg" >> .mozconfig
eebaa1f
echo "ac_add_options --enable-ffmpeg" >> .mozconfig
8aab9fe
e30eb69
# This option works on these architectures only
91d1df5
%ifarch %{arm}
e30eb69
echo "ac_add_options --disable-elf-hack" >> .mozconfig
3f82021
echo "ac_add_options --disable-av1" >> .mozconfig
b82e457
echo 'export NEON_FLAGS=-mfpu=vfpv3-d16' >> .mozconfig
e30eb69
%endif
652a78e
%ifnarch %{arm}
652a78e
echo "ac_add_options --enable-av1" >> .mozconfig
652a78e
%endif
e30eb69
c355d1f
%if 0%{?debug_build}
78aec85
echo "ac_add_options --enable-debug" >> .mozconfig
78aec85
echo "ac_add_options --disable-optimize" >> .mozconfig
9127037
echo "ac_add_options --enable-rust-debug" >> .mozconfig
4c9800a
%else
95a1397
%global optimize_flags "none"
3d0e11c
%ifarch %{arm} s390x
78aec85
# ARMv7 need that (rhbz#1426850)
3d0e11c
%define optimize_flags " -fno-schedule-insns"
fed4174
%endif
2bf20d4
%if %{?optimize_flags} != "none"
78aec85
echo 'ac_add_options --enable-optimize=%{?optimize_flags}' >> .mozconfig
78aec85
%else
78aec85
echo 'ac_add_options --enable-optimize' >> .mozconfig
2d55698
%endif
78aec85
echo "ac_add_options --disable-debug" >> .mozconfig
43af98f
%endif
78aec85
echo "ac_add_options --disable-strip" >> .mozconfig
78aec85
echo "ac_add_options --disable-install-strip" >> .mozconfig
78aec85
echo "ac_add_options --disable-tests" >> .mozconfig
6383430
echo "ac_add_options --disable-crashreporter" >> .mozconfig
2608d61
2608d61
# Localization
2608d61
%if 0%{?build_langpacks}
2608d61
echo "ac_add_options --with-l10n-base=$PWD/l10n" >> .mozconfig
2608d61
%endif
8aab9fe
90fab27
# Clang
90fab27
echo "ac_add_options --with-libclang-path=%{_libdir}" >> .mozconfig
90fab27
91d1df5
%ifarch s390x
0a3cfe9
echo "ac_add_options --disable-jit" >> .mozconfig
664509a
%endif
664509a
6e5b0b7
%if 0%{?build_with_pgo}
6e5b0b7
echo "ac_add_options MOZ_PGO=1" >> .mozconfig
1cfb4b8
echo "ac_add_options --enable-lto" >> .mozconfig
6e5b0b7
%else
3d0e11c
echo "ac_add_options --disable-lto" >> .mozconfig
6e5b0b7
%endif
3d0e11c
664509a
echo 'export NODEJS="%{_buildrootdir}/bin/node-stdout-nonblocking-wrapper"' >> .mozconfig
664509a
c355d1f
# Remove executable bit to make brp-mangle-shebangs happy.
c355d1f
chmod -x third_party/rust/itertools/src/lib.rs
91d1df5
chmod a-x third_party/rust/ash/src/extensions/ext/*.rs
91d1df5
chmod a-x third_party/rust/ash/src/extensions/khr/*.rs
bb9fb2f
chmod a-x third_party/rust/ash/src/extensions/nv/*.rs
c355d1f
544344b
# Remove unrecognized files
8ca9e9c
find extensions/gnu -name cose.manifest -delete
544344b
c355d1f
#---------------------------------------------------------------------
c355d1f
78aec85
%build
664509a
# cbindgen
664509a
%if 0%{?use_bundled_cbindgen}
664509a
664509a
mkdir -p my_rust_vendor
664509a
cd my_rust_vendor
664509a
%{__tar} xf %{SOURCE17}
664509a
cd -
664509a
mkdir -p .cargo
664509a
cat > .cargo/config <
664509a
[source.crates-io]
664509a
replace-with = "vendored-sources"
664509a
664509a
[source.vendored-sources]
664509a
directory = "`pwd`/my_rust_vendor"
664509a
EOL
664509a
664509a
env CARGO_HOME=.cargo cargo install cbindgen
664509a
export PATH=`pwd`/.cargo/bin:$PATH
8aab9fe
%endif
8aab9fe
664509a
mkdir %{_buildrootdir}/bin || :
664509a
cp %{SOURCE18} %{_buildrootdir}/bin || :
664509a
78aec85
# Update the various config.guess to upstream release for aarch64 support
69d8fd7
find ./ -path ./third_party/rust -prune -o -name config.guess -exec cp /usr/lib/rpm/config.guess {} ';'
78aec85
78aec85
MOZ_OPT_FLAGS=$(echo "%{optflags}" | %{__sed} -e 's/-Wall//')
da37eaa
%if %{?less_optbuild}
3d0e11c
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-O2/-O1/')
3d0e11c
%endif
da37eaa
%if %{?debug_build}
da37eaa
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-O2/-O0/')
da37eaa
%endif
3d0e11c
78aec85
#rhbz#1037063
78aec85
# -Werror=format-security causes build failures when -Wno-format is explicitly given
78aec85
# for some sources
78aec85
# Explicitly force the hardening flags for Firefox so it passes the checksec test;
78aec85
# See also https://fedoraproject.org/wiki/Changes/Harden_All_Packages
80d4c17
# Workaround for mozbz#1531309
80d4c17
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-Werror=format-security//')
622a5d2
78aec85
# Use hardened build?
91d1df5
%if %{?hardened_build}
78aec85
MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now"
91d1df5
%endif
78aec85
c51f3a7
%ifarch s390x
c51f3a7
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-g/-g1/')
c51f3a7
# If MOZ_DEBUG_FLAGS is empty, firefox's build will default it to "-g" which
c51f3a7
# overrides the -g1 from line above and breaks building on s390
c51f3a7
# (OOM when linking, rhbz#1238225)
c51f3a7
export MOZ_DEBUG_FLAGS=" "
c51f3a7
%endif
c51f3a7
c51f3a7
%ifarch %{arm} %{ix86}
c51f3a7
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-g/-g0/')
78aec85
# If MOZ_DEBUG_FLAGS is empty, firefox's build will default it to "-g" which
78aec85
# overrides the -g1 from line above and breaks building on s390
78aec85
# (OOM when linking, rhbz#1238225)
78aec85
export MOZ_DEBUG_FLAGS=" "
78aec85
%endif
6aa999d
6aa999d
# We don't wantfirefox to use CK_GCM_PARAMS_V3 in nss
6aa999d
MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -DNSS_PKCS11_3_0_STRICT"
6aa999d
664509a
%if !0%{?build_with_clang}
db3ceae
%ifarch s390x %{power64} aarch64 %{ix86}
f865a4c
MOZ_LINK_FLAGS="-Wl,--no-keep-memory -Wl,--reduce-memory-overheads -Wl,--print-memory-usage"
028c4a3
%endif
2a63573
%ifarch %{arm}
db3ceae
MOZ_LINK_FLAGS="-Wl,--no-keep-memory"
7966018
echo "ac_add_options --enable-linker=gold" >> .mozconfig
2a63573
%endif
664509a
%endif
0f7991b
%ifarch %{arm} %{ix86} s390x
c355d1f
export RUSTFLAGS="-Cdebuginfo=0"
279f18e
%endif
f45d231
f45d231
%ifarch %{arm}
f45d231
# disable hard-coded LTO due to RAM constraints
f45d231
sed -i '/cargo_rustc_flags += -Clto/d' config/makefiles/rust.mk
f45d231
sed -i '/RUSTFLAGS += -Cembed-bitcode=yes/d' config/makefiles/rust.mk
f45d231
sed -i 's/codegen-units=1/codegen-units=16/' config/makefiles/rust.mk
f45d231
f45d231
# make sure "-g0" is the last flag so there's no debug info
f45d231
MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -g0"
f45d231
%endif
f45d231
78aec85
export CFLAGS=$MOZ_OPT_FLAGS
3d0e11c
export CXXFLAGS="$MOZ_OPT_FLAGS -fpermissive"
78aec85
export LDFLAGS=$MOZ_LINK_FLAGS
78aec85
78aec85
export PREFIX='%{_prefix}'
78aec85
export LIBDIR='%{_libdir}'
78aec85
export PKG_CONFIG='%{_bindir}/pkg-config'
f2082f9
export PYTHON='%{__python3}'
sagitter abfa85b
664509a
%if 0%{?build_with_clang}
664509a
export LLVM_PROFDATA="llvm-profdata"
664509a
export AR="llvm-ar"
664509a
export NM="llvm-nm"
664509a
export RANLIB="llvm-ranlib"
664509a
echo "ac_add_options --enable-linker=lld" >> .mozconfig
664509a
%else
664509a
export CC=gcc
664509a
export CXX=g++
664509a
export AR="gcc-ar"
664509a
export NM="gcc-nm"
664509a
export RANLIB="gcc-ranlib"
664509a
%endif
6e5b0b7
export CCACHE_DISABLE=1
664509a
da37eaa
%if %{?less_optbuild}
3d0e11c
MOZ_SMP_FLAGS=-j1
3d0e11c
%else
78aec85
MOZ_SMP_FLAGS=-j1
91d1df5
# On x86_64 architectures, Mozilla can build up to 4 jobs at once in parallel,
2963315
# however builds tend to fail on other arches when building in parallel.
e2a7e8d
%ifarch %{ix86} s390x %{arm} aarch64
91d1df5
[ -z "$RPM_BUILD_NCPUS" ] && \
91d1df5
     RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
91d1df5
[ "$RPM_BUILD_NCPUS" -ge 2 ] && MOZ_SMP_FLAGS=-j2
91d1df5
%endif
e2a7e8d
%ifarch x86_64 ppc ppc64 ppc64le
2963315
[ -z "$RPM_BUILD_NCPUS" ] && \
78aec85
     RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
2963315
[ "$RPM_BUILD_NCPUS" -ge 2 ] && MOZ_SMP_FLAGS=-j2
2963315
[ "$RPM_BUILD_NCPUS" -ge 4 ] && MOZ_SMP_FLAGS=-j4
2963315
[ "$RPM_BUILD_NCPUS" -ge 8 ] && MOZ_SMP_FLAGS=-j8
e2a7e8d
[ "$RPM_BUILD_NCPUS" -ge 16 ] && MOZ_SMP_FLAGS=-j16
e2a7e8d
[ "$RPM_BUILD_NCPUS" -ge 24 ] && MOZ_SMP_FLAGS=-j24
e2a7e8d
[ "$RPM_BUILD_NCPUS" -ge 32 ] && MOZ_SMP_FLAGS=-j32
e2a7e8d
[ "$RPM_BUILD_NCPUS" -ge 64 ] && MOZ_SMP_FLAGS=-j64
c2144d4
%endif
3d0e11c
%endif
710f31e
3d0e11c
echo "mk_add_options MOZ_MAKE_FLAGS=\"$MOZ_SMP_FLAGS\"" >> .mozconfig
3d0e11c
echo "mk_add_options MOZ_SERVICES_SYNC=1" >> .mozconfig
91d1df5
echo "export STRIP=/bin/true" >> .mozconfig
1f611d5
b225abb
%if 0%{?launch_wayland_compositor}
1ab65a6
cp -p %{SOURCE19} .
1ab65a6
. ./run-wayland-compositor	
1ab65a6
%endif
1ab65a6
6d80f18
%if %{?debug_build}
6d80f18
export CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true
6d80f18
%endif
6d80f18
a02439e
	
a02439e
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
a02439e
#Use python 3.11 for mach
a02439e
sed -i -e 's|#!/usr/bin/env python3|#!/usr/bin/env python3.11|' mach
3a6cd7a
%if 0%{?build_with_pgo}
3a6cd7a
%if 0%{?pgo_wayland}
1ab65a6
env | grep "WAYLAND"
e2a7e8d
MOZ_ENABLE_WAYLAND=1 ./mach build -v 2>&1 | cat - && exit 1
1f611d5
%else
e2a7e8d
xvfb-run ./mach build  2>&1 | cat - || exit 1
1f611d5
%endif
1f611d5
%else
e2a7e8d
./mach build -v 2>&1 | cat - || exit 1
1f611d5
%endif
sagitter a7fb410
sagitter 7c80051
%install
78aec85
# set up our default bookmarks
02aad29
%if 0%{?fedora}
02aad29
%global default_bookmarks_file %{_datadir}/bookmarks/default-bookmarks.html
c355d1f
cp -p %{default_bookmarks_file} objdir/dist/bin/browser/chrome/en-US/locale/browser/bookmarks.html
02aad29
%endif
78aec85
c355d1f
%make_install -C objdir
sagitter a7fb410
sagitter 7c80051
##Resize IceCat icon
sagitter a7fb410
for i in 16 22 24 32 36 48 64 72 96 128 256 ; do
2cb5042
  mkdir -p %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps
2cb5042
  convert -geometry ${i} %{SOURCE2} %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/%{name}.png
sagitter a7fb410
done
sagitter a7fb410
sagitter 7c80051
##desktop file installation
2cb5042
mkdir -p %{buildroot}%{_datadir}/applications
2cb5042
desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE14}
45ce475
2cb5042
rm -rf %{buildroot}%{_bindir}/%{name}
daa8b02
%{__sed} -e 's,/__PREFIX__,%{_prefix},g' %{SOURCE13} > %{buildroot}%{_bindir}/%{name}
45ce475
chmod 755 %{buildroot}%{_bindir}/%{name}
45ce475
d628ecf
%{__sed} -e 's,/__PREFIX__,%{_prefix},g' %{SOURCE15} > %{buildroot}%{_bindir}/%{name}-x11
45ce475
chmod 755 %{buildroot}%{_bindir}/%{name}-x11
d628ecf
desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE16}
0252c7f
d628ecf
%{__sed} -e 's,/__PREFIX__,%{_prefix},g' %{SOURCE12} > %{buildroot}%{_bindir}/%{name}-wayland
45ce475
chmod 755 %{buildroot}%{_bindir}/%{name}-wayland
d628ecf
desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE9}
0252c7f
45ce475
#
sagitter a7fb410
fd9745a
# Install man page
fd9745a
#mkdir -p %%{buildroot}%%{_mandir}/man1
fd9745a
#install -p -m 644 %%{name}.1 %%{buildroot}%%{_mandir}/man1/
sagitter a7fb410
84b37b6
##Extract langpacks, make any mods needed, repack the langpack, and install it.
2bf20d4
%if 0%{?build_langpacks}
sagitter 7c80051
echo > %{name}.lang
2cb5042
mkdir -p %{buildroot}%{langpackdir}
sagitter f6527ea
tar xf %{SOURCE4}
dab63ff
 for langpack in `ls langpacks/*.xpi`; do
sagitter a7fb410
  language=`basename $langpack .xpi`
a0958e3
  extensionID=langpack-$language@icecat.mozilla.org
sagitter a7fb410
  mkdir -p $extensionID
sagitter a7fb410
  unzip -qq $langpack -d $extensionID
sagitter a7fb410
  find $extensionID -type f | xargs chmod 644
sagitter a7fb410
sagitter a7fb410
  cd $extensionID
sagitter a7fb410
  zip -qq -r9mX ../${extensionID}.xpi *
sagitter a7fb410
  cd -
sagitter a7fb410
2cb5042
  install -p -m 644 ${extensionID}.xpi %{buildroot}%{langpackdir}
sagitter a7fb410
  language=`echo $language | sed -e 's/-/_/g'`
sagitter a7fb410
  echo "%%lang($language) %{langpackdir}/${extensionID}.xpi" >> %{name}.lang
a0958e3
 done
sagitter a7fb410
rm -rf %{name}-langpacks
sagitter a7fb410
84b37b6
##Install langpack workaround (see #707100, #821169)
sagitter a7fb410
function create_default_langpack() {
sagitter a7fb410
language_long=$1
sagitter a7fb410
language_short=$2
2cb5042
cd %{buildroot}%{langpackdir}
a0958e3
ln -s langpack-$language_long@icecat.mozilla.org.xpi langpack-$language_short@icecat.mozilla.org.xpi
sagitter a7fb410
cd -
a0958e3
echo "%%lang($language_short) %{langpackdir}/langpack-$language_short@icecat.mozilla.org.xpi" >> %{name}.lang
sagitter a7fb410
}
d628ecf
d628ecf
# Table of fallbacks for each language
aadd0f7
#create_default_langpack "bn-IN" "bn"
d628ecf
create_default_langpack "es-AR" "es"
d628ecf
create_default_langpack "fy-NL" "fy"
d628ecf
create_default_langpack "ga-IE" "ga"
d628ecf
create_default_langpack "gu-IN" "gu"
d628ecf
create_default_langpack "hi-IN" "hi"
d628ecf
create_default_langpack "hy-AM" "hy"
d628ecf
create_default_langpack "nb-NO" "nb"
d628ecf
create_default_langpack "nn-NO" "nn"
d628ecf
create_default_langpack "pa-IN" "pa"
d628ecf
create_default_langpack "pt-PT" "pt"
d628ecf
create_default_langpack "sv-SE" "sv"
d628ecf
create_default_langpack "zh-TW" "zh"
78aec85
%endif
78aec85
78aec85
# Remove copied libraries to speed up build
c355d1f
rm -f ${RPM_BUILD_ROOT}%{_libdir}/%{icecat_devel}/sdk/lib/libmozjs.so
c355d1f
rm -f ${RPM_BUILD_ROOT}%{_libdir}/%{icecat_devel}/sdk/lib/libmozalloc.so
c355d1f
rm -f ${RPM_BUILD_ROOT}%{_libdir}/%{icecat_devel}/sdk/lib/libxul.so
78aec85
c2e5d02
# Remove useless backup files
c2e5d02
rm -rf ${RPM_BUILD_ROOT}%{icecatappdir}/browser/extensions/SimpleSumOfUs@0xbeef.coffee
c2e5d02
78aec85
# Link identical binaries
78aec85
ln -sf %{icecatappdir}/%{name}-bin ${RPM_BUILD_ROOT}%{icecatappdir}/%{name}
78aec85
78aec85
# Use the system hunspell dictionaries
78aec85
rm -rf ${RPM_BUILD_ROOT}%{icecatappdir}/dictionaries
c92a9b4
ln -s %{_datadir}/hunspell ${RPM_BUILD_ROOT}%{icecatappdir}/dictionaries
sagitter a7fb410
c355d1f
# Copy over run-icecat.sh
c355d1f
cp -p build/unix/run-%{name}.sh %{buildroot}%{icecatappdir}/
c355d1f
0a2348a
# Remove unused directories
2cb5042
rm -rf %{buildroot}%{_libdir}/%{icecat_devel}
2cb5042
rm -rf %{buildroot}%{_datadir}/idl/%{icecat_ver}
2cb5042
rm -rf %{buildroot}%{_includedir}/%{icecat_ver}
2cb5042
rm -rf %{buildroot}%{icecatappdir}/removed-files
sagitter a7fb410
7b3f829
# Remove gtk2 support as flash plugin is no longer supported
7b3f829
rm -rf %{buildroot}%{icecatappdir}/gtk2
7b3f829
2cb5042
mkdir -p %{buildroot}%{_metainfodir}
2cb5042
install -pm 644 %{SOURCE10} %{buildroot}%{_metainfodir}/
a0958e3
78aec85
# Moves defaults/preferences to browser/defaults/preferences
78aec85
%pretrans -p <lua>
78aec85
require 'posix'
78aec85
require 'os'
78aec85
if (posix.stat("%{icecatappdir}/browser/defaults/preferences", "type") == "link") then
78aec85
  posix.unlink("%{icecatappdir}/browser/defaults/preferences")
78aec85
  posix.mkdir("%{icecatappdir}/browser/defaults/preferences")
78aec85
  if (posix.stat("%{icecatappdir}/defaults/preferences", "type") == "directory") then
78aec85
    for i,filename in pairs(posix.dir("%{icecatappdir}/defaults/preferences")) do
78aec85
      os.rename("%{icecatappdir}/defaults/preferences/"..filename, "%{icecatappdir}/browser/defaults/preferences/"..filename)
78aec85
    end
78aec85
    f = io.open("%{icecatappdir}/defaults/preferences/README","w")
78aec85
    if f then
78aec85
      f:write("Content of this directory has been moved to %{icecatappdir}/browser/defaults/preferences.")
78aec85
      f:close()
78aec85
    end
78aec85
  end
78aec85
end
78aec85
sagitter a7fb410
%check
2cb5042
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/*.appdata.xml
88eae59
desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop
sagitter a7fb410
2bf20d4
%if 0%{?build_langpacks}
sagitter a7fb410
%files -f %{name}.lang
8aab9fe
%else
8aab9fe
%files
8aab9fe
%endif
e53c76e
%doc README.* AUTHORS
f7f92ca
%license LICENSE COPYING-*
78aec85
%{_bindir}/%{name}
45ce475
%{_datadir}/applications/%{name}.desktop
78aec85
%{_datadir}/icons/hicolor/*x*/apps/%{name}*.png
c355d1f
%{_metainfodir}/*.appdata.xml
c355d1f
%dir %{icecatappdir}
775cb0e
%{icecatappdir}/glxtest
775cb0e
%{icecatappdir}/vaapitest
84b37b6
%{icecatappdir}/browser/
84b37b6
%{icecatappdir}/defaults/
78aec85
%{icecatappdir}/dictionaries
84b37b6
%{icecatappdir}/icecat*
14ef8c0
%{icecatappdir}/fonts/
84b37b6
%{icecatappdir}/*.so
84b37b6
%{icecatappdir}/*.ini
84b37b6
%{icecatappdir}/omni.ja
84b37b6
%{icecatappdir}/run-icecat.sh
a50c628
%{icecatappdir}/dependentlibs.list
a50c628
%{icecatappdir}/plugin-container
c355d1f
%{icecatappdir}/pingsender
8aab9fe
%{icecatappdir}/gmp-clearkey/
2bf20d4
%if 0%{?build_langpacks}
84b37b6
%dir %{langpackdir}
84b37b6
%endif
sagitter a7fb410
45ce475
%files x11
45ce475
%{_bindir}/%{name}-x11
45ce475
%{_datadir}/applications/%{name}-x11.desktop
0252c7f
45ce475
%files wayland
45ce475
%{_bindir}/%{name}-wayland
45ce475
%{_datadir}/applications/%{name}-wayland.desktop
45ce475
sagitter a7fb410
%changelog
f3f3265
%autochangelog