# Run Mozilla test suite as a part of compile rpm section. Turn off when
# building locally and don't want to spend 24 hours waiting for results.
%global run_firefox_tests 0

%ifarch loongarch64
 %global toolchain clang
 %global _general_options -O2 %{?_lto_cflags} -g -grecord-gcc-switches -pipe -fstack-protector-strong
%endif

# Produce debug (non-optimized) package build. Suitable for debugging only
# as the build is *very* slow.
%global debug_build       0

%global launch_wayland_compositor 0
%if 0%{?run_firefox_tests}
  %global test_on_wayland           1
  %global launch_wayland_compositor 1
  %global build_tests               1
%endif

%global system_gbm        1
%global system_pipewire   0
%global system_drm        0
%global use_pipewire_camera 0
%global use_gcc_ts        0
%global use_bundled_cbindgen  0

# TODO: Revert this after SM2 & SM3 issue is fixed
%global system_nss        1
%global llvm              llvm-toolset-21
%global llvm_version      21.0.0
%global rust_version      1.82
%global wayland_backend_default 0

%global system_av1        0
%global system_icu        1
%global system_libvpx     1
%global system_webp       1

%if %{?system_nss}
%global nspr_version      4.32
%global nss_version       3.112
%endif

%global mozappdir     %{_libdir}/firefox
%global langpackdir   %{mozappdir}/browser/extensions

%define bundled_install_path %{mozappdir}/bundled

%bcond_without langpacks

# Exclude private libraries from autogenerated provides and requires
%global __provides_exclude_from ^%{mozappdir}
%global __requires_exclude ^(%%(find %{buildroot}%{mozappdir} -name '*.so' | xargs -n1 basename | sort -u | paste -s -d '|' -))

Summary:        Mozilla Firefox Web browser
Name:           firefox
Version:        140.14.0
Release:        2
URL:            https://www.mozilla.org/firefox/
License:        MPL-1.1 or GPL-2.0-or-later or LGPL-2.0-or-later
Source0:        https://ftp.mozilla.org/pub/firefox/releases/%{version}esr/source/firefox-%{version}esr.source.tar.xz
%if %{with langpacks}
# sh create-firefox-langpacks.sh %%{version}esr
Source1:        firefox-langpacks-%{version}esr.tar.xz
%endif
# bash gen_cbindgen-vendor.sh
Source2:        cbindgen-vendor.tar.xz
Source10:       firefox-mozconfig
Source12:       firefox-openeuler-default-prefs.js
Source20:       org.mozilla.firefox.desktop
Source21:       firefox.sh.in
Source23:       firefox.1
Source24:       mozilla-api-key
Source25:       firefox-symbolic.svg
Source26:       distribution.ini.in
Source27:       google-api-key
Source30:       firefox-x11.sh.in
Source31:       firefox-x11.desktop
Source32:       node-stdout-nonblocking-wrapper
Source33:       org.mozilla.firefox.appdata.xml.in
Source34:       org.mozilla.firefox-search-provider.ini
Source35:       google-loc-api-key
Source36:       testing.sh
Source37:       mochitest-python.tar.gz

# Build patches
Patch01:        build-disable-elfhack.patch
Patch02:        firefox-gcc-build.patch
Patch03:        build-big-endian-errors.patch
Patch08:        rhbz-2131158-webrtc-nss-fix.patch
Patch09:        build-ffvpx.patch
Patch11:        rhbz-71999-fips-youtube.patch
Patch12:        disable-glean-sdk,psutil,zstandard,orjson.patch
# Fix rust host triplet detection with rust >= 1.98 (vendor-specific targets)
Patch13:        fix-rust-host-triplet-vendor.patch

# -- Upstreamed patches --
Patch51:        mozilla-bmo1170092.patch
Patch52:        exceptionHandled-for-IO-error-processhandler.patch
Patch53:        D245908.clear-lang-bundles.diff
Patch54:        D249071.restoreWinState.diff
Patch55:        firefox-146.0.1-icu78.patch
Patch56:        Bug-2057577-DOM-Media-Add-FFmpeg-63-support.-r-alwu-.patch
# -- Submitted upstream, not merged --
Patch101:       mozilla-bmo1636168-fscreen.patch
Patch102:       mozilla-bmo1670333.patch
# Big endian fix
Patch103:       mozilla-bmo1504834-part1.patch
Patch104:       mozilla-bmo1504834-part3.patch
# Big endian fix
Patch105:       mozilla-bmo849632.patch
# Big endian fix
Patch106:       mozilla-bmo998749.patch
Patch107:       mozilla-bmo1716707-swizzle.patch
Patch108:       mozilla-bmo1716707-svg.patch
Patch110:       build-libaom.patch
Patch111:       av1-else-condition-add.patch

# Enable user addons
Patch151:       firefox-enable-addons.patch
Patch152:       rhbz-1173156.patch
Patch153:       firefox-nss-addon-hack.patch
# ARM run-time patch
Patch154:       rhbz-1354671.patch

# ---- Test patches ----
# Generate without context by
# GENDIFF_DIFF_ARGS=-U0 gendiff firefox-xxxx .firefox-tests-xpcshell
# GENDIFF_DIFF_ARGS=-U0 gendiff firefox-xxxx .firefox-tests-reftest

# ---- Security patches ----

# Arch specific patches
# ---- RISCV64 patches ----

# ---- LOONGARCH patches ----

# BUILD REQURES/REQUIRES
%if %{?system_nss}
BuildRequires:  pkgconfig(nspr) >= %{nspr_version}
BuildRequires:  pkgconfig(nss) >= %{nss_version}
BuildRequires:  nss-static >= %{nss_version}
%endif

BuildRequires:  bzip2-devel
BuildRequires:  dbus-glib-devel
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib
BuildRequires:  libjpeg-devel
BuildRequires:  libstdc++-devel
BuildRequires:  libstdc++-static
BuildRequires:  m4
BuildRequires:  make
BuildRequires:  nasm >= 1.13
BuildRequires:  nodejs >= 10.21
BuildRequires:  pciutils-libs
BuildRequires:  perl-interpreter
BuildRequires:  pkgconfig(alsa)
BuildRequires:  pkgconfig(dri)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(gtk+-3.0)
BuildRequires:  pkgconfig(krb5)
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(libffi)
BuildRequires:  pkgconfig(libnotify)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libpulse)
BuildRequires:  pkgconfig(libstartup-notification-1.0)
BuildRequires:  pkgconfig(pango)
BuildRequires:  pkgconfig(xrender)
BuildRequires:  pkgconfig(xt)
BuildRequires:  pkgconfig(xtst)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  zip

%if %{?system_drm}
BuildRequires:  libdrm-devel
%endif
%if %{?system_icu}
BuildRequires:  libicu-devel >= 76.1
%endif

%if %{?system_gbm}
BuildRequires:  mesa-libgbm-devel
%endif

%if %{?system_pipewire}
BuildRequires:  pipewire-devel
%endif

%if !0%{?use_bundled_cbindgen}
BuildRequires:  rust-cbindgen
%endif

BuildRequires:  cargo >= %{rust_version}
BuildRequires:  %{llvm}-clang-devel >= %{llvm_version}
BuildRequires:  %{llvm}-clang >= %{llvm_version}
BuildRequires:  %{llvm}-llvm-devel >= %{llvm_version}
BuildRequires:  %{llvm}-llvm >= %{llvm_version}
BuildRequires:  %{llvm}-lld >= %{llvm_version}
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
BuildRequires:  rustfmt >= %{rust_version}
BuildRequires:  rust >= %{rust_version}
BuildRequires:  wget gnupg2

%if 0%{?test_on_wayland}
BuildRequires:  dbus-x11
BuildRequires:  gnome-keyring
BuildRequires:  gnome-settings-daemon
BuildRequires:  gsettings-desktop-schemas
BuildRequires:  mesa-dri-drivers
BuildRequires:  mutter
BuildRequires:  xorg-x11-server-Xwayland
%endif

%if 0%{?run_firefox_tests}
BuildRequires:  abattis-cantarell-fonts
BuildRequires:  dbus-x11
BuildRequires:  dejavu-sans-fonts
BuildRequires:  dejavu-sans-mono-fonts
BuildRequires:  dejavu-serif-fonts
BuildRequires:  gnome-keyring
BuildRequires:  google-carlito-fonts
BuildRequires:  google-droid-sans-fonts
BuildRequires:  google-noto-cjk-fonts-common
BuildRequires:  google-noto-emoji-color-fonts
BuildRequires:  google-noto-fonts-common
BuildRequires:  google-noto-sans-cjk-ttc-fonts
BuildRequires:  google-noto-sans-fonts
BuildRequires:  google-noto-sans-gurmukhi-fonts
BuildRequires:  google-noto-sans-sinhala-vf-fonts
BuildRequires:  jomolhari-fonts
BuildRequires:  khmeros-base-fonts
BuildRequires:  liberation-fonts-common
BuildRequires:  liberation-mono-fonts
BuildRequires:  liberation-sans-fonts
BuildRequires:  liberation-serif-fonts
BuildRequires:  lohit-tamil-fonts
BuildRequires:  lohit-telugu-fonts
BuildRequires:  mesa-dri-drivers
BuildRequires:  nss-tools
BuildRequires:  paktype-naskh-basic-fonts
BuildRequires:  procps-ng
BuildRequires:  pt-sans-fonts
#BuildRequires:  smc-meera-fonts
BuildRequires:  stix-fonts
BuildRequires:  thai-scalable-fonts-common
BuildRequires:  thai-scalable-waree-fonts
BuildRequires:  xorg-x11-fonts-ISO8859-1-100dpi
BuildRequires:  xorg-x11-fonts-misc
BuildRequires:  xorg-x11-server-Xvfb
%endif

%if %{?system_av1}
BuildRequires:  pkgconfig(aom)
BuildRequires:  pkgconfig(dav1d)
%endif
%if %{?system_libvpx}
BuildRequires:  libvpx-devel
%endif
%if %{?system_webp}
BuildRequires:  pkgconfig(libwebp)
BuildRequires:  pkgconfig(libwebpdemux)
%endif

%if 0%{?use_gcc_ts}
BuildRequires:  gcc-toolset-14-gcc
BuildRequires:  gcc-toolset-14-c++
BuildRequires:  gcc-toolset-14-libgcc
BuildRequires:  gcc-toolset-14-binutils
%endif

Requires:       mozilla-filesystem
Requires:       p11-kit-trust
Requires:       pciutils-libs
Requires:       ffmpeg-libs%{?_isa}

%if %{?system_nss}
Requires:       nspr >= %{nspr_version}
Requires:       nss >= %{nss_version}
%endif

Obsoletes:      mozilla <= 37:1.7.13
Provides:       webclient

# Bundled libraries
#Provides: bundled(libjxl) it's used only on nightly builds
Provides: bundled(angle)
Provides: bundled(aom)
Provides: bundled(audioipc-2)
Provides: bundled(bergamot-translator)
Provides: bundled(brotli)
Provides: bundled(bsdiff)
Provides: bundled(cairo)
Provides: bundled(cfworker)
Provides: bundled(cld2)
Provides: bundled(cubeb)
Provides: bundled(d3.js)
Provides: bundled(double-conversion)
Provides: bundled(expat)
Provides: bundled(fastText)
Provides: bundled(fathom)
Provides: bundled(fdlibm)
Provides: bundled(ffvpx)
Provides: bundled(freetype2)
Provides: bundled(function2)
Provides: bundled(gemmology)
Provides: bundled(graphite2)
Provides: bundled(harfbuzz)
Provides: bundled(highway)
Provides: bundled(hunspell)
Provides: bundled(intgemm)
Provides: bundled(irregexp)
Provides: bundled(jpeg-xl)
Provides: bundled(kissfft)
Provides: bundled(libaom)
Provides: bundled(libcubeb)
Provides: bundled(libdrm)
Provides: bundled(libepoxy)
Provides: bundled(libgbm)
Provides: bundled(libjpeg)
Provides: bundled(libmar)
Provides: bundled(libmkv)
Provides: bundled(libnestegg)
Provides: bundled(libogg)
Provides: bundled(libopus)
Provides: bundled(libpng)
Provides: bundled(libprio)
Provides: bundled(libsoundtouch)
Provides: bundled(libspeex_resampler)
Provides: bundled(libsrtp)
Provides: bundled(libtheora)
Provides: bundled(libtremor)
Provides: bundled(libvorbis)
Provides: bundled(libwebrtc)
Provides: bundled(libyuv)
Provides: bundled(lit)
Provides: bundled(mp4parse-rust)
Provides: bundled(msgpack-c)
Provides: bundled(mtransport)
Provides: bundled(nestegg)
Provides: bundled(nICEr)
Provides: bundled(nimbus)
Provides: bundled(openmax_dl)
Provides: bundled(openmax_il)
Provides: bundled(ots)
Provides: bundled(pdf.js)
Provides: bundled(picosha2)
Provides: bundled(PKI)
Provides: bundled(qcms)
Provides: bundled(rlbox)
Provides: bundled(rlbox_sandboxing_api)
Provides: bundled(rlbox_wasm2c_sandbox)
Provides: bundled(sfntly)
Provides: bundled(sipcc)
Provides: bundled(skia)
Provides: bundled(soundtouch)
Provides: bundled(sqlite3)
Provides: bundled(thebes)
Provides: bundled(theora)
Provides: bundled(usrsctp)
Provides: bundled(wabt)
Provides: bundled(wasm2c)
Provides: bundled(WebRender)
Provides: bundled(wgpu)
Provides: bundled(woff2)
Provides: bundled(xsimd)
Provides: bundled(xz-embedded)
Provides: bundled(ycbcr)
Provides: bundled(zlib)

%if ! %{?system_libvpx}
Provides: bundled(libvpx)
%endif
%if ! %{?system_av1}
Provides: bundled(dav1d)
%endif

%description
Mozilla Firefox is an open-source web browser, designed for standards
compliance, performance and portability.

%if 0%{?run_firefox_tests}
%global testsuite_pkg_name %{name}-testresults
%package -n %{testsuite_pkg_name}
Summary: Results of testsuite
%description -n %{testsuite_pkg_name}
This package contains results of tests executed during build.
%files -n %{testsuite_pkg_name}
/%{version}-%{release}/test_results
/%{version}-%{release}/test_summary.txt
/%{version}-%{release}/failures-*
%endif

%if 0%{?wayland_backend_default}
%package x11
Summary: Firefox X11 launcher.
Requires: %{name}
%description x11
The firefox-x11 package contains launcher and desktop file
to run Firefox explicitly on X11.
%files x11
%{_bindir}/firefox-x11
%{_datadir}/applications/firefox-x11.desktop
%endif

#---------------------------------------------------------------------

%prep
%setup -q -n %{name}-%{version}

# remove files for rejected licenses
rm -vf ./*/testing/web-platform/tests/conformance-checkers/html-rdfa/0030-isvalid.html
rm -vf ./*/testing/web-platform/tests/conformance-checkers/html-rdfa/0008-isvalid.html
rm -vf ./*/testing/web-platform/tests/conformance-checkers/html-rdfalite/0030-isvalid.html
rm -vf ./*/testing/web-platform/tests/css/css-ui/support/cursors/woolly-64.svg
rm -vf ./*/testing/web-platform/tests/css/css-ui/support/cursors/woolly.svg
rm -vf ./*/testing/web-platform/tests/conformance-checkers/html-rdfa/0230-novalid.html
rm -vf ./*/testing/web-platform/tests/conformance-checkers/html-rdfa/0231-isvalid.html
rm -vf ./*/layout/inspector/tests/chrome/test_fontVariationsAPI.css
# A forbidden code point was found in:
rm -vf ./*/mobile/android/android-components/components/browser/errorpages/src/main/res/values-ar/strings.xml
rm -vf ./*/mobile/android/android-components/components/feature/addons/src/main/res/values-ur/strings.xml
rm -vf ./*/third_party/webkit/PerformanceTests/Speedometer3/resources/editors/dist/assets/codemirror-521de7ab.js
rm -vf ./*/third_party/python/pip/pip-24.0.dist-info/AUTHORS.txt

# We uses system freetype2
rm -vrf ./*/modules/freetype2
# We use system zlib
rm -vrf ./*/modules/zlib

# Build patches
%patch -P1 -p1 -b .disable-elfhack
%patch -P2 -p1 -b .firefox-gcc-build
%patch -P3 -p1 -b .build-big-endian-errors
%patch -P8 -p1 -b .rhbz-2131158-webrtc-nss-fix
%patch -P9 -p1 -b .build-ffvpx
%patch -P11 -p1 -b .rhbz-71999-fips-youtube
%patch -P12 -p1
%patch -P13 -p1 -b .rust-host-triplet-vendor

# -- Upstreamed patches --
%patch -P51 -p1 -b .mozilla-bmo1170092
%patch -P52 -p1 -b .exceptionHandled-for-IO-error-processhandler
%patch -P53 -p1 -b .clear-lang-bundles
%patch -P54 -p1 -b .restoreWinState
%patch -P55 -p1 -b .icu78
%patch -P56 -p1 -b .ffmpeg9
# -- Submitted upstream, not merged --
%patch -P101 -p1 -b .mozilla-bmo1636168-fscreen
%patch -P102 -p1 -b .mozilla-bmo1670333
%patch -P103 -p1 -b .mozilla-bmo1504834-part1
%patch -P104 -p1 -b .mozilla-bmo1504834-part3
%patch -P105 -p1 -b .mozilla-bmo849632
%patch -P106 -p1 -b .mozilla-bmo998749
%patch -P107 -p1 -b .mozilla-bmo1716707-swizzle
%patch -P108 -p1 -b .mozilla-bmo1716707-svg
%patch -P110 -p1 -b .libaom
%patch -P111 -p1 -b .av1-else-condition-add

# ---- Specific patches ----
%patch -P151 -p1 -b .addons
%patch -P152 -p1 -b .rhbz-1173156
%patch -P153 -p1 -b .addons-nss-hack
# ARM run-time patch
%ifarch aarch64
%patch -P154 -p1 -b .rhbz-1354671
%endif

# ---- Security patches ----

# RISCV64 patches

#LoongArch64 patches

%{__rm} -f .mozconfig
%{__cp} %{SOURCE10} .mozconfig
%{__cp} %{SOURCE24} mozilla-api-key
%{__cp} %{SOURCE27} google-api-key
%{__cp} %{SOURCE35} google-loc-api-key

echo "ac_add_options --prefix=\"%{_prefix}\"" >> .mozconfig
echo "ac_add_options --libdir=\"%{_libdir}\"" >> .mozconfig

%if %{?system_nss}
echo "ac_add_options --with-system-nspr" >> .mozconfig
echo "ac_add_options --with-system-nss" >> .mozconfig
%else
echo "ac_add_options --without-system-nspr" >> .mozconfig
echo "ac_add_options --without-system-nss" >> .mozconfig
%endif

%if %{?system_drm}
echo "ac_add_options --with-system-libdrm" >> .mozconfig
%else
echo "ac_add_options --without-system-libdrm" >> .mozconfig
%endif

%if %{?system_gbm}
echo "ac_add_options --with-system-gbm" >> .mozconfig
%else
echo "ac_add_options --without-system-gbm" >> .mozconfig
%endif

%if %{?system_icu}
echo "ac_add_options --with-system-icu" >> .mozconfig
%else
echo "ac_add_options --without-system-icu" >> .mozconfig
%endif

%if %{?system_pipewire}
echo "ac_add_options --with-system-pipewire" >> .mozconfig
%else
echo "ac_add_options --without-system-pipewire" >> .mozconfig
%endif


%if %{?debug_build}
echo "ac_add_options --enable-debug" >> .mozconfig
echo "ac_add_options --disable-optimize" >> .mozconfig
%else
%global optimize_flags "none"
%ifarch s390x
%global optimize_flags "-g -O1"
%endif
%ifarch ppc64le aarch64 riscv64
%global optimize_flags "-g -O2"
%endif
%if %{optimize_flags} != "none"
echo 'ac_add_options --enable-optimize=%{?optimize_flags}' >> .mozconfig
%else
echo 'ac_add_options --enable-optimize' >> .mozconfig
%endif
echo "ac_add_options --disable-debug" >> .mozconfig
%endif

# Second arches fail to start with jemalloc enabled
%ifnarch %{ix86} x86_64 riscv64
echo "ac_add_options --disable-jemalloc" >> .mozconfig
%endif

%if %{?system_av1}
echo "ac_add_options --with-system-av1" >> .mozconfig
%endif
%if %{?system_libvpx}
echo "ac_add_options --with-system-libvpx" >> .mozconfig
%endif
%if %{?system_webp}
echo "ac_add_options --with-system-webp" >> .mozconfig
%endif


%if 0%{?build_tests}
echo "ac_add_options --enable-tests" >> .mozconfig
%else
echo "ac_add_options --disable-tests" >> .mozconfig
%endif

%ifarch s390 s390x
echo "ac_add_options --disable-jit" >> .mozconfig
%endif

%ifarch ppc64 ppc64le
echo "ac_add_options --disable-webrtc" >> .mozconfig
echo "ac_add_options --disable-lto" >> .mozconfig
%endif
echo "ac_add_options --disable-lto" >> .mozconfig


# api keys full path
echo "ac_add_options --with-mozilla-api-keyfile=`pwd`/mozilla-api-key" >> .mozconfig
# It seems that the api key we have is for the safe browsing only
echo "ac_add_options --with-google-location-service-api-keyfile=`pwd`/google-loc-api-key" >> .mozconfig
echo "ac_add_options --with-google-safebrowsing-api-keyfile=`pwd`/google-api-key" >> .mozconfig

echo 'export NODEJS="%{_buildrootdir}/bin/node-stdout-nonblocking-wrapper"' >> .mozconfig

# Remove executable bit to make brp-mangle-shebangs happy.
chmod -x third_party/rust/itertools/src/lib.rs
chmod a-x third_party/rust/ash/src/extensions/ext/*.rs
chmod a-x third_party/rust/ash/src/extensions/khr/*.rs
chmod a-x third_party/rust/ash/src/extensions/nv/*.rs

#---------------------------------------------------------------------

%build
%if 0%{?use_gcc_ts}
source /opt/%{_vendor}/gcc-toolset-14/enable
%endif

# Disable LTO to work around rhbz#1883904
%define _lto_cflags %{nil}
export PATH="%{_buildrootdir}/bin:$PATH"
export PATH="/opt/%{_vendor}/%{llvm}/root/usr/bin/:$PATH"
# Cleanup buildroot for existing rpms from bundled nss/nspr and other packages
rm -rf %{_buildrootdir}/*

function install_rpms_to_current_dir() {
    PACKAGE_RPM=$(eval echo $1)
    PACKAGE_DIR=%{_rpmdir}

    if [ ! -f $PACKAGE_DIR/$PACKAGE_RPM ]; then
        # Hack for tps tests
        ARCH_STR=%{_arch}
        %ifarch %{ix86}
            ARCH_STR="i?86"
        %endif
        PACKAGE_DIR="$PACKAGE_DIR/$ARCH_STR"
     fi

     for package in $(ls $PACKAGE_DIR/$PACKAGE_RPM)
     do
         echo "$package"
         rpm2cpio "$package" | cpio -idu
     done
}

env
which gcc
which c++
which g++
which ld
which nasm
which node
which python3

%if 0%{?use_bundled_cbindgen}
# Bundled cbindgen
mkdir -p my_rust_vendor
cd my_rust_vendor
%{__tar} xf %{SOURCE2}
mkdir -p .cargo
%ifnarch loongarch64
cat > .cargo/config <<EOL
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "`pwd`"
EOL
%endif

env CARGO_HOME=.cargo cargo install cbindgen
export PATH=`pwd`/.cargo/bin:$PATH
cd -

# end of Bundled cbindgen
%endif

mkdir -p %{_buildrootdir}/bin || :
install -m0755 %{SOURCE32} %{_buildrootdir}/bin/ || :

# Update the various config.guess to upstream release for aarch64 support
# Do not update config.guess in the ./third_party/rust because that would break checksums
find ./ -path ./third_party/rust -prune -o -name config.guess -exec cp /usr/lib/rpm/config.guess {} ';'

MOZ_OPT_FLAGS=$(echo "%{optflags}" | %{__sed} -e 's/-Wall//')
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | sed -e 's/-fexceptions//')
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-Werror=format-security//')
MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now"
%if %{?debug_build}
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-O2//')
%endif
%if "%{toolchain}" == "clang"
MOZ_OPT_FLAGS=$(echo "%{optflags}" | %{__sed} -e 's/-fgcc-compatible//')
%endif

%ifarch %{ix86} riscv64
MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-g/-g0/')
export MOZ_DEBUG_FLAGS=" "
%endif

MOZ_LINK_FLAGS="%{?build_ldflags}"
### NOTE: these sections are not required anymore. Alson --no-keep-memory + -Wl,-z,pack-relative-relocs causes
### ld to go OOM (https://sourceware.org/bugzilla/show_bug.cgi?id=30756)
# Limit RAM usage during link
%ifnarch loongarch64
MOZ_LINK_FLAGS="$MOZ_LINK_FLAGS -Wl,--no-keep-memory"
%endif

# lld do not like --reduce-memory-overheads switch
%if "%{toolchain}" != "clang"
MOZ_LINK_FLAGS="$MOZ_LINK_FLAGS -Wl,--reduce-memory-overheads"
%endif

%if 0%{?flatpak}
# Make sure the linker can find libraries in /app/lib64 as we don't use
# __global_ldflags that normally sets this.
MOZ_LINK_FLAGS="$MOZ_LINK_FLAGS -L%{_libdir}"
%endif
%ifarch %{ix86} %{s390x} riscv64 loongarch64
export RUSTFLAGS="-Cdebuginfo=0"
echo 'export RUSTFLAGS="-Cdebuginfo=0"' >> .mozconfig
%endif


# We don't wantfirefox to use CK_GCM_PARAMS_V3 in nss
MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -DNSS_PKCS11_3_0_STRICT"

echo "export CFLAGS=\"$MOZ_OPT_FLAGS\"" >> .mozconfig
echo "export CXXFLAGS=\"$MOZ_OPT_FLAGS\"" >> .mozconfig
%ifarch aarch64
echo "export ASFLAGS=\"-mbranch-protection=standard\"" >> .mozconfig
%endif
%ifarch x86_64
echo "export ASFLAGS=\"-fcf-protection=full\"" >> .mozconfig
%endif
echo "export LDFLAGS=\"$MOZ_LINK_FLAGS\"" >> .mozconfig

%if "%{toolchain}" == "clang"
echo "export LD_LIBRARY_PATH=/opt/openEuler/llvm-toolset-21/root/usr/lib64:$LD_LIBRARY_PATH" >> .mozconfig
echo "export LLVM_PROFDATA=\"llvm-profdata\"" >> .mozconfig
echo "export AR=\"llvm-ar\"" >> .mozconfig
echo "export NM=\"llvm-nm\"" >> .mozconfig
echo "export RANLIB=\"llvm-ranlib\"" >> .mozconfig
echo "ac_add_options --enable-linker=lld" >> .mozconfig
%else
echo "export CC=gcc" >> .mozconfig
echo "export CXX=g++" >> .mozconfig
echo "export AR=\"gcc-ar\"" >> .mozconfig
echo "export NM=\"gcc-nm\"" >> .mozconfig
echo "export RANLIB=\"gcc-ranlib\"" >> .mozconfig
%endif
MOZ_SMP_FLAGS=-j1
# On x86_64 architectures, Mozilla can build up to 4 jobs at once in parallel,
# however builds tend to fail on other arches when building in parallel.
#%ifarch %{ix86} s390x aarch64 ppc64le
#[ -z "$RPM_BUILD_NCPUS" ] && \
#     RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
#[ "$RPM_BUILD_NCPUS" -ge 2 ] && MOZ_SMP_FLAGS=-j2
#%endif
#%ifarch x86_64 ppc ppc64 ppc64le
[ -z "$RPM_BUILD_NCPUS" ] && \
       RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"
[ "$RPM_BUILD_NCPUS" -ge 2 ] && MOZ_SMP_FLAGS=-j2
[ "$RPM_BUILD_NCPUS" -ge 4 ] && MOZ_SMP_FLAGS=-j4
[ "$RPM_BUILD_NCPUS" -ge 8 ] && MOZ_SMP_FLAGS=-j8
[ "$RPM_BUILD_NCPUS" -ge 16 ] && MOZ_SMP_FLAGS=-j16
[ "$RPM_BUILD_NCPUS" -ge 32 ] && MOZ_SMP_FLAGS=-j32
[ "$RPM_BUILD_NCPUS" -ge 64 ] && MOZ_SMP_FLAGS=-j64
#%endif

echo "mk_add_options MOZ_MAKE_FLAGS=\"$MOZ_SMP_FLAGS\"" >> .mozconfig
echo "mk_add_options MOZ_SERVICES_SYNC=1" >> .mozconfig
echo "export STRIP=/bin/true" >> .mozconfig

%if %{launch_wayland_compositor}
cp %{SOURCE36} .
. ./testing.sh run_wayland_compositor
%endif

./mach build -v 2>&1 || exit 1

#---------------------------------------------------------------------
%install
export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system
function install_rpms_to_current_dir() {
    PACKAGE_RPM=$(eval echo $1)
    PACKAGE_DIR=%{_rpmdir}

    if [ ! -f $PACKAGE_DIR/$PACKAGE_RPM ]; then
        # Hack for tps tests
        ARCH_STR=%{_arch}
        %ifarch %{ix86}
            ARCH_STR="i?86"
        %endif
        PACKAGE_DIR="$PACKAGE_DIR/$ARCH_STR"
     fi

     for package in $(ls $PACKAGE_DIR/$PACKAGE_RPM)
     do
         echo "$package"
         rpm2cpio "$package" | cpio -idu
     done
}

# run Firefox test suite
%if %{launch_wayland_compositor}
cp %{SOURCE36} .
. ./testing.sh run_wayland_compositor
%endif

%if 0%{?run_firefox_tests}
  mkdir -p objdir/_virtualenvs/init_py3
  %{__cat} > objdir/_virtualenvs/init_py3/pip.conf << EOF
[global]
find-links=`pwd`/mochitest-python
no-index=true
EOF
  tar xf %{SOURCE37}
  cp %{SOURCE36} .
  mkdir -p test_results
  %if %{?test_on_wayland}
    ./testing.sh run_tests_wayland || true
  %else
    ./testing.sh run_tests_x11 || true
  %endif
  ./testing.sh print_results > test_summary.txt 2>&1 || true
  ./testing.sh print_failures || true
%endif

# Make sure locale works for langpacks
%{__cat} > objdir/dist/bin/browser/defaults/preferences/firefox-l10n.js << EOF
pref("general.useragent.locale", "chrome://global/locale/intl.properties");
EOF

DESTDIR=%{buildroot} make -C objdir install

%{__mkdir_p} %{buildroot}{%{_libdir},%{_bindir},%{_datadir}/applications}

desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE20}
%if 0%{?wayland_backend_default}
desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE31}
%endif

# set up the firefox start script
%{__rm} -rf %{buildroot}%{_bindir}/firefox
%{__sed} -e 's,/__PREFIX__,%{_prefix},g' %{SOURCE21} > %{buildroot}%{_bindir}/firefox
%{__chmod} 755 %{buildroot}%{_bindir}/firefox

%if 0%{?flatpak}
sed -i -e 's|%FLATPAK_ENV_VARS%|export TMPDIR="$XDG_CACHE_HOME/tmp"|' %{buildroot}%{_bindir}/firefox
%else
sed -i -e 's|%FLATPAK_ENV_VARS%||' %{buildroot}%{_bindir}/firefox
%endif

# Run firefox under wayland only on RHEL9 and newer
%if !0%{?wayland_backend_default}
sed -i -e 's|%DISABLE_WAYLAND_PLACEHOLDER%|export MOZ_DISABLE_WAYLAND=1|' %{buildroot}%{_bindir}/firefox
%else
sed -i -e 's|%DISABLE_WAYLAND_PLACEHOLDER%||' %{buildroot}%{_bindir}/firefox
# firefox-x11 launch script for RHEL9 only
%{__sed} -e 's,/__PREFIX__,%{_prefix},g' %{SOURCE30} > %{buildroot}%{_bindir}/firefox-x11
%{__chmod} 755 %{buildroot}%{_bindir}/firefox-x11
%endif

%{__install} -p -D -m 644 %{SOURCE23} %{buildroot}%{_mandir}/man1/firefox.1

%{__rm} -f %{buildroot}/%{mozappdir}/firefox-config
%{__rm} -f %{buildroot}/%{mozappdir}/update-settings.ini

for s in 16 22 24 32 48 256; do
    %{__mkdir_p} %{buildroot}%{_datadir}/icons/hicolor/${s}x${s}/apps
    %{__cp} -p browser/branding/official/default${s}.png \
               %{buildroot}%{_datadir}/icons/hicolor/${s}x${s}/apps/firefox.png
done

# Install hight contrast icon
%{__mkdir_p} %{buildroot}%{_datadir}/icons/hicolor/symbolic/apps
%{__cp} -p %{SOURCE25} \
           %{buildroot}%{_datadir}/icons/hicolor/symbolic/apps

echo > %{name}.lang
%if %{with langpacks}
# Extract langpacks, make any mods needed, repack the langpack, and install it.
%{__mkdir_p} %{buildroot}%{langpackdir}
%{__tar} xf %{SOURCE1}
for langpack in `ls firefox-langpacks/*.xpi`; do
  language=`basename $langpack .xpi`
  extensionID=langpack-$language@firefox.mozilla.org
  %{__mkdir_p} $extensionID
  unzip -qq $langpack -d $extensionID
  find $extensionID -type f | xargs chmod 644

  cd $extensionID
  zip -qq -r9mX ../${extensionID}.xpi *
  cd -

  %{__install} -m 644 ${extensionID}.xpi %{buildroot}%{langpackdir}
  language=`echo $language | sed -e 's/-/_/g'`
%if 0%{?flatpak}
  echo "%{langpackdir}/${extensionID}.xpi" >> %{name}.lang
%else
  echo "%%lang($language) %{langpackdir}/${extensionID}.xpi" >> %{name}.lang
%endif
done
%{__rm} -rf firefox-langpacks

# Install langpack workaround (see #707100, #821169)
function create_default_langpack() {
language_long=$1
language_short=$2
cd %{buildroot}%{langpackdir}
ln -s langpack-$language_long@firefox.mozilla.org.xpi langpack-$language_short@firefox.mozilla.org.xpi
cd -
echo "%%lang($language_short) %{langpackdir}/langpack-$language_short@firefox.mozilla.org.xpi" >> %{name}.lang
}

# Table of fallbacks for each language
#create_default_langpack "bn-IN" "bn"
create_default_langpack "es-AR" "es"
create_default_langpack "fy-NL" "fy"
create_default_langpack "ga-IE" "ga"
create_default_langpack "gu-IN" "gu"
create_default_langpack "hi-IN" "hi"
create_default_langpack "hy-AM" "hy"
create_default_langpack "nb-NO" "nb"
create_default_langpack "nn-NO" "nn"
create_default_langpack "pa-IN" "pa"
create_default_langpack "pt-PT" "pt"
create_default_langpack "sv-SE" "sv"
create_default_langpack "zh-CN" "zh"
%endif

# Keep compatibility with the old preference location.
%{__mkdir_p} %{buildroot}%{mozappdir}/browser/defaults/preferences
# Default preferences
%{__cp} %{SOURCE12} %{buildroot}%{mozappdir}/browser/defaults/preferences/firefox.js
sed -i -e 's|%PREFIX%|%{_prefix}|' %{buildroot}%{mozappdir}/browser/defaults/preferences/firefox.js
# System config dir
%{__mkdir_p} %{buildroot}/%{_sysconfdir}/%{name}/pref

# System extensions
%global firefox_app_id  \{ec8030f7-c20a-464f-9b0e-13a3a9e97384\}
%{__mkdir_p} %{buildroot}%{_datadir}/mozilla/extensions/%{firefox_app_id}
%{__mkdir_p} %{buildroot}%{_libdir}/mozilla/extensions/%{firefox_app_id}

# Copy over the LICENSE
%{__install} -p -c -m 644 LICENSE %{buildroot}/%{mozappdir}

# Use the system hunspell dictionaries
%{__rm} -rf %{buildroot}%{mozappdir}/dictionaries
ln -s %{_datadir}/hunspell %{buildroot}%{mozappdir}/dictionaries

%if 0%{?run_firefox_tests}
%{__mkdir_p} %{buildroot}/%{version}-%{release}/test_results
%{__cp} test_results/* %{buildroot}/%{version}-%{release}/test_results
%{__cp} test_summary.txt %{buildroot}/%{version}-%{release}/
%{__cp} failures-* %{buildroot}/%{version}-%{release}/ || true
%endif

%if %{?use_pipewire_camera}
echo 'pref("media.webrtc.camera.allow-pipewire", true);' >> %{buildroot}%{mozappdir}/defaults/preferences/firefox.js
%endif

# Add distribution.ini
%{__mkdir_p} %{buildroot}%{mozappdir}/distribution
%{__sed} -e "s/__NAME__/%(source /etc/os-release; echo ${NAME})/g" \
         -e "s/__ID__/%(source /etc/os-release; echo ${ID})/g" \
         %{SOURCE26} > %{buildroot}%{mozappdir}/distribution/distribution.ini

# Install appdata file
mkdir -p %{buildroot}%{_datadir}/metainfo
%{__sed} -e "s/__VERSION__/%{version}/" \
         -e "s/__DATE__/$(date '+%Y-%m-%d')/" \
         %{SOURCE33} > %{buildroot}%{_datadir}/metainfo/org.mozilla.firefox.appdata.xml

# Install Gnome search provider files
mkdir -p %{buildroot}%{_datadir}/gnome-shell/search-providers
%{__cp} %{SOURCE34} %{buildroot}%{_datadir}/gnome-shell/search-providers

# Remove gtk2 support as flash plugin is no longer supported
rm -rf %{buildroot}%{mozappdir}/gtk2/

# Create a symlink to replace libnssckbi.so with p11-kit-client.so
# instead of p11-kit-trust.so, so that Firefox can see the system
# trust store on the host through the p11-kit RPC protocol.  A symlink
# to libnss3.so is also needed, because Firefox tries to load
# libnssckbi.so from the same directory where libnss3.so is loaded (as
# of Firefox 89).
%if 0%{?flatpak}
ln -sf /usr/lib64/libnss3.so %{buildroot}%{_libdir}/libnss3.so
ln -sf /usr/lib64/pkcs11/p11-kit-client.so %{buildroot}%{_libdir}/libnssckbi.so
%endif
#---------------------------------------------------------------------

%check
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/*.appdata.xml

%preun
# is it a final removal?
if [ $1 -eq 0 ]; then
  %{__rm} -rf %{mozappdir}/components
  %{__rm} -rf %{mozappdir}/extensions
  %{__rm} -rf %{mozappdir}/plugins
fi

%files -f %{name}.lang
%{_bindir}/firefox
%{mozappdir}/firefox
%{mozappdir}/firefox-bin
%doc %{_mandir}/man1/*
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/*
%dir %{_datadir}/mozilla/extensions/*
%dir %{_libdir}/mozilla/extensions/*
%{_datadir}/applications/org.mozilla.firefox.desktop
%{_datadir}/metainfo/*.appdata.xml
%{_datadir}/gnome-shell/search-providers/*.ini
%dir %{mozappdir}
%license %{mozappdir}/LICENSE
%{mozappdir}/browser/chrome
%{mozappdir}/browser/defaults/preferences/firefox.js
%{mozappdir}/distribution/distribution.ini
# That's Windows only
%ghost %{mozappdir}/browser/features/aushelper@mozilla.org.xpi
%if %{with langpacks}
%dir %{langpackdir}
%endif
%{mozappdir}/browser/omni.ja
%{mozappdir}/application.ini
%{mozappdir}/pingsender
%exclude %{mozappdir}/removed-files
%if 0%{?flatpak}
%{_libdir}/libnss3.so
%{_libdir}/libnssckbi.so
%endif
%{_datadir}/icons/hicolor/16x16/apps/firefox.png
%{_datadir}/icons/hicolor/22x22/apps/firefox.png
%{_datadir}/icons/hicolor/24x24/apps/firefox.png
%{_datadir}/icons/hicolor/256x256/apps/firefox.png
%{_datadir}/icons/hicolor/32x32/apps/firefox.png
%{_datadir}/icons/hicolor/48x48/apps/firefox.png
%{_datadir}/icons/hicolor/symbolic/apps/firefox-symbolic.svg
%{mozappdir}/*.so
%{mozappdir}/defaults/pref/channel-prefs.js
%{mozappdir}/dependentlibs.list
%{mozappdir}/dictionaries
%{mozappdir}/omni.ja
%{mozappdir}/platform.ini
%{mozappdir}/gmp-clearkey
%{mozappdir}/fonts/TwemojiMozilla.ttf
%{mozappdir}/glxtest
%{mozappdir}/vaapitest
%ifarch aarch64 riscv64
%{mozappdir}/v4l2test
%endif

%changelog
* Tue Aug 25 2026 Funda Wang <fundawang@yeah.net> - 140.14.0-2
- fix rust host triplet detection with rust >= 1.98 (fall back to unknown vendor)

* Tue Aug 18 2026 Funda Wang <fundawang@yeah.net> - 140.14.0-1
- update to 140.14.0
- support ffmpeg 9

* Wed Aug 05 2026 Funda Wang <fundawang@yeah.net> - 140.13.0-5
- build with same llvm which used by rust

* Mon Jul 27 2026 Wenlong Zhang <zhangwenlong@loongson.cn> - 140.13.0-3
- build firefox with clang on loongarch64

* Sat Jul 25 2026 Liu Wang <1823363429@qq.com> - 140.13.0-2
- Add StartupWMClass=firefox so that GNOME can correctly recognize the Firefox window and associate it with the icon.

* Tue Jul 21 2026 Funda Wang <fundawang@yeah.net> - 140.13.0-1
- update to 140.13.0

* Fri Jun 19 2026 Funda Wang <fundawang@yeah.net> - 140.12.0-2
- support building with non-root user inside container

* Tue Jun 16 2026 Funda Wang <fundawang@yeah.net> - 140.12.0-1
- update to 140.12.0

* Tue May 19 2026 Funda Wang <fundawang@yeah.net> - 140.11.0-1
- update to 140.11.0

* Fri May 08 2026 wangkai <13474090681@163.com> - 140.10.2-1
- update to 140.10.2
  * fix CVE-2026-8090, CVE-2026-8091, CVE-2026-8092, CVE-2026-8094

* Wed Apr 29 2026 wangkai <13474090681@163.com> - 140.10.1-1
- update to 140.10.1
  * fix CVE-2026-7320, CVE-2026-7321, CVE-2026-7322, CVE-2026-7323

* Tue Apr 21 2026 Funda Wang <fundawang@yeah.net> - 140.10.0-1
- update to 140.10.0

* Wed Apr 08 2026 wangkai <13474090681@163.com> - 140.9.1-1
- update to 140.9.1
  * fix CVE-2026-5731, CVE-2026-5732, CVE-2026-5734

* Tue Mar 24 2026 Funda Wang <fundawang@yeah.net> - 140.9.0-1
- update to 140.9.0

* Thu Feb 26 2026 Wang Kui <wangkui35@h-partners.com> - 140.8.0-2
- change DesktopId to org.mozilla.firefox.desktop in firefox-search-provider.ini

* Tue Feb 24 2026 Funda Wang <fundawang@yeah.net> - 140.8.0-1
- update to 140.8.0
- try build with system icu

* Wed Jan 14 2026 Funda Wang <fundawang@yeah.net> - 140.7.0-1
- update to 140.7.0
  * fix CVE-2026-0877, CVE-2026-0878, CVE-2026-0879, CVE-2026-0880,
    CVE-2026-0882, CVE-2025-14327, CVE-2026-0883, CVE-2026-0884,
    CVE-2026-0885, CVE-2026-0886, CVE-2026-0887, CVE-2026-0890,
    CVE-2026-0891

* Tue Dec 09 2025 Funda Wang <fundawang@yeah.net> - 140.6.0-1
- update to 140.6.0

* Tue Dec 02 2025 lijuzhang<lijuzhang@inspur.com> - 140.5.0-2
- BuildRequires(cargo) add version constraint

* Tue Nov 11 2025 Funda Wang <fundawang@yeah.net> - 140.5.0-1
- update to 140.5.0
  * fix CVE-2025-13012, CVE-2025-13013, CVE-2025-13014, CVE-2025-13015,
    CVE-2025-13016, CVE-2025-13017, CVE-2025-13018, CVE-2025-13019,
    CVE-2025-13020

* Wed Oct 22 2025 Funda Wang <fundawang@yeah.net> - 140.4.0-3
- support building with system cbindgen
- build with system ldflags

* Tue Oct 21 2025 Peng Haitao <htpengc@isoftstone.com> - 140.4.0-2
- Modify openEuler to %{vendor}

* Mon Oct 13 2025 Funda Wang <fundawang@yeah.net> - 140.4.0-1
- update to 140.4.0
- fix CVE-2025-11708, CVE-2025-11709, CVE-2025-11710, CVE-2025-11711,
  CVE-2025-11712, CVE-2025-11713, CVE-2025-11714, CVE-2025-11715

* Sat Oct 11 2025 wangkai <13474090681@163.com> - 140.3.1-2
- Disable use_gcc_ts marco

* Wed Sep 24 2025 wangkai <13474090681@163.com> - 140.3.1-1
- Update to 140.3.1
- Fix CVE-2025-10527 CVE-2025-10528 CVE-2025-10529 CVE-2025-10532 CVE-2025-10533
  CVE-2025-10536 CVE-2025-10537 CVE-2025-9182 CVE-2025-9183 CVE-2025-9184
  CVE-2025-8036 CVE-2025-8037 CVE-2025-8038 CVE-2025-8039 CVE-2025-8040

* Tue Aug 26 2025 Funda Wang <fundawang@yeah.net> - 128.14.0-2
- hunspell contains dictionary now
- drop useless update desktop and icon cache scriptlet

* Tue Aug 19 2025 Funda Wang <fundawang@yeah.net> - 128.14.0-1
- update to 128.14.0
- Fix CVE-2025-9179 CVE-2025-9180 CVE-2025-9181 CVE-2025-9185

* Wed Jul 23 2025 wangkai <13474090681@163.com> - 128.13.0-1
- Update to 128.13.0
- Fix CVE-2025-8027 CVE-2025-8028 CVE-2025-8029 CVE-2025-8030 CVE-2025-8031 CVE-2025-8032
  CVE-2025-8033 CVE-2025-8034 CVE-2025-8035
- Use system libpng

* Wed Jun 25 2025 wangkai <13474090681@163.com> - 128.12.0-1
- Update to 128.12.0
- Fix CVE-2025-6424 CVE-2025-6425 CVE-2025-6429 CVE-2025-6430

* Mon Jun 09 2025 wangkai <13474090681@163.com> - 128.11.0-1
- Update to 128.11.0
- Fix MFSA-TMP-2025-0001: Double-free in libvpx encoder
- Fix CVE-2025-5263 CVE-2025-5264 CVE-2025-5266 CVE-2025-5267 CVE-2025-5268 CVE-2025-5269

* Mon May 19 2025 wangkai <13474090681@163.com> - 128.10.1-1
- Update to 128.10.1
- Fix CVE-2025-4918 CVE-2025-4919

* Wed Apr 30 2025 wangkai <13474090681@163.com> - 128.10.0-1
- Update to 128.10.0
- Fix CVE-2025-2817 CVE-2025-4083 CVE-2025-4084 CVE-2025-4087 CVE-2025-4091 CVE-2025-4093

* Wed Apr 02 2025 wangkai <13474090681@163.com> - 128.9.0-1
- Update to 128.9.0
- Fix CVE-2025-3028 CVE-2025-3029 CVE-2025-3030

* Wed Mar 05 2025 wangkai <13474090681@163.com> - 128.8.0-1
- Update to 128.8.0
- Fix CVE-2024-43097 CVE-2025-1931 CVE-2025-1932 CVE-2025-1933 CVE-2025-1934
  CVE-2025-1935 CVE-2025-1936 CVE-2025-1937 CVE-2025-1938

* Wed Feb 05 2025 wangkai <13474090681@163.com> - 128.7.0-1
- Update to 128.7.0
- Fix CVE-2025-1009 CVE-2025-1010 CVE-2025-1011 CVE-2025-1012 CVE-2025-1013
  CVE-2025-1014 CVE-2025-1016 CVE-2025-1017

* Wed Jan 08 2025 wangkai <13474090681@163.com> - 128.6.0-1
- Update to 128.6.0
- Fix CVE-2025-0237 CVE-2025-0238 CVE-2025-0239 CVE-2025-0240 CVE-2025-0241
  CVE-2025-0242 CVE-2025-0243

* Tue Dec 03 2024 wangkai <13474090681@163.com> - 128.5.0-1
- Update to 128.5.0
- Fix CVE-2024-11691 CVE-2024-11692 CVE-2024-11694 CVE-2024-11695 CVE-2024-11696
  CVE-2024-11697 CVE-2024-11699

* Mon Nov 25 2024 zhouyi <zhouyi198@h-partners.com> - 128.4.0-3
- Lfs url change

* Thu Nov 14 2024 zhouyi <zhouyi198@h-partners.com> - 128.4.0-2
- Add lfs config
- Edit firefox.spec  

* Mon Nov 04 2024 wangkai <13474090681@163.com> - 128.4.0-1
- Update to 128.4.0
- Fix CVE-2024-10458 CVE-2024-10459 CVE-2024-10460 CVE-2024-10461 CVE-2024-10462
  CVE-2024-10463 CVE-2024-10464 CVE-2024-10465 CVE-2024-10466 CVE-2024-10467

* Tue Oct 22 2024 Wenlong Zhang <zhangwenlong@loongson.cn> - 128.3.0-3
- fix build error for loongarch64

* Wed Oct 09 2024 wangkai <13474090681@163.com> - 128.3.0-2
- Fix CVE-2024-9680

* Tue Oct 08 2024 wangkai <13474090681@163.com> - 128.3.0-1
- Update to 128.3.0
- Fix CVE-2024-9392 CVE-2024-9393 CVE-2024-9394 CVE-2024-9396
  CVE-2024-9397 CVE-2024-9398 CVE-2024-9399 CVE-2024-9400 CVE-2024-9401
  CVE-2024-9402

* Thu Sep 05 2024 misaka00251 <liuxin@iscas.ac.cn> - 128.2.0-1
- Upgrade to 128.2.0
- Fix CVE-2024-8385 CVE-2024-8386 CVE-2024-8387

* Wed Sep 04 2024 wangkai <13474090681@163.com> - 115.15.0-1
- Update to 115.15.0
- Fix CVE-2024-8381 CVE-2024-8382 CVE-2024-8383 CVE-2024-8384

* Thu Aug 08 2024 wangkai <13474090681@163.com> - 115.14.0-1
- Update to 115.14.0
- Fix CVE-2024-7519 CVE-2024-7521 CVE-2024-7522 CVE-2024-7524
  CVE-2024-7525 CVE-2024-7526 CVE-2024-7527 CVE-2024-7529 CVE-2024-7531

* Sat Aug 03 2024 lvfei <lvfei@kylinos.cn> - 115.13.0-2
- Fix bad date in changelog

* Thu Jul 11 2024 wangkai <13474090681@163.com> - 115.13.0-1
- Update to 115.13.0
- Fix CVE-2024-6601 CVE-2024-6602 CVE-2024-6603 CVE-2024-6604

* Thu Jun 13 2024 wangkai <13474090681@163.com> - 115.12.0-1
- Update to 115.12.0
- Fix CVE-2024-29944 CVE-2024-3302 CVE-2024-3852 CVE-2024-3854
  CVE-2024-3857 CVE-2024-3859 CVE-2024-3861 CVE-2024-3864 CVE-2024-4367
  CVE-2024-4767 CVE-2024-4768 CVE-2024-4769 CVE-2024-4770 CVE-2024-4777
  CVE-2024-5688 CVE-2024-5690 CVE-2024-5691 CVE-2024-5692 CVE-2024-5693
  CVE-2024-5696 CVE-2024-5700 CVE-2024-5702

* Wed May 29 2024 Wenlong Zhang <zhangwenlong@loongson.cn> - 115.9.0-3
- fix build error for loongarch64

* Fri May 10 2024 wangkai <13474090681@163.com> - 115.9.0-2
- fix rust-1.78 unknown feature stdsimd error

* Wed Mar 20 2024 wangkai <13474090681@163.com> - 115.9.0-1
- Update to 115.9.0
- Fix CVE-2024-2616 CVE-2024-2608 CVE-2024-2610 CVE-2024-2612 CVE-2024-2614 CVE-2023-5388 CVE-2024-2607 CVE-2024-2611
- CVE-2024-1546 CVE-2024-1549 CVE-2024-1547 CVE-2024-1553 CVE-2024-1551 CVE-2024-1548 CVE-2024-1552 CVE-2024-1550
- CVE-2024-0750 CVE-2024-0746 CVE-2024-0742 CVE-2024-0741 CVE-2024-0747 CVE-2024-0751 CVE-2024-0749 CVE-2024-0753 CVE-2024-0755
- CVE-2023-6856 CVE-2023-6859 CVE-2023-6857 CVE-2023-6860 CVE-2023-6867 CVE-2023-6858 CVE-2023-6865 CVE-2023-6863 CVE-2023-6861 CVE-2023-6864

* Sun Feb 18 2024 wangkai <13474090681@163.com> - 115.5.0-4
- Modify the way to get the source package

* Tue Jan 02 2024 wangkai <13474090681@163.com> - 115.5.0-3
- Fix CVE-2023-7104

* Sat Nov 25 2023 Jingwiw  <wangjingwei@iscas.ac.cn> - 115.5.0-2
- Optimize for riscv64
- Use system libraries for VP8, VP9, and WebP
- Force ffmpeg as a dependency

* Thu Nov 23 2023 wangkai <13474090681@163.com> - 115.5.0-1
- Update to 115.5.0

* Thu Sep 28 2023 wangkai <13474090681@163.com> - 102.15.0-2
- Fix for libwebp CVE-2023-4863

* Wed Sep 20 2023 lvfei <lvfei@kylinos.cn> - 102.15.0-1
- Update to 102.15.0
- Fix CVE-2023-4573 CVE-2023-4574 CVE-2023-4575 CVE-2023-4576  CVE-2023-4581 CVE-2023-4584

* Tue Aug 08 2023 wangkai <13474090681@163.com> - 102.14.0-1
- Update to 102.14.0
- Fix CVE-2023-4045 CVE-2023-4046 CVE-2023-4047 CVE-2023-4048 CVE-2023-4049 CVE-2023-4050 CVE-2023-4054 CVE-2023-4055 CVE-2023-4056

* Thu Jul 06 2023 wangkai <13474090681@163.com> - 102.13.0-1
- Update to 102.13.0
- Fix CVE-2023-34416 CVE-2023-34414 CVE-2023-37201 CVE-2023-37202 CVE-2023-37207 CVE-2023-37208 CVE-2023-37211
- Remove unused patch

* Wed May 10 2023 wangkai <13474090681@163.com> - 102.11.0-1
- Update to 102.11.0

* Fri Mar 31 2023 wangkai <wangkai385@h-partners.com> - 102.9.0-1
- Update to 102.9.0

* Fri Mar 03 2023 wangkai <wangkai385@h-partners.com> - 102.8.0-1
- Update to 102.8.0

* Tue Feb 14 2023 Ge Wang <wangge20@h-partners.com> - 79.0-14
- Fix build failure due to arc4random feature activated

* Thu Jul 21 2022 xu_ping <xuping33@h-partners.com> - 79.0-13
- Fix attribute error module distutils has no attribute sysconfig

* Fri May 6 2022 liyanan <liyanan32@h-partners.com> - 79.0-12
- Fix compilation failure by python3.10 and wayland 1.20

* Thu Oct 14 2021 zhangweiguo <zhangweiguo2@huawei.com> - 79.0-11
- Set RUSTFLAGS:debuginfo to 1

* Mon Aug 23 2021 lingsheng <lingsheng@huawei.com> - 79.0-10
- Fix firefox tab crash with clone3 in glibc 2.34

* Wed Aug 11 2021 caodongxia <caodongxia@huawei.com> - 79.0-9
- Fix glibc dynstack 

* Wed Jul  7 2021 lingsheng <lingsheng@huawei.com> - 79.0-8
- Fix firefox video tab crash with rust 1.51

* Mon Jul 05 2021 caodongxia <caodongxia@huawei.com> - 79.0-7
- Fix build with pipewire 0.3

* Fri May 14 2021 lingsheng <lingsheng@huawei.com> - 79.0-6
- Fix build with rust 1.51

* Thu Jan 07 2021 wangxiao <wangxiao65@huawei.com> - 79.0-5
- Fix CVE-2020-15969 CVE-2020-15999 CVE-2020-16012 CVE-2020-26951
  CVE-2020-26953 CVE-2020-26956 CVE-2020-26957 CVE-2020-26958
  CVE-2020-26959 CVE-2020-26960 CVE-2020-26961 CVE-2020-26963
  CVE-2020-26965 CVE-2020-25966 CVE-2020-26967

* Wed Dec 16 2020 wangxiao <wangxiao65@huawei.com> - 79.0-4
- Fix CVE-2020-15664 CVE-2020-15665 CVE-2020-15666 CVE-2020-15667
  CVE-2020-15668 CVE-2020-15676 CVE-2020-15677 CVE-2020-15678

* Sat Nov 28 2020 Jeffery.Gao <gaojianxing@huawei.com> - 79.0-3
- Fix firefox downgrade error

* Mon Oct 26 2020 lingsheng <lingsheng@huawei.com> - 79.0-2
- Fix firefox remove warning

* Mon Aug 17 2020 zhangjiapeng <zhangjiapeng9@huawei.com> - 79.0-1
- Update to 79.0-1

* Wed Jul 22 2020 lingsheng <lingsheng@huawei.com> - 62.0.3-7
- Fix firefox build with rust 1.38

* Mon May 25 2020 huanghaitao <huanghaitao8@huawei.com> - 62.0.3-6
- Type:cves
- ID: CVE-2020-6811 CVE-2020-6814
- SUG:restart
- DESC: fix CVE-2020-6811 CVE-2020-6814

* Mon May 25 2020 Captain Wei<captain.a.wei@gmail.com> - 62.0.3-5
- fix unstable_name_collisions problem when compile

* Wed Feb 26 2020 xuxijian<xuxijian@huawei.com> - 62.0.3-4
- Package init