From b19ec410cae70c640925725e6d2f5b701f04159b Mon Sep 17 00:00:00 2001
From: grizzlyuser <grizzlyuser@protonmail.com>
Date: Jan 05 2021 14:18:39 +0000
Subject: [PATCH 1/8] libre/iceweasel: 84.0.1 from upstreams, update patches


---

diff --git a/libre/iceweasel/0001-Use-remoting-name-for-GDK-application-names.patch b/libre/iceweasel/0001-Use-remoting-name-for-GDK-application-names.patch
index b1dcee5..bb0fff9 100644
--- a/libre/iceweasel/0001-Use-remoting-name-for-GDK-application-names.patch
+++ b/libre/iceweasel/0001-Use-remoting-name-for-GDK-application-names.patch
@@ -5,14 +5,14 @@ Subject: [PATCH] Use remoting name for GDK application names
 
 ---
  toolkit/xre/nsAppRunner.cpp |  6 +-----
- widget/gtk/nsAppShell.cpp   | 11 ++++-------
- 2 files changed, 5 insertions(+), 12 deletions(-)
+ widget/gtk/nsAppShell.cpp   | 12 +++++-------
+ 2 files changed, 6 insertions(+), 12 deletions(-)
 
 diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
-index 49e2c73986ab..43ebcac381c7 100644
+index 40e4dae574dc5..cc22fc3f5edaf 100644
 --- a/toolkit/xre/nsAppRunner.cpp
 +++ b/toolkit/xre/nsAppRunner.cpp
-@@ -3822,11 +3822,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
+@@ -4176,11 +4176,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) {
    // consistently.
  
    // Set program name to the one defined in application.ini.
@@ -26,18 +26,19 @@ index 49e2c73986ab..43ebcac381c7 100644
    // Initialize GTK here for splash.
  
 diff --git a/widget/gtk/nsAppShell.cpp b/widget/gtk/nsAppShell.cpp
-index cfe022e65d82..06325264dbb1 100644
+index 24bdd5083375b..74dd54a5ae0e6 100644
 --- a/widget/gtk/nsAppShell.cpp
 +++ b/widget/gtk/nsAppShell.cpp
-@@ -24,6 +24,7 @@
+@@ -24,6 +24,8 @@
  #  include "WakeLockListener.h"
  #endif
  #include "gfxPlatform.h"
 +#include "nsAppRunner.h"
++#include "mozilla/XREAppData.h"
  #include "ScreenHelperGTK.h"
  #include "HeadlessScreenHelper.h"
  #include "mozilla/widget/ScreenManager.h"
-@@ -159,13 +160,9 @@ nsresult nsAppShell::Init() {
+@@ -153,13 +155,9 @@ nsresult nsAppShell::Init() {
        // See https://bugzilla.gnome.org/show_bug.cgi?id=747634
        //
        // Only bother doing this for the parent process, since it's the one
diff --git a/libre/iceweasel/0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch b/libre/iceweasel/0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch
deleted file mode 100644
index 427dfcd..0000000
--- a/libre/iceweasel/0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Jed Davis <jld@mozilla.com>
-Date: Fri, 28 Aug 2020 09:23:58 +0000
-Subject: [PATCH] Bug 1660901 - Support the fstat-like subset of fstatat in the
- Linux sandbox policies. r=gcp
-
-Differential Revision: https://phabricator.services.mozilla.com/D88499
----
- security/sandbox/linux/SandboxFilter.cpp           | 6 ++++++
- security/sandbox/linux/broker/SandboxBrokerUtils.h | 2 ++
- 2 files changed, 8 insertions(+)
-
-diff --git a/security/sandbox/linux/SandboxFilter.cpp b/security/sandbox/linux/SandboxFilter.cpp
-index e522d61e065c..4087bdc07e01 100644
---- a/security/sandbox/linux/SandboxFilter.cpp
-+++ b/security/sandbox/linux/SandboxFilter.cpp
-@@ -243,6 +243,12 @@ class SandboxPolicyCommon : public SandboxPolicyBase {
-     auto path = reinterpret_cast<const char*>(aArgs.args[1]);
-     auto buf = reinterpret_cast<statstruct*>(aArgs.args[2]);
-     auto flags = static_cast<int>(aArgs.args[3]);
-+
-+    if (fd != AT_FDCWD && (flags & AT_EMPTY_PATH) != 0 &&
-+        strcmp(path, "") == 0) {
-+      return ConvertError(fstatsyscall(fd, buf));
-+    }
-+
-     if (fd != AT_FDCWD && path[0] != '/') {
-       SANDBOX_LOG_ERROR("unsupported fd-relative fstatat(%d, \"%s\", %p, %d)",
-                         fd, path, buf, flags);
-diff --git a/security/sandbox/linux/broker/SandboxBrokerUtils.h b/security/sandbox/linux/broker/SandboxBrokerUtils.h
-index 85a006740c2c..db33b5028e77 100644
---- a/security/sandbox/linux/broker/SandboxBrokerUtils.h
-+++ b/security/sandbox/linux/broker/SandboxBrokerUtils.h
-@@ -19,10 +19,12 @@
- typedef struct stat64 statstruct;
- #  define statsyscall stat64
- #  define lstatsyscall lstat64
-+#  define fstatsyscall fstat64
- #elif defined(__NR_stat)
- typedef struct stat statstruct;
- #  define statsyscall stat
- #  define lstatsyscall lstat
-+#  define fstatsyscall fstat
- #else
- #  error Missing stat syscall include.
- #endif
diff --git a/libre/iceweasel/0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch b/libre/iceweasel/0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch
deleted file mode 100644
index dd5a535..0000000
--- a/libre/iceweasel/0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Julien Cristau <jcristau@mozilla.com>
-Date: Sun, 6 Sep 2020 20:20:39 +0000
-Subject: [PATCH] Bug 1660901 - ignore AT_NO_AUTOMOUNT in fstatat system call.
- r=jld
-
-Per the manpage "Both stat() and lstat() act as though AT_NO_AUTOMOUNT
-was set.", so don't bail if it's set in a call to fstatat.
-
-Differential Revision: https://phabricator.services.mozilla.com/D89121
----
- security/sandbox/linux/SandboxFilter.cpp | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
-
-diff --git a/security/sandbox/linux/SandboxFilter.cpp b/security/sandbox/linux/SandboxFilter.cpp
-index 4087bdc07e01..c4f6c318ad1c 100644
---- a/security/sandbox/linux/SandboxFilter.cpp
-+++ b/security/sandbox/linux/SandboxFilter.cpp
-@@ -254,9 +254,10 @@ class SandboxPolicyCommon : public SandboxPolicyBase {
-                         fd, path, buf, flags);
-       return BlockedSyscallTrap(aArgs, nullptr);
-     }
--    if ((flags & ~AT_SYMLINK_NOFOLLOW) != 0) {
-+    if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT)) != 0) {
-       SANDBOX_LOG_ERROR("unsupported flags %d in fstatat(%d, \"%s\", %p, %d)",
--                        (flags & ~AT_SYMLINK_NOFOLLOW), fd, path, buf, flags);
-+                        (flags & ~(AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT)), fd,
-+                        path, buf, flags);
-       return BlockedSyscallTrap(aArgs, nullptr);
-     }
-     return (flags & AT_SYMLINK_NOFOLLOW) == 0 ? broker->Stat(path, buf)
diff --git a/libre/iceweasel/PKGBUILD b/libre/iceweasel/PKGBUILD
index 24f639c..17fa64c 100644
--- a/libre/iceweasel/PKGBUILD
+++ b/libre/iceweasel/PKGBUILD
@@ -44,10 +44,10 @@
 
 pkgname=iceweasel
 epoch=1
-pkgver=81.0.2
+pkgver=84.0.1
 pkgrel=1
 pkgrel+=.parabola1
-_brandingver=80.0
+_brandingver=84.0
 _brandingrel=1
 pkgdesc="Standalone web browser derived from Mozilla Firefox"
 arch=(x86_64)
@@ -70,9 +70,6 @@ replaces=('firefox')
 options=(!emptydirs !makeflags !strip)
 source=(https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-$pkgver.source.tar.xz{,.asc}
         0001-Use-remoting-name-for-GDK-application-names.patch
-        0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch
-        0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch
-        0004-Bug-1663715-Update-syn-and-proc-macro2-so-that-Firef.patch
         $pkgname.desktop)
 source+=(https://repo.parabola.nu/other/iceweasel/${pkgname}_${_brandingver}-${_brandingrel}.branding.tar.xz{,.sig}
          libre.patch
@@ -82,7 +79,7 @@ source_armv7h=(arm.patch
                build-arm-libopus.patch)
 source_i686=('avoid-libxul-OOM-python-check.patch'
              'rust-static-disable-network-test-on-static-libraries.patch')
-sha256sums=('91b6482de9b193b19d1fd9a8b99015a001646a48429297bbb7fe41784f9f9b44'
+sha256sums=('ae5500d270a199f9a10674fbd4ba7a6beac1f260a4c009bbca8ea39967592243'
             'SKIP'
             'e0eaec8ddd24bbebf4956563ebc6d7a56f8dada5835975ee4d320dd3d0c9c442'
             'c2489a4ad3bfb65c064e07180a1de9a2fbc3b1b72d6bc4cd3985484d1b6b7b29'
@@ -117,14 +114,6 @@ prepare() {
   # https://bugzilla.mozilla.org/show_bug.cgi?id=1530052
   patch -Np1 -i ../0001-Use-remoting-name-for-GDK-application-names.patch
 
-  # https://bugs.archlinux.org/task/67978
-  # https://bugzilla.mozilla.org/show_bug.cgi?id=1660901
-  patch -Np1 -i ../0002-Bug-1660901-Support-the-fstat-like-subset-of-fstatat.patch
-  patch -Np1 -i ../0003-Bug-1660901-ignore-AT_NO_AUTOMOUNT-in-fstatat-system.patch
-
-  # https://bugzilla.mozilla.org/show_bug.cgi?id=1663715
-  patch -Np1 -i ../0004-Bug-1663715-Update-syn-and-proc-macro2-so-that-Firef.patch
-
   cat >../mozconfig <<END
 ac_add_options --enable-application=browser
 mk_add_options MOZ_OBJDIR=${PWD@Q}/obj
@@ -201,7 +190,7 @@ END
     ;;
     i686)
       # disable LTO and use gcc toolchain (clang has issues on IA32)
-      # disable SIMD (SSE20 for i686)
+      # disable SIMD (SSE2 for i686)
       export MOZ_SOURCE_CHANGESET="DEVEDITION_${pkgver//./_}_RELEASE"
       cat >>../mozconfig <<END
 ac_add_options --disable-linker=lld
diff --git a/libre/iceweasel/avoid-libxul-OOM-python-check.patch b/libre/iceweasel/avoid-libxul-OOM-python-check.patch
index caefbe0..6322811 100644
--- a/libre/iceweasel/avoid-libxul-OOM-python-check.patch
+++ b/libre/iceweasel/avoid-libxul-OOM-python-check.patch
@@ -1,7 +1,7 @@
-diff -rauN firefox-79.0/config/rules.mk firefox-79.0-avoid-libxul-OOM-python-check-patch/config/rules.mk
---- firefox-79.0/config/rules.mk	2020-07-21 00:49:36.000000000 +0200
-+++ firefox-79.0-avoid-libxul-OOM-python-check-patch/config/rules.mk	2020-08-02 14:04:30.846204786 +0200
-@@ -470,7 +470,7 @@ ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
+diff -rauN a/config/rules.mk b/config/rules.mk
+--- a/config/rules.mk	2020-10-13 20:28:50.994026769 +0200
++++ b/config/rules.mk	2020-10-13 20:29:06.594023940 +0200
+@@ -470,7 +470,7 @@
  	$(LINKER) -OUT:$@ -PDB:$(LINK_PDBFILE) -IMPLIB:$(basename $(@F)).lib $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $($(notdir $@)_OBJS) $(filter %.res,$^) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
  else # !WINNT || GNU_CC
  	$(call EXPAND_CC_OR_CXX,$@) -o $@ $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) $($(notdir $@)_OBJS) $(filter %.res,$^) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS)
@@ -10,7 +10,7 @@ diff -rauN firefox-79.0/config/rules.mk firefox-79.0-avoid-libxul-OOM-python-che
  endif # WINNT && !GNU_CC
  
  ifdef ENABLE_STRIP
-@@ -514,7 +514,7 @@ ifeq (_WINNT,$(GNU_CC)_$(OS_ARCH))
+@@ -514,7 +514,7 @@
  	$(LINKER) -out:$@ -pdb:$(LINK_PDBFILE) $($@_OBJS) $(filter %.res,$^) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(MOZ_PROGRAM_LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(OS_LIBS)
  else
  	$(call EXPAND_CC_OR_CXX,$@) $(COMPUTED_CXX_LDFLAGS) $(PGO_CFLAGS) -o $@ $($@_OBJS) $(filter %.res,$^) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(OS_LIBS)
@@ -19,7 +19,7 @@ diff -rauN firefox-79.0/config/rules.mk firefox-79.0-avoid-libxul-OOM-python-che
  endif # WINNT && !GNU_CC
  
  ifdef ENABLE_STRIP
-@@ -594,7 +594,7 @@ ifndef INCREMENTAL_LINKER
+@@ -594,7 +594,7 @@
  	$(RM) $@
  endif
  	$(MKSHLIB) $($@_OBJS) $(filter %.res,$^) $(LDFLAGS) $(STATIC_LIBS) $(SHARED_LIBS) $(EXTRA_DSO_LDOPTS) $(MOZ_GLUE_LDFLAGS) $(OS_LIBS)
diff --git a/libre/iceweasel/rust-static-disable-network-test-on-static-libraries.patch b/libre/iceweasel/rust-static-disable-network-test-on-static-libraries.patch
index 95c2df7..81d536c 100644
--- a/libre/iceweasel/rust-static-disable-network-test-on-static-libraries.patch
+++ b/libre/iceweasel/rust-static-disable-network-test-on-static-libraries.patch
@@ -1,15 +1,14 @@
-diff --git a/config/makefiles/rust.mk b/config/makefiles/rust.mk
-index 58606db50f..9c4d5b9279 100644
---- a/config/makefiles/rust.mk
-+++ b/config/makefiles/rust.mk
-@@ -305,17 +305,17 @@ $(RUST_LIBRARY_FILE): force-cargo-library-build
+diff -rauN a/config/makefiles/rust.mk b/config/makefiles/rust.mk
+--- a/config/makefiles/rust.mk	2020-10-13 20:23:09.920635480 +0200
++++ b/config/makefiles/rust.mk	2020-10-13 20:24:02.273994137 +0200
+@@ -310,17 +310,17 @@
  # the chance of proxy bypasses originating from rust code.
- # The check only works when rust code is built with -Clto but without MOZ_LTO_RUST.
+ # The check only works when rust code is built with -Clto but without MOZ_LTO_RUST_CROSS.
  # Sanitizers and sancov also fail because compiler-rt hooks network functions.
 -ifndef MOZ_PROFILE_GENERATE
 -ifeq ($(OS_ARCH), Linux)
 -ifeq (,$(rustflags_sancov)$(MOZ_ASAN)$(MOZ_TSAN)$(MOZ_UBSAN))
--ifndef MOZ_LTO_RUST
+-ifndef MOZ_LTO_RUST_CROSS
 -ifneq (,$(filter -Clto,$(cargo_rustc_flags)))
 -	$(call py_action,check_binary,--target --networking $@)
 -endif
@@ -17,17 +16,17 @@ index 58606db50f..9c4d5b9279 100644
 -endif
 -endif
 -endif
-+# ifndef MOZ_PROFILE_GENERATE
-+# ifeq ($(OS_ARCH), Linux)
-+# ifeq (,$(rustflags_sancov)$(MOZ_ASAN)$(MOZ_TSAN)$(MOZ_UBSAN))
-+# ifndef MOZ_LTO_RUST
-+# ifneq (,$(filter -Clto,$(cargo_rustc_flags)))
-+# 	$(call py_action,check_binary,--target --networking $@)
-+# endif
-+# endif
-+# endif
-+# endif
-+# endif
++#ifndef MOZ_PROFILE_GENERATE
++#ifeq ($(OS_ARCH), Linux)
++#ifeq (,$(rustflags_sancov)$(MOZ_ASAN)$(MOZ_TSAN)$(MOZ_UBSAN))
++#ifndef MOZ_LTO_RUST_CROSS
++#ifneq (,$(filter -Clto,$(cargo_rustc_flags)))
++#	$(call py_action,check_binary,--target --networking $@)
++#endif
++#endif
++#endif
++#endif
++#endif
  
  force-cargo-library-check:
  	$(call CARGO_CHECK) --lib $(cargo_target_flag) $(rust_features_flag)

From 10f52704525e7c58eadf0c3ea5d6e555f8dd548d Mon Sep 17 00:00:00 2001
From: grizzlyuser <grizzlyuser@protonmail.com>
Date: Jan 05 2021 14:18:39 +0000
Subject: [PATCH 2/8] libre/iceweasel: Remote Settings patching


Also add basic test that searches the entire source code tree for domain
name of Remote Settings server and fails the build if any occurrences
are found.

Needed to relocate quilt directory because IIRC it made some backups of
patched files that contained that domain name.

---

diff --git a/libre/iceweasel/PKGBUILD b/libre/iceweasel/PKGBUILD
index 17fa64c..6632d6b 100644
--- a/libre/iceweasel/PKGBUILD
+++ b/libre/iceweasel/PKGBUILD
@@ -27,6 +27,9 @@
 #  - Modify the addons pages to use GNU IceCat plugins sources, rather
 #    than addons.mozilla.org, which hosts non-free addons
 #  - Disable EME, which is implemented via the non-free libWideVine CDM
+#  - Disable Normandy that let Mozilla push messages with recommendations
+#    of nonfree software
+#  - Make Remote Settings work completely offline using local data
 #  - Rebrand to Iceweasel, per the mozilla trademark policy,
 #    due to these FSDG changes
 #
@@ -74,6 +77,7 @@ source=(https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-
 source+=(https://repo.parabola.nu/other/iceweasel/${pkgname}_${_brandingver}-${_brandingrel}.branding.tar.xz{,.sig}
          libre.patch
          libre-searchengines.patch
+         libre-0001-always-sync-remote-settings-with-local-dump.patch
          vendor.js.in)
 source_armv7h=(arm.patch
                build-arm-libopus.patch)
@@ -257,14 +261,30 @@ END
   export QUILT_PATCHES="${brandingsrcdir}"/patches
   export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
   export QUILT_DIFF_ARGS='--no-timestamps'
+  export QUILT_PC=$srcdir/.pc
   quilt push -av
 
 
   ## libre patching ##
 
   # Remove remaining non-free bits
+  # Remove test-related networking dumps, because they contain code from
+  # some Amazon webpage with no clear licensing, thus nonfree.
+  # Also they interfere with checking of Remote Settings patching done later,
+  # because communication with RS server has been captured in them too.
+  rm python/mozperftest/mozperftest/system/example.zip
+  rm testing/mozbase/mozproxy/tests/files/mitm5-linux-firefox-amazon.zip
+
   echo "applying libre.patch"
-  patch -Np1 -i ../libre.patch
+  patch -Np1 --no-backup-if-mismatch -i ../libre.patch
+
+  echo "applying libre-0001-always-sync-remote-settings-with-local-dump.patch"
+  patch -Np1 --no-backup-if-mismatch -i ../libre-0001-always-sync-remote-settings-with-local-dump.patch
+
+  # Check Remote Settings patched completely by
+  # libre-0001-always-sync-remote-settings-with-local-dump.patch
+  local settings_server='firefox.settings.services.mozilla.com'
+  ! grep -qr $settings_server || { echo 'Remote Settings patching needs rework'; return 1; }
 
   # Disable various components at the source level
   sed -i 's/;1/;0/' toolkit/components/telemetry/components.conf
diff --git a/libre/iceweasel/libre-0001-always-sync-remote-settings-with-local-dump.patch b/libre/iceweasel/libre-0001-always-sync-remote-settings-with-local-dump.patch
new file mode 100644
index 0000000..4e37328
--- /dev/null
+++ b/libre/iceweasel/libre-0001-always-sync-remote-settings-with-local-dump.patch
@@ -0,0 +1,987 @@
+From c115ebc66ae779c18128e0b815fcf29da268a4f8 Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 17:20:39 +0200
+Subject: [PATCH 01/13] Point to local omni.ja files, not remote server
+
+Basically replace every occurrence of Remote Settings server domain name
+with URIs that point to built-in local files within omni.ja.
+
+Some links to json files may point to non-existing files, but that's OK
+because it's better than leave them point to Remote Settings server.
+If necessary, missing files can be added later.
+---
+ .../components/ASRouterAdmin/ASRouterAdmin.jsx            | 2 +-
+ .../newtab/data/content/activity-stream.bundle.js         | 2 +-
+ modules/libpref/init/all.js                               | 2 +-
+ services/settings/Utils.jsm                               | 4 ++--
+ .../periodic-updates/scripts/periodic_file_updates.sh     | 2 +-
+ toolkit/components/search/SearchUtils.jsm                 | 8 ++++----
+ toolkit/components/search/docs/DefaultSearchEngines.rst   | 2 +-
+ .../components/search/docs/SearchEngineConfiguration.rst  | 2 +-
+ toolkit/mozapps/defaultagent/RemoteSettings.cpp           | 2 +-
+ 9 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx b/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx
+index 8c5e540bd2..329e4e66f9 100644
+--- a/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx
++++ b/browser/components/newtab/content-src/components/ASRouterAdmin/ASRouterAdmin.jsx
+@@ -1260,7 +1260,7 @@ export class ASRouterAdminInner extends React.PureComponent {
+                   <a
+                     className="providerUrl"
+                     target="_blank"
+-                    href="https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/nimbus-desktop-experiments/records"
++                    href="resource://app/defaults/settings/main/nimbus-desktop-experiments.json"
+                     rel="noopener noreferrer"
+                   >
+                     nimbus-desktop-experiments
+diff --git a/browser/components/newtab/data/content/activity-stream.bundle.js b/browser/components/newtab/data/content/activity-stream.bundle.js
+index fb6d64d432..d8213e7e20 100644
+--- a/browser/components/newtab/data/content/activity-stream.bundle.js
++++ b/browser/components/newtab/data/content/activity-stream.bundle.js
+@@ -1835,7 +1835,7 @@ class ASRouterAdminInner extends react__WEBPACK_IMPORTED_MODULE_4___default.a.Pu
+         label = react__WEBPACK_IMPORTED_MODULE_4___default.a.createElement("span", null, "remote settings (", react__WEBPACK_IMPORTED_MODULE_4___default.a.createElement("a", {
+           className: "providerUrl",
+           target: "_blank",
+-          href: "https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/nimbus-desktop-experiments/records",
++          href: "resource://app/defaults/settings/main/nimbus-desktop-experiments.json",
+           rel: "noopener noreferrer"
+         }, "nimbus-desktop-experiments"), ")");
+       }
+diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
+index 2406affed4..907e8ebcef 100644
+--- a/modules/libpref/init/all.js
++++ b/modules/libpref/init/all.js
+@@ -2250,7 +2250,7 @@ pref("security.cert_pinning.hpkp.enabled", false);
+ // Remote settings preferences
+ // Note: if you change this, make sure to also review security.onecrl.maximum_staleness_in_seconds
+ pref("services.settings.poll_interval", 86400); // 24H
+-pref("services.settings.server", "https://firefox.settings.services.mozilla.com/v1");
++pref("services.settings.server", "resource://app/defaults/settings");
+ pref("services.settings.default_bucket", "main");
+ 
+ // The percentage of clients who will report uptake telemetry as
+diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm
+index 66df850904..0df0fdc677 100644
+--- a/services/settings/Utils.jsm
++++ b/services/settings/Utils.jsm
+@@ -60,11 +60,11 @@ var Utils = {
+     );
+     const isXpcshell = env.exists("XPCSHELL_TEST_PROFILE_DIR");
+     return AppConstants.RELEASE_OR_BETA && !Cu.isInAutomation && !isXpcshell
+-      ? "https://firefox.settings.services.mozilla.com/v1"
++      ? "resource://app/defaults/settings"
+       : gServerURL;
+   },
+ 
+-  CHANGES_PATH: "/buckets/monitor/collections/changes/records",
++  CHANGES_PATH: "/monitor/changes.json",
+ 
+   /**
+    * Logger instance.
+diff --git a/taskcluster/docker/periodic-updates/scripts/periodic_file_updates.sh b/taskcluster/docker/periodic-updates/scripts/periodic_file_updates.sh
+index c2492615e0..2b10ad01f6 100755
+--- a/taskcluster/docker/periodic-updates/scripts/periodic_file_updates.sh
++++ b/taskcluster/docker/periodic-updates/scripts/periodic_file_updates.sh
+@@ -279,7 +279,7 @@ function compare_suffix_lists {
+ }
+ 
+ function compare_remote_settings_files {
+-  REMOTE_SETTINGS_SERVER="https://firefox.settings.services.mozilla.com/v1"
++  REMOTE_SETTINGS_SERVER="resource://app/defaults/settings"
+ 
+   # 1. List remote settings collections from server.
+   echo "INFO: fetch remote settings list from server"
+diff --git a/toolkit/components/search/SearchUtils.jsm b/toolkit/components/search/SearchUtils.jsm
+index 278f9f9c08..7bac023c11 100644
+--- a/toolkit/components/search/SearchUtils.jsm
++++ b/toolkit/components/search/SearchUtils.jsm
+@@ -139,13 +139,13 @@ var SearchUtils = {
+ 
+   ENGINES_URLS: {
+     "prod-main":
+-      "https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/search-config/records",
++      "resource://app/defaults/settings/main/search-config.json",
+     "prod-preview":
+-      "https://firefox.settings.services.mozilla.com/v1/buckets/main-preview/collections/search-config/records",
++      "resource://app/defaults/settings/main/search-config.json",
+     "stage-main":
+-      "https://settings.stage.mozaws.net/v1/buckets/main/collections/search-config/records",
++      "resource://app/defaults/settings/main/search-config.json",
+     "stage-preview":
+-      "https://settings.stage.mozaws.net/v1/buckets/main-preview/collections/search-config/records",
++      "resource://app/defaults/settings/main/search-config.json",
+   },
+ 
+   // The following constants are left undocumented in nsISearchService.idl
+diff --git a/toolkit/components/search/docs/DefaultSearchEngines.rst b/toolkit/components/search/docs/DefaultSearchEngines.rst
+index 5668646648..deb7d20185 100644
+--- a/toolkit/components/search/docs/DefaultSearchEngines.rst
++++ b/toolkit/components/search/docs/DefaultSearchEngines.rst
+@@ -63,4 +63,4 @@ is updated.
+ 
+ .. _configuration schema: SearchConfigurationSchema.html
+ .. _remote settings: /services/common/services/RemoteSettings.html
+-.. _search-default-override-allowlist bucket: https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/search-default-override-allowlist/records
++.. _search-default-override-allowlist bucket: resource://app/defaults/settings/main/search-default-override-allowlist.json
+diff --git a/toolkit/components/search/docs/SearchEngineConfiguration.rst b/toolkit/components/search/docs/SearchEngineConfiguration.rst
+index e9041affb8..7a9466d294 100644
+--- a/toolkit/components/search/docs/SearchEngineConfiguration.rst
++++ b/toolkit/components/search/docs/SearchEngineConfiguration.rst
+@@ -68,5 +68,5 @@ related. As a result several situations may occur:
+ .. _JSON schema: https://json-schema.org/
+ .. _stored in mozilla-central: https://searchfox.org/mozilla-central/source/toolkit/components/search/schema/
+ .. _Search Configuration Schema: SearchConfigurationSchema.html
+-.. _viewed live: https://firefox.settings.services.mozilla.com/v1/buckets/main/collections/search-config/records
++.. _viewed live: resource://app/defaults/settings/main/search-config.json
+ .. _Normandy: /toolkit/components/normandy/normandy/services.html
+diff --git a/toolkit/mozapps/defaultagent/RemoteSettings.cpp b/toolkit/mozapps/defaultagent/RemoteSettings.cpp
+index 667d9fc628..b2bf628f29 100644
+--- a/toolkit/mozapps/defaultagent/RemoteSettings.cpp
++++ b/toolkit/mozapps/defaultagent/RemoteSettings.cpp
+@@ -23,7 +23,7 @@ extern "C" {
+ HRESULT IsAgentRemoteDisabledRust(const char* szUrl, DWORD* lpdwDisabled);
+ }
+ 
+-#define PROD_ENDPOINT "https://firefox.settings.services.mozilla.com/v1"
++#define PROD_ENDPOINT "resource://app/defaults/settings"
+ #define PROD_BID "main"
+ #define PROD_CID "windows-default-browser-agent"
+ #define PROD_ID "state"
+-- 
+2.30.0
+
+
+From f76e1c055def541e358886d0e73ba4710d3e5084 Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 17:34:08 +0200
+Subject: [PATCH 02/13] Remove polling triggered by push broadcasts
+
+When initialized, remote-settings.js adds a listener to push broadcasts,
+that let Remote Settings server send push messages to trigger polling
+for changes from the client side. This is not needed for local-only
+setup. Remove the record from broadcast-listeners.json file stored in
+the user profile, so that it doesn't get picked up by push broadcast
+service.
+---
+ dom/push/PushBroadcastService.jsm    | 13 +++++++++++++
+ services/settings/remote-settings.js |  7 ++-----
+ 2 files changed, 15 insertions(+), 5 deletions(-)
+
+diff --git a/dom/push/PushBroadcastService.jsm b/dom/push/PushBroadcastService.jsm
+index 27ed31ee9c..71f1316994 100644
+--- a/dom/push/PushBroadcastService.jsm
++++ b/dom/push/PushBroadcastService.jsm
+@@ -179,6 +179,19 @@ var BroadcastService = class {
+     }
+   }
+ 
++  async deleteListener(broadcastId) {
++    await this.initializePromise;
++
++    if (this.jsonFile.data.listeners.hasOwnProperty(broadcastId)) {
++      console.info(
++        "deleteListener: deleting listener",
++        broadcastId
++      );
++      delete this.jsonFile.data.listeners[broadcastId];
++      this.jsonFile.saveSoon();
++    }
++  }
++
+   /**
+    * Call the listeners of the specified broadcasts.
+    *
+diff --git a/services/settings/remote-settings.js b/services/settings/remote-settings.js
+index 6d0185faf9..aae93fa440 100644
+--- a/services/settings/remote-settings.js
++++ b/services/settings/remote-settings.js
+@@ -441,7 +441,7 @@ function remoteSettingsFunction() {
+       moduleURI: __URI__,
+       symbolName: "remoteSettingsBroadcastHandler",
+     };
+-    pushBroadcastService.addListener(BROADCAST_ID, currentVersion, moduleInfo);
++    pushBroadcastService.deleteListener(BROADCAST_ID);
+   };
+ 
+   return remoteSettings;
+@@ -461,9 +461,6 @@ var remoteSettingsBroadcastHandler = {
+       `Push notification received (version=${version} phase=${phase})`
+     );
+ 
+-    return RemoteSettings.pollChanges({
+-      expectedTimestamp: version,
+-      trigger: isStartup ? "startup" : "broadcast",
+-    });
++    return;
+   },
+ };
+-- 
+2.30.0
+
+
+From fcf60ef5835e673e03807d898f90e48907f44e63 Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 17:41:54 +0200
+Subject: [PATCH 03/13] Remove timer that triggers polling for changes
+
+That is not needed for local-only setup.
+---
+ services/settings/components.conf           | 9 +--------
+ services/settings/servicesSettings.manifest | 4 ----
+ 2 files changed, 1 insertion(+), 12 deletions(-)
+
+diff --git a/services/settings/components.conf b/services/settings/components.conf
+index 9a737802ee..25109415a7 100644
+--- a/services/settings/components.conf
++++ b/services/settings/components.conf
+@@ -4,11 +4,4 @@
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ 
+-Classes = [
+-    {
+-        'cid': '{5e756573-234a-49ea-bbe4-59ec7a70657d}',
+-        'contract_ids': ['@mozilla.org/services/settings;1'],
+-        'jsm': 'resource://services-settings/RemoteSettingsComponents.jsm',
+-        'constructor': 'RemoteSettingsTimer',
+-    },
+-]
++Classes = []
+diff --git a/services/settings/servicesSettings.manifest b/services/settings/servicesSettings.manifest
+index 3bfed26ea4..807eb220ec 100644
+--- a/services/settings/servicesSettings.manifest
++++ b/services/settings/servicesSettings.manifest
+@@ -1,7 +1,3 @@
+ # Register resource aliases
+ resource services-settings resource://gre/modules/services-settings/
+ 
+-# Schedule polling of remote settings changes
+-# (default 24H, max 72H)
+-# see syntax https://searchfox.org/mozilla-central/rev/cc280c4be94ff8cf64a27cc9b3d6831ffa49fa45/toolkit/components/timermanager/UpdateTimerManager.jsm#155
+-category update-timer RemoteSettingsComponents @mozilla.org/services/settings;1,getService,services-settings-poll-changes,services.settings.poll_interval,86400,259200
+-- 
+2.30.0
+
+
+From 8600d50c402f523973f67dfb03c1ea8614fcf48c Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 17:47:41 +0200
+Subject: [PATCH 04/13] Utils: fetch timestamps of each collection locally
+
+Utils.CHANGES_PATH points to
+services/settings/dumps/monitor/changes.json
+which will be generated later by JSON processing script. Fetch the
+timestamps from that file and mock response headers to not confuse any
+code that expects them.
+---
+ browser/installer/package-manifest.in     |  1 +
+ services/settings/Utils.jsm               | 14 ++++++++++++--
+ services/settings/dumps/monitor/moz.build |  8 ++++++++
+ services/settings/dumps/moz.build         |  1 +
+ 4 files changed, 22 insertions(+), 2 deletions(-)
+ create mode 100644 services/settings/dumps/monitor/moz.build
+
+diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in
+index 75c79a7168..ac01689596 100644
+--- a/browser/installer/package-manifest.in
++++ b/browser/installer/package-manifest.in
+@@ -295,6 +295,7 @@
+ @RESPATH@/browser/defaults/settings/blocklists
+ @RESPATH@/browser/defaults/settings/pinning
+ @RESPATH@/browser/defaults/settings/main
++@RESPATH@/browser/defaults/settings/monitor
+ @RESPATH@/browser/defaults/settings/security-state
+ 
+ ; Warning: changing the path to channel-prefs.js can cause bugs (Bug 756325)
+diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm
+index 0df0fdc677..0e631ddc0d 100644
+--- a/services/settings/Utils.jsm
++++ b/services/settings/Utils.jsm
+@@ -145,7 +145,7 @@ var Utils = {
+     //     "collection":"certificates"
+     //    }]}
+ 
+-    let url = serverUrl + Utils.CHANGES_PATH;
++    let url = Utils.SERVER_URL + Utils.CHANGES_PATH;
+ 
+     // Use ETag to obtain a `304 Not modified` when no change occurred,
+     // and `?_since` parameter to only keep entries that weren't processed yet.
+@@ -166,6 +166,9 @@ var Utils = {
+           .join("&");
+     }
+     const response = await fetch(url, { headers });
++    const responseDate = new Date().toUTCString()
++    response.headers.set("Date", responseDate);
++    response.headers.set("Last-Modified", responseDate);
+ 
+     let changes = [];
+     // If no changes since last time, go on with empty list of changes.
+@@ -203,7 +206,14 @@ var Utils = {
+           );
+         }
+       } else {
+-        changes = payload.data;
++        const { bucket, collection } = filters;
++        if (!bucket || !collection) {
++          throw new Error('Unable to fetch latest change without bucket or collection');
++        }
++        const change = payload.data.find(
++            change => change.bucket === bucket && change.collection === collection
++          ) ?? { last_modified: 0, bucket, collection };
++        changes = [change];
+       }
+     }
+     // The server should always return ETag. But we've had situations where the CDN
+diff --git a/services/settings/dumps/monitor/moz.build b/services/settings/dumps/monitor/moz.build
+new file mode 100644
+index 0000000000..d3d017fda5
+--- /dev/null
++++ b/services/settings/dumps/monitor/moz.build
+@@ -0,0 +1,8 @@
++# This Source Code Form is subject to the terms of the Mozilla Public
++# License, v. 2.0. If a copy of the MPL was not distributed with this
++# file, You can obtain one at http://mozilla.org/MPL/2.0/.
++
++FINAL_TARGET_FILES.defaults.settings.monitor += ["changes.json"]
++
++if CONFIG["MOZ_BUILD_APP"] == "browser":
++    DIST_SUBDIR = "browser"
+diff --git a/services/settings/dumps/moz.build b/services/settings/dumps/moz.build
+index 3cc9436f61..3742da5667 100644
+--- a/services/settings/dumps/moz.build
++++ b/services/settings/dumps/moz.build
+@@ -5,6 +5,7 @@
+ DIRS += [
+     "blocklists",
+     "main",
++    "monitor",
+     "pinning",
+     "security-state",
+ ]
+-- 
+2.30.0
+
+
+From 99af961e47d810c965c0145f19a92eedec1abafc Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 17:52:10 +0200
+Subject: [PATCH 05/13] Utils: disable offline checking
+
+Since only local data is read now, it should always return false for the
+current any any future code that relies on it.
+---
+ services/settings/Utils.jsm | 9 ---------
+ 1 file changed, 9 deletions(-)
+
+diff --git a/services/settings/Utils.jsm b/services/settings/Utils.jsm
+index 0e631ddc0d..d034d8ea78 100644
+--- a/services/settings/Utils.jsm
++++ b/services/settings/Utils.jsm
+@@ -80,15 +80,6 @@ var Utils = {
+    * @return {bool} Whether network is down or not.
+    */
+   get isOffline() {
+-    try {
+-      return (
+-        Services.io.offline ||
+-        CaptivePortalService.state == CaptivePortalService.LOCKED_PORTAL ||
+-        !gNetworkLinkService.isLinkUp
+-      );
+-    } catch (ex) {
+-      log.warn("Could not determine network status.", ex);
+-    }
+     return false;
+   },
+ 
+-- 
+2.30.0
+
+
+From 55830695a1e2457aecca1392d46c98c3e210d58a Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 17:56:02 +0200
+Subject: [PATCH 06/13] Refactor hashing logic to a separate function
+
+It is used instead of internal signature validation mechanism, for
+integrity checking of the locally cached data.
+---
+ services/settings/RemoteSettingsWorker.jsm | 4 ++++
+ services/settings/SharedUtils.jsm          | 9 +++++++--
+ 2 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/services/settings/RemoteSettingsWorker.jsm b/services/settings/RemoteSettingsWorker.jsm
+index 147ebb6b13..c86e218fd3 100644
+--- a/services/settings/RemoteSettingsWorker.jsm
++++ b/services/settings/RemoteSettingsWorker.jsm
+@@ -189,6 +189,10 @@ class Worker {
+     // task on the current thread instead of the worker thread.
+     return SharedUtils.checkContentHash(buffer, size, hash);
+   }
++
++  async getContentHash(bytes) {
++    return SharedUtils.getContentHash(bytes);
++  }
+ }
+ 
+ // Now, first add a shutdown blocker. If that fails, we must have
+diff --git a/services/settings/SharedUtils.jsm b/services/settings/SharedUtils.jsm
+index db5017a742..1a8e83c2e8 100644
+--- a/services/settings/SharedUtils.jsm
++++ b/services/settings/SharedUtils.jsm
+@@ -28,11 +28,16 @@ var SharedUtils = {
+       return false;
+     }
+     // Has expected content?
++    const hashStr = await this.getContentHash(bytes);
++    return hashStr == hash;
++  },
++
++  async getContentHash(bytes) {
+     const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
+     const hashBytes = new Uint8Array(hashBuffer);
+     const toHex = b => b.toString(16).padStart(2, "0");
+-    const hashStr = Array.from(hashBytes, toHex).join("");
+-    return hashStr == hash;
++
++    return Array.from(hashBytes, toHex).join("");
+   },
+ 
+   /**
+-- 
+2.30.0
+
+
+From 9dc19397aebfb6b9f74afa0fb4d653a29e14e964 Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 18:05:02 +0200
+Subject: [PATCH 07/13] Client: Fetch and hash records from local dump
+
+Read the records from local dumps. See [1] for details on how to prepare
+custom dumps). Records are cached in the local IndexedDB, and the client
+updates cached records each time there's a change. Also it verifies
+integrity of the data. Then the list of current / created / updated /
+deleted records is generated and emitted to every registered listener.
+
+Change upstream signature validation mechanism to a simpler one.
+Otherwise, it'd be necessary to sign local records, which is redundant,
+because the application package should be signed already by the distro.
+
+Instead of signature property from metadata records, json_dump_metadata
+has been introduced. It contains the checksum of the records and size in
+bytes. Also added app_build_id property for version checking and updates
+of cached data.
+
+Although it's possible to disable integrity checking via preference, it
+seems to be not a good idea, because the logic that detects invalid
+local data relies on it. In the context of local-only setup, data that
+has been received from real Remote Settings server will not contain the
+custom metadata, and thus will be considered invalid and then discarded,
+while the client gets a chance to gracefully inform registered listeners
+about these changes so that they can discard the data received before
+the upgrade to local-only setup.
+
+[1] https://firefox-source-docs.mozilla.org/services/common/services/RemoteSettings.html#initial-data
+---
+ services/settings/RemoteSettingsClient.jsm | 62 ++++++++++------------
+ 1 file changed, 27 insertions(+), 35 deletions(-)
+
+diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
+index 80dd563e11..1025ab33a2 100644
+--- a/services/settings/RemoteSettingsClient.jsm
++++ b/services/settings/RemoteSettingsClient.jsm
+@@ -556,11 +556,9 @@ class RemoteSettingsClient extends EventEmitter {
+ 
+           // If the data is up-to-date but don't have metadata (records loaded from dump),
+           // we fetch them and validate the signature immediately.
+-          if (this.verifySignature && ObjectUtils.isEmpty(localMetadata)) {
++          if (this.verifySignature && ObjectUtils.isEmpty(localMetadata?.json_dump_metadata)) {
+             console.debug(`${this.identifier} pull collection metadata`);
+-            const metadata = await this.httpClient().getData({
+-              query: { _expected: expectedTimestamp },
+-            });
++            const { metadata } = await this._fetchChangeset(expectedTimestamp);
+             await this.db.importChanges(metadata);
+             // We don't bother validating the signature if the dump was just loaded. We do
+             // if the dump was loaded at some other point (eg. from .get()).
+@@ -813,32 +811,23 @@ class RemoteSettingsClient extends EventEmitter {
+   async _validateCollectionSignature(records, timestamp, metadata) {
+     const start = Cu.now() * 1000;
+ 
+-    if (!metadata?.signature) {
++    if (!metadata?.json_dump_metadata) {
+       throw new MissingSignatureError(this.identifier);
+     }
+ 
+-    if (!this._verifier) {
+-      this._verifier = Cc[
+-        "@mozilla.org/security/contentsignatureverifier;1"
+-      ].createInstance(Ci.nsIContentSignatureVerifier);
+-    }
+-
+-    // This is a content-signature field from an autograph response.
+     const {
+-      signature: { x5u, signature },
++      json_dump_metadata: { hash, size },
+     } = metadata;
+-    const certChain = await (await fetch(x5u)).text();
+     // Merge remote records with local ones and serialize as canonical JSON.
+     const serialized = await RemoteSettingsWorker.canonicalStringify(
+       records,
+       timestamp
+     );
+     if (
+-      !(await this._verifier.asyncVerifyContentSignature(
+-        serialized,
+-        "p384ecdsa=" + signature,
+-        certChain,
+-        this.signerName
++      !(await RemoteSettingsWorker.checkContentHash(
++        new TextEncoder().encode(serialized),
++        size,
++        hash
+       ))
+     ) {
+       throw new InvalidSignatureError(this.identifier);
+@@ -1030,24 +1019,27 @@ class RemoteSettingsClient extends EventEmitter {
+    * @param since timestamp of last sync (optional)
+    */
+   async _fetchChangeset(expectedTimestamp, since) {
+-    const client = this.httpClient();
+-    const {
+-      metadata,
+-      timestamp: remoteTimestamp,
+-      changes: remoteRecords,
+-    } = await client.execute(
+-      {
+-        path: `/buckets/${this.bucketName}/collections/${this.collectionName}/changeset`,
+-      },
+-      {
+-        query: {
+-          _expected: expectedTimestamp,
+-          _since: since,
+-        },
+-      }
++    const { data } = await SharedUtils.loadJSONDump(
++      this.bucketName,
++      this.collectionName
+     );
++    const remoteRecords = data ?? [];
++
++    const serialized = await RemoteSettingsWorker.canonicalStringify(
++      remoteRecords,
++      expectedTimestamp
++    );
++    const bytes = new TextEncoder().encode(serialized);
++    const metadata = {
++      app_build_id: Services.appinfo.appBuildID,
++      json_dump_metadata: {
++        hash: await RemoteSettingsWorker.getContentHash(bytes),
++        size: bytes.length,
++      },
++    }
++
+     return {
+-      remoteTimestamp,
++      remoteTimestamp: expectedTimestamp,
+       metadata,
+       remoteRecords,
+     };
+-- 
+2.30.0
+
+
+From 4dfbb2ccacd011b05839c19127942b497141f2a1 Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 18:42:56 +0200
+Subject: [PATCH 08/13] Client: start deferred sync on get() or on()
+
+The users of the RemoteSettingsClient.jsm can receive records from it in
+two ways: by calling get(), and by subscribing to events by calling
+on().
+
+So hook a deferred sync whenever something calls these methods. Because
+multiple of those calls can be made quite early and in very short time,
+set up a deferred task that will be armed only when needed and only once
+in a second. When the task is running it first checks if the local data
+came from the dump of the current app build, and no-ops if true. If
+false, it triggers a sync. Then adds a flag if the client has been
+correctly synchronized with the dump, so that no metadata checking
+occurs during the session.
+---
+ services/settings/RemoteSettingsClient.jsm | 32 ++++++++++++++++++++--
+ 1 file changed, 30 insertions(+), 2 deletions(-)
+
+diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
+index 1025ab33a2..253251823a 100644
+--- a/services/settings/RemoteSettingsClient.jsm
++++ b/services/settings/RemoteSettingsClient.jsm
+@@ -16,6 +16,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
+   ClientEnvironmentBase:
+     "resource://gre/modules/components-utils/ClientEnvironment.jsm",
+   Database: "resource://services-settings/Database.jsm",
++  DeferredTask: "resource://gre/modules/DeferredTask.jsm",
+   Downloader: "resource://services-settings/Attachments.jsm",
+   IDBHelpers: "resource://services-settings/IDBHelpers.jsm",
+   KintoHttpClient: "resource://services-common/kinto-http-client.js",
+@@ -30,6 +31,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
+ XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);
+ 
+ const TELEMETRY_COMPONENT = "remotesettings";
++const DEFERRED_SYNC_DELAY_MILLISECONDS = 1000
+ 
+ XPCOMUtils.defineLazyGetter(this, "console", () => Utils.log);
+ 
+@@ -259,6 +261,14 @@ class RemoteSettingsClient extends EventEmitter {
+     this._lastCheckTimePref = lastCheckTimePref;
+     this._verifier = null;
+     this._syncRunning = false;
++    this._deferredSync = new DeferredTask(
++      async () => {
++        if (!this._syncRunning && !(await this._isSynced())) {
++          await this.sync();
++        }
++      },
++      DEFERRED_SYNC_DELAY_MILLISECONDS
++    );
+ 
+     // This attribute allows signature verification to be disabled, when running tests
+     // or when pulling data from a dev server.
+@@ -290,6 +300,11 @@ class RemoteSettingsClient extends EventEmitter {
+     );
+   }
+ 
++  on(event, callback) {
++    super.on(event, callback);
++    this._deferredSync.arm();
++  }
++
+   get identifier() {
+     return `${this.bucketName}/${this.collectionName}`;
+   }
+@@ -353,7 +368,11 @@ class RemoteSettingsClient extends EventEmitter {
+     try {
+       let hasLocalData = await Utils.hasLocalData(this);
+ 
+-      if (syncIfEmpty && !hasLocalData) {
++      if (!(await this._isSynced())) {
++        throw new MissingSignatureError(this.identifier);
++      }
++
++      if ((syncIfEmpty && !hasLocalData)) {
+         // .get() was called before we had the chance to synchronize the local database.
+         // We'll try to avoid returning an empty list.
+         if (!this._importingPromise) {
+@@ -414,7 +433,10 @@ class RemoteSettingsClient extends EventEmitter {
+       // No need to verify signature on JSON dumps.
+       // If local DB cannot be read, then we don't even try to do anything,
+       // we return results early.
+-      return this._filterEntries(data);
++      const filtered = this._filterEntries(data);
++      this._deferredSync.arm();
++
++      return filtered;
+     }
+ 
+     console.debug(
+@@ -452,6 +474,12 @@ class RemoteSettingsClient extends EventEmitter {
+     return final;
+   }
+ 
++  async _isSynced() {
++    this._synced ||=
++      Services.appinfo.appBuildID === (await this.db.getMetadata())?.app_build_id;
++    return this._synced;
++  }
++
+   /**
+    * Synchronize the local database with the remote server.
+    *
+-- 
+2.30.0
+
+
+From 89dc912d08b7d4eed113439efa17dce57eda106e Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 18:53:51 +0200
+Subject: [PATCH 09/13] Client: deep compare records if timestamps match
+
+When the list of current / updated / deleted records is generated, their
+modification timestamps are compared to detect the updates.
+
+Although in practice this is unlikely to happen, in theory the
+timestamp of some older record received from Remote Settings can match
+with the modified record in the dump. Although JSON processing script
+makes sure to add unique timestamps to each of the modified records,
+it's still possible to update dumps manually and simply forget to update
+timestamps. So serialize the records and compare them as strings to be
+on the safe side. This should happen only once after upgrading to each
+new version of the application, so is not likely to introduce any
+noticeable performance issues.
+---
+ services/settings/RemoteSettingsClient.jsm | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
+index 253251823a..b45a55919c 100644
+--- a/services/settings/RemoteSettingsClient.jsm
++++ b/services/settings/RemoteSettingsClient.jsm
+@@ -13,6 +13,7 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+ 
+ XPCOMUtils.defineLazyModuleGetters(this, {
+   AppConstants: "resource://gre/modules/AppConstants.jsm",
++  CanonicalJSON: "resource://gre/modules/CanonicalJSON.jsm",
+   ClientEnvironmentBase:
+     "resource://gre/modules/components-utils/ClientEnvironment.jsm",
+   Database: "resource://services-settings/Database.jsm",
+@@ -1022,7 +1023,10 @@ class RemoteSettingsClient extends EventEmitter {
+         const old = oldById.get(r.id);
+         if (old) {
+           oldById.delete(r.id);
+-          if (r.last_modified != old.last_modified) {
++          if (
++            r.last_modified != old.last_modified ||
++            CanonicalJSON.stringify(r) != CanonicalJSON.stringify(old)
++          ) {
+             syncResult.updated.push({ old, new: r });
+           }
+         } else {
+-- 
+2.30.0
+
+
+From 5f4207fd155c2dae802522070627c34ced6a192e Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 19:01:39 +0200
+Subject: [PATCH 10/13] Client: delete more data on cleanup
+
+When the client detects the local data is invalid (i.e. it came from
+real Remote Settings and can have unwanted records), delete not only
+the records, but also the attachments that came with them, because they
+too can be problematic. And last check time preference, because it's not
+useful anyway when remote-settings.js doesn't do any polling for changes.
+
+Note that attachments should be deleted before the records, because the
+logic gets the data about the attachments from those records.
+---
+ services/settings/RemoteSettingsClient.jsm | 15 ++++++++++++---
+ 1 file changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
+index b45a55919c..3dbd972f87 100644
+--- a/services/settings/RemoteSettingsClient.jsm
++++ b/services/settings/RemoteSettingsClient.jsm
+@@ -221,7 +221,10 @@ class AttachmentDownloader extends Downloader {
+   async deleteAll() {
+     let allRecords = await this._client.db.list();
+     return Promise.all(
+-      allRecords.filter(r => !!r.attachment).map(r => this.delete(r))
++      allRecords.filter(r => !!r.attachment).map(r => {
++        this.delete(r);
++        this.deleteCached(r.id);
++      })
+     );
+   }
+ }
+@@ -982,7 +985,7 @@ class RemoteSettingsClient extends EventEmitter {
+           // Signature failed, clear local DB because it contains
+           // bad data (local + remote changes).
+           console.debug(`${this.identifier} clear local data`);
+-          await this.db.clear();
++          await this._clearAll();
+           // Local data was tampered, throw and it will retry from empty DB.
+           console.error(`${this.identifier} local data was corrupted`);
+           throw new CorruptedDataError(this.identifier);
+@@ -1004,7 +1007,7 @@ class RemoteSettingsClient extends EventEmitter {
+             // _importJSONDump() only clears DB if dump is available,
+             // therefore do it here!
+             if (imported < 0) {
+-              await this.db.clear();
++              await this._clearAll();
+             }
+           }
+         }
+@@ -1044,6 +1047,12 @@ class RemoteSettingsClient extends EventEmitter {
+     return syncResult;
+   }
+ 
++  async _clearAll() {
++    await this.attachments.deleteAll();
++    await this.db.clear();
++    Services.prefs.clearUserPref(this.lastCheckTimePref);
++  }
++
+   /**
+    * Fetch information from changeset endpoint.
+    *
+-- 
+2.30.0
+
+
+From b3c304e2fe95d0a75c524a5aa96a68a34ce2ae34 Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 19:07:56 +0200
+Subject: [PATCH 11/13] Client: remove comparison of collection timestamps
+
+In case if the cached data that came from real Remote Settings server
+(before the upgrade to local-only setup) has collection timestamp, that
+is newer than the packaged local dump, then this comparison logic can
+lead to early return of old data, skipping the integrity checking and
+necessary cleanup. So remove the checks.
+---
+ services/settings/RemoteSettingsClient.jsm | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/services/settings/RemoteSettingsClient.jsm b/services/settings/RemoteSettingsClient.jsm
+index 3dbd972f87..d319a77c27 100644
+--- a/services/settings/RemoteSettingsClient.jsm
++++ b/services/settings/RemoteSettingsClient.jsm
+@@ -917,14 +917,9 @@ class RemoteSettingsClient extends EventEmitter {
+       updated: [],
+       deleted: [],
+     };
+-    // If data wasn't changed, return empty sync result.
+-    // This can happen when we update the signature but not the data.
+     console.debug(
+       `${this.identifier} local timestamp: ${localTimestamp}, remote: ${remoteTimestamp}`
+     );
+-    if (localTimestamp && remoteTimestamp < localTimestamp) {
+-      return syncResult;
+-    }
+ 
+     const start = Cu.now() * 1000;
+     await this.db.importChanges(metadata, remoteTimestamp, remoteRecords, {
+-- 
+2.30.0
+
+
+From 804007d2861f829315e575660d47b9a4c430d151 Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 19:15:44 +0200
+Subject: [PATCH 12/13] Attachments: load only from dump and drop cached
+
+---
+ services/settings/Attachments.jsm | 35 +++++++------------------------
+ 1 file changed, 8 insertions(+), 27 deletions(-)
+
+diff --git a/services/settings/Attachments.jsm b/services/settings/Attachments.jsm
+index 0eeb632799..eaa7db8c81 100644
+--- a/services/settings/Attachments.jsm
++++ b/services/settings/Attachments.jsm
+@@ -143,10 +143,11 @@ class Downloader {
+       checkHash,
+       attachmentId = record?.id,
+       useCache = false,
+-      fallbackToCache = false,
+       fallbackToDump = false,
+     } = options || {};
+ 
++    const fallbackToCache = false;
++
+     if (!useCache) {
+       // For backwards compatibility.
+       // WARNING: Its return type is different from what's documented.
+@@ -206,6 +207,7 @@ class Downloader {
+         const newBuffer = await this.downloadAsBytes(record, {
+           retries,
+           checkHash,
++          dumpInfo,
+         });
+         const blob = new Blob([newBuffer]);
+         if (useCache) {
+@@ -241,7 +243,7 @@ class Downloader {
+       }
+ 
+       try {
+-        return { ...(await cacheInfo.getResult()), _source: "cache_fallback" };
++        await this.cacheImpl.delete(attachmentId);
+       } catch (e) {
+         // Failed to read from cache, e.g. IndexedDB unusable.
+         Cu.reportError(e);
+@@ -278,7 +280,7 @@ class Downloader {
+    * @returns {String} the absolute file path to the downloaded attachment.
+    */
+   async downloadToDisk(record, options = {}) {
+-    const { retries = 3 } = options;
++    const retries = 0;
+     const {
+       attachment: { filename, size, hash },
+     } = record;
+@@ -335,31 +337,10 @@ class Downloader {
+    */
+   async downloadAsBytes(record, options = {}) {
+     const {
+-      attachment: { location, hash, size },
+-    } = record;
+-
+-    const remoteFileUrl = (await this._baseAttachmentsURL()) + location;
++      dumpInfo = new LazyRecordAndBuffer(() => this._readAttachmentDump(attachmentId))
++    } = options;
+ 
+-    const { retries = 3, checkHash = true } = options;
+-    let retried = 0;
+-    while (true) {
+-      try {
+-        const buffer = await this._fetchAttachment(remoteFileUrl);
+-        if (!checkHash) {
+-          return buffer;
+-        }
+-        if (await RemoteSettingsWorker.checkContentHash(buffer, size, hash)) {
+-          return buffer;
+-        }
+-        // Content is corrupted.
+-        throw new Downloader.BadContentError(location);
+-      } catch (e) {
+-        if (retried >= retries) {
+-          throw e;
+-        }
+-      }
+-      retried++;
+-    }
++    return (await dumpInfo.getResult()).buffer;
+   }
+ 
+   /**
+-- 
+2.30.0
+
+
+From 4ee3b715e10a5f9a5ef7830b047ae7f64e55e5f4 Mon Sep 17 00:00:00 2001
+From: grizzlyuser <grizzlyuser@protonmail.com>
+Date: Wed, 30 Dec 2020 19:22:20 +0200
+Subject: [PATCH 13/13] Disable CRLite entirely for now
+
+It's designed to fetch the data from Remote Settings. One of the main
+selling points is that new revocations can be pushed to the clients
+within minutes. That won't work with local-only setup. Although (some?)
+of the JSON dumps for it are in place, obviously the updates won't
+happen that fast.
+
+Right now CRLite doesn't enforce anything, and works just for telemetry
+collection (which is hopefully disabled anyway). So disable the
+preference right in the source code, so that the patch fails to apply
+when the upstream decides to set it to enforcing mode by default.
+
+The solution with CRLite is up for discussion. If necessary, it's
+possible to make clients for blessed collections to communicate to real
+Remote Settings server. For example, for collections related to
+certificate revocations.
+---
+ modules/libpref/init/all.js | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
+index 907e8ebcef..65db6bd04c 100644
+--- a/modules/libpref/init/all.js
++++ b/modules/libpref/init/all.js
+@@ -186,7 +186,7 @@ pref("security.pki.distrust_ca_policy", 2);
+ #if defined(NIGHTLY_BUILD)
+ pref("security.pki.crlite_mode", 2);
+ #else
+-pref("security.pki.crlite_mode", 1);
++pref("security.pki.crlite_mode", 0);
+ #endif
+ 
+ // Represents the expected certificate transparency log merge delay (including
+-- 
+2.30.0
+

From 824020da2265c770dd299e0c697b18f1b0922105 Mon Sep 17 00:00:00 2001
From: grizzlyuser <grizzlyuser@protonmail.com>
Date: Jan 05 2021 14:18:39 +0000
Subject: [PATCH 3/8] libre/iceweasel: Drop old search engine patching


Legacy search configuration has been dropped upstream [1].
It needs to be done by new method now.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1619926

---

diff --git a/libre/iceweasel/PKGBUILD b/libre/iceweasel/PKGBUILD
index 6632d6b..5d40e11 100644
--- a/libre/iceweasel/PKGBUILD
+++ b/libre/iceweasel/PKGBUILD
@@ -303,13 +303,9 @@ END
   # FIXME: custom searchplugins ID per new format above ("ddg" is standard)
   #        browser/components/search/extensions/<ID>/
 #   local remove_engines_sed='s|.*oogle.*|          "ddg", "duckduckgo-html", "duckduckgo-lite", "internet-archive", "parabola-labs", "parabola-packages", "parabola-wiki-en", "searx", "wikipedia", "yacy"|g'
-  local remove_engines_sed='s|.*oogle.*|          "ddg", "wikipedia"|g'
-  echo "applying libre-searchengines.patch"
-  patch -Np1 -i ../libre-searchengines.patch
   pushd browser/components/search/extensions
-  sed -i "${remove_engines_sed}" list.json
   sed -i 's|https://duckduckgo.com/|https://html.duckduckgo.com/html/|' ddg/manifest.json
-  
+
   # Removing URL parameters that let DuckDuckGo know the place in UI
   # the search was ran from (like address bar, context menu, etc.)
   local jq_cmd='del(.chrome_settings_overrides.search_provider.params)'
@@ -317,16 +313,10 @@ END
   ! diff manifest.json.tmp ddg/manifest.json > /dev/null
   mv manifest.json.tmp ddg/manifest.json
 
-  # Sanity-check search-engines patching
-  local removed_engines_regex='Bing|Google|Seznam|Twitter|Yahoo|Yandex|Яндекс|amazon|bing|google|ebay|twitter'
-  local engines_err_msg="search-engines patch needs re-working"
-  ! grep -E ${removed_engines_regex} list.json > /dev/null || ! echo "${engines_err_msg}"
-
   find -mindepth 1 -maxdepth 1 \
     -not -name ddg \
     -not -name wikipedia \
-    -not -name list.json \
-    -exec rm -rf {} \;
+    -exec rm -frv {} \;
   popd
 
   # Removing What's New tab from Developer Tools, usages are removed by libre.patch
diff --git a/libre/iceweasel/libre-searchengines.patch b/libre/iceweasel/libre-searchengines.patch
deleted file mode 100644
index 3efc173..0000000
--- a/libre/iceweasel/libre-searchengines.patch
+++ /dev/null
@@ -1,312 +0,0 @@
-diff --git a/browser/components/search/extensions/list.json b/browser/components/search/extensions/list.json
-index d023e0a..15ee5f5 100644
---- a/browser/components/search/extensions/list.json
-+++ b/browser/components/search/extensions/list.json
-@@ -1,53 +1,29 @@
- {
-   "default": {
--    "searchDefault": "Google",
--    "searchOrder": ["Google", "Bing"],
-     "visibleDefaultEngines": [
-       "google-b-d", "amazondotcom", "bing", "ddg", "ebay", "wikipedia"
-     ]
-   },
-   "regionOverrides": {
-     "US": {
--      "google-b-d": "google-b-1-d"
-     },
-     "CA": {
--      "ebay": "ebay-ca",
--      "ebay-fr": "ebay-ca",
--      "amazondotcom": "amazon-ca",
--      "amazon-france": "amazon-ca"
-     },
-     "AT": {
--      "ebay-de": "ebay-at"
-     },
-     "AU": {
--      "ebay": "ebay-au",
--      "ebay-uk": "ebay-au",
--      "amazondotcom": "amazon-au",
--      "amazon-en-GB": "amazon-au"
-     },
-     "BE": {
--      "ebay": "ebay-be",
--      "ebay-nl": "ebay-be",
--      "ebay-fr": "ebay-be"
-     },
-     "CH": {
--      "ebay": "ebay-ch",
--      "ebay-de": "ebay-ch",
--      "ebay-fr": "ebay-ch"
-     },
-     "FR": {
--      "amazondotcom": "amazon-france"
-     },
-     "IE": {
--      "ebay": "ebay-ie",
--      "ebay-uk": "ebay-ie"
-     },
-     "NL": {
--      "ebay": "ebay-nl"
-     },
-     "GB": {
--      "ebay": "ebay-uk",
--      "amazondotcom": "amazon-en-GB"
-     }
-   },
-   "locales": {
-@@ -56,35 +32,6 @@
-         "visibleDefaultEngines": [
-           "google-b-d", "amazondotcom", "bing", "ddg", "ebay", "wikipedia"
-         ]
--      },
--      "KZ": {
--        "visibleDefaultEngines": [
--          "amazondotcom", "bing", "google-b-d", "wikipedia", "ddg", "yandex-en"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "BY": {
--        "visibleDefaultEngines": [
--          "amazondotcom", "bing", "google-b-d", "wikipedia", "ddg", "yandex-en"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "RU": {
--        "visibleDefaultEngines": [
--          "amazondotcom", "bing", "google-b-d", "wikipedia", "ddg", "yandex-en"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "TR": {
--        "visibleDefaultEngines": [
--          "amazondotcom", "bing", "google-b-d", "wikipedia", "ddg", "yandex-en"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "experimental-hidden": {
--        "visibleDefaultEngines": [
--          "amazon-ca", "amazon-au", "yandex-en", "google", "google-b-1-e", "google-b-e"
--        ]
-       }
-     },
-     "ach": {
-@@ -141,18 +88,6 @@
-         "visibleDefaultEngines": [
-           "yandex-by", "google-b-d", "ddg", "wikipedia-be", "wikipedia-be-tarask"
-         ]
--      },
--      "BY": {
--        "searchDefault": "Яндекс"
--      },
--      "KZ": {
--        "searchDefault": "Яндекс"
--      },
--      "RU": {
--        "searchDefault": "Яндекс"
--      },
--      "TR": {
--        "searchDefault": "Яндекс"
-       }
-     },
-     "bg": {
-@@ -220,7 +155,6 @@
-     },
-     "cs": {
-       "default": {
--        "searchOrder": ["Google", "Seznam"],
-         "visibleDefaultEngines": [
-           "google-b-d", "seznam-cz", "ddg", "heureka-cz", "mapy-cz", "wikipedia-cz"
-         ]
-@@ -266,35 +200,6 @@
-         "visibleDefaultEngines": [
-           "google-b-d", "amazon-ca", "bing", "ddg", "ebay-ca", "wikipedia"
-         ]
--      },
--      "KZ": {
--        "visibleDefaultEngines": [
--          "yandex-en", "google-b-d", "amazon-ca", "bing", "ddg", "ebay-ca", "wikipedia"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "BY": {
--        "visibleDefaultEngines": [
--          "yandex-en", "google-b-d", "amazon-ca", "bing", "ddg", "ebay-ca", "wikipedia"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "RU": {
--        "visibleDefaultEngines": [
--          "yandex-en", "google-b-d", "amazon-ca", "bing", "ddg", "ebay-ca", "wikipedia"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "TR": {
--        "visibleDefaultEngines": [
--          "yandex-en", "google-b-d", "amazon-ca", "bing", "ddg", "ebay-ca", "wikipedia"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "experimental-hidden": {
--        "visibleDefaultEngines": [
--          "amazon-ca", "amazon-au", "yandex-en", "google", "google-b-1-e", "google-b-e"
--        ]
-       }
-     },
-     "en-GB": {
-@@ -302,35 +207,6 @@
-         "visibleDefaultEngines": [
-           "google-b-d", "bing", "amazon-en-GB", "chambers-en-GB", "ddg", "ebay-uk", "wikipedia"
-         ]
--      },
--      "KZ": {
--        "visibleDefaultEngines": [
--          "yandex-en", "google-b-d", "bing", "amazon-en-GB", "chambers-en-GB", "ddg", "ebay-uk", "wikipedia"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "BY": {
--        "visibleDefaultEngines": [
--          "yandex-en", "google-b-d", "bing", "amazon-en-GB", "chambers-en-GB", "ddg", "ebay-uk", "wikipedia"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "RU": {
--        "visibleDefaultEngines": [
--          "yandex-en", "google-b-d", "bing", "amazon-en-GB", "chambers-en-GB", "ddg", "ebay-uk", "wikipedia"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "TR": {
--        "visibleDefaultEngines": [
--          "yandex-en", "google-b-d", "bing", "amazon-en-GB", "chambers-en-GB", "ddg", "ebay-uk", "wikipedia"
--        ],
--        "searchDefault": "Yandex"
--      },
--      "experimental-hidden": {
--        "visibleDefaultEngines": [
--          "yandex-en"
--        ]
-       }
-     },
-     "eo": {
-@@ -397,11 +249,6 @@
-         "visibleDefaultEngines": [
-           "google-b-d", "bing", "ddg", "mercadolibre-mx", "wikipedia-es"
-         ]
--      },
--      "experimental-hidden": {
--        "visibleDefaultEngines": [
--          "amazon-mx"
--        ]
-       }
-     },
-     "et": {
-@@ -451,11 +298,6 @@
-         "visibleDefaultEngines": [
-           "google-b-d", "bing", "bolcom-fy-NL", "ddg", "ebay-nl", "marktplaats-fy-NL", "wikipedia-fy-NL"
-         ]
--      },
--      "experimental-hidden": {
--        "visibleDefaultEngines": [
--          "amazon-nl"
--        ]
-       }
-     },
-     "ga-IE": {
-@@ -565,7 +407,6 @@
-     },
-     "ja-JP-macos": {
-       "default": {
--        "searchOrder": ["Google", "Yahoo! JAPAN", "Bing", "Amazon.co.jp", "楽天市場", "ヤフオク!", "教えて！goo", "Wikipedia (ja)"],
-         "visibleDefaultEngines": [
-           "google-b-d", "yahoo-jp", "bing", "amazon-jp", "rakuten", "yahoo-jp-auctions", "oshiete-goo", "wikipedia-ja", "ddg"
-         ]
-@@ -573,7 +414,6 @@
-     },
-     "ja": {
-       "default": {
--        "searchOrder": ["Google", "Yahoo! JAPAN", "Bing", "Amazon.co.jp", "楽天市場", "ヤフオク!", "教えて！goo", "Wikipedia (ja)"],
-         "visibleDefaultEngines": [
-           "google-b-d", "yahoo-jp", "bing", "amazon-jp", "rakuten", "yahoo-jp-auctions", "oshiete-goo", "wikipedia-ja", "ddg"
-         ]
-@@ -598,18 +438,6 @@
-         "visibleDefaultEngines": [
-           "yandex-kk", "google-b-d", "ddg", "flip", "wikipedia-kk"
-         ]
--      },
--      "KZ": {
--        "searchDefault": "Яндекс"
--      },
--      "BY": {
--        "searchDefault": "Яндекс"
--      },
--      "RU": {
--        "searchDefault": "Яндекс"
--      },
--      "TR": {
--        "searchDefault": "Яндекс"
-       }
-     },
-     "km": {
-@@ -729,11 +557,6 @@
-         "visibleDefaultEngines": [
-           "google-b-d", "bing", "bolcom-nl", "ddg", "ebay-nl", "marktplaats-nl", "wikipedia-nl"
-         ]
--      },
--      "experimental-hidden": {
--        "visibleDefaultEngines": [
--          "amazon-nl"
--        ]
-       }
-     },
-     "nn-NO": {
-@@ -804,18 +627,6 @@
-         "visibleDefaultEngines": [
-           "yandex-ru", "google-b-d", "ddg", "ozonru", "priceru", "wikipedia-ru", "mailru"
-         ]
--      },
--      "RU": {
--        "searchDefault": "Яндекс"
--      },
--      "BY": {
--        "searchDefault": "Яндекс"
--      },
--      "KZ": {
--        "searchDefault": "Яндекс"
--      },
--      "TR": {
--        "searchDefault": "Яндекс"
-       }
-     },
-     "si": {
-@@ -900,18 +711,6 @@
-         "visibleDefaultEngines": [
-           "yandex-tr", "google-b-d", "ddg", "wikipedia-tr"
-         ]
--      },
--      "TR": {
--        "searchDefault": "Yandex"
--      },
--      "BY": {
--        "searchDefault": "Yandex"
--      },
--      "KZ": {
--        "searchDefault": "Yandex"
--      },
--      "RU": {
--        "searchDefault": "Yandex"
-       }
-     },
-     "trs": {
-@@ -968,9 +767,6 @@
-         "visibleDefaultEngines": [
-           "baidu", "google-b-d", "bing", "ddg", "wikipedia-zh-CN", "amazondotcn"
-         ]
--      },
--      "CN": {
--        "searchDefault": "百度"
-       }
-     },
-     "zh-TW": {
diff --git a/libre/iceweasel/vendor.js.in b/libre/iceweasel/vendor.js.in
index 2d5f1a3..d67ae2f 100644
--- a/libre/iceweasel/vendor.js.in
+++ b/libre/iceweasel/vendor.js.in
@@ -321,7 +321,3 @@ pref("extensions.getAddons.showPane", false);
 // Setting these preferences just in case and to not frustrate users.
 pref("app.normandy.api_url", "http://127.0.0.1/");
 pref("app.normandy.enabled", false);
-
-// Disable Mozilla's remote configuration of search engines
-// See https://bugzilla.mozilla.org/show_bug.cgi?id=1542235
-pref("browser.search.modernConfig", false);

From fc8db55d4a3ecefd2f749fa0b3ad0f07498b1f3f Mon Sep 17 00:00:00 2001
From: grizzlyuser <grizzlyuser@protonmail.com>
Date: Jan 05 2021 14:18:39 +0000
Subject: [PATCH 4/8] libre/iceweasel: process icons for top sites


Remove bundled icons of all websites except Wikipedia. Generate icons
and thumbnails for top sites configured by Parabola from SVG sources
from the branding package.

They need to be displayed on new tab. If not added, thumbnails will be
automatically generated for each website by completely loading it in
background and making a screenshot at start of each browser session.
This network communication can be unwanted for those on pay-per-byte
data plans.

---

diff --git a/libre/iceweasel/PKGBUILD b/libre/iceweasel/PKGBUILD
index 5d40e11..450c986 100644
--- a/libre/iceweasel/PKGBUILD
+++ b/libre/iceweasel/PKGBUILD
@@ -257,6 +257,27 @@ END
       -o "${brandingdestdir}/default$i.png"
   done
 
+  # process default Top Sites and their icons
+  local tippytopdir=browser/components/newtab/data/content/tippytop
+  find "${tippytopdir}" -type f \
+    -not -name 'wikipedia-org*' \
+    -not -name 'top_sites.json' \
+    -exec rm -v {} \;
+  for image in "${brandingsrcdir}"/tippytop/*.svg; do
+    local outname=$(basename -s .svg "${image}")
+
+    local size=$(identify -format '%wx%h' "${tippytopdir}"/images/wikipedia-org@2x.png)
+    magick -density 300 $image -gravity center -resize $size -extent $size \
+      "${tippytopdir}/images/${outname}@2x.png"
+
+    local background='none'
+    if [[ $outname == 'gnu' ]]; then background='white'; fi
+    size=256x256
+    magick -density 300 -background $background $image -gravity center \
+      -resize $size -extent $size -define icon:auto-resize=64,48,32,16 \
+      "${tippytopdir}/favicons/${outname}.ico"
+  done
+
   # apply branding patches
   export QUILT_PATCHES="${brandingsrcdir}"/patches
   export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'

From 42735187f7feaa358268264c03f8920838ec13e2 Mon Sep 17 00:00:00 2001
From: grizzlyuser <grizzlyuser@protonmail.com>
Date: Jan 05 2021 14:18:39 +0000
Subject: [PATCH 5/8] libre/iceweasel: Add JSON processing script


jq was not enough. It lacks functionality necessary to do all these
changes in one pass, like verification by JSON schemas, or automatic
unique timestamp generation for changed records.

Python script can be updated in future to support more Remote
Settings dumps, not just main/search-config and monitor/changes.

---

diff --git a/libre/iceweasel/PKGBUILD b/libre/iceweasel/PKGBUILD
index 450c986..aa726cc 100644
--- a/libre/iceweasel/PKGBUILD
+++ b/libre/iceweasel/PKGBUILD
@@ -62,8 +62,7 @@ makedepends=(unzip zip diffutils yasm mesa imake inetutils xorg-server-xvfb
              autoconf2.13 rust clang llvm jack gtk2 nodejs cbindgen nasm
              python-setuptools python-psutil python-zstandard lld)
 # FIXME: 'mozilla-serarchplugins' package needs re-working (see note in prepare())
-makedepends+=(quilt libxslt imagemagick git jq)
-makedepends+=(rust=1:1.46.0) # FIXME: FTBS with rust v1.47.0
+makedepends+=(quilt libxslt imagemagick git jq python-jsonschema)
 optdepends=('networkmanager: Location detection via available WiFi networks'
             'libnotify: Notification integration'
             'pulseaudio: Audio support'
@@ -76,8 +75,8 @@ source=(https://archive.mozilla.org/pub/firefox/releases/$pkgver/source/firefox-
         $pkgname.desktop)
 source+=(https://repo.parabola.nu/other/iceweasel/${pkgname}_${_brandingver}-${_brandingrel}.branding.tar.xz{,.sig}
          libre.patch
-         libre-searchengines.patch
          libre-0001-always-sync-remote-settings-with-local-dump.patch
+         libre-process-json-files.py
          vendor.js.in)
 source_armv7h=(arm.patch
                build-arm-libopus.patch)
@@ -351,6 +350,7 @@ END
     -e '!toolkit/crashreporter/google-breakpad/src/third_party/lss/' \
     -e '!third_party/python/**/*.egg-info/'
   rm -rf .git
+  python ../libre-process-json-files.py "$srcdir/firefox-$pkgver" "${brandingsrcdir}"
 }
 
 _check_build_config() {
diff --git a/libre/iceweasel/libre-process-json-files.py b/libre/iceweasel/libre-process-json-files.py
new file mode 100644
index 0000000..2fdde62
--- /dev/null
+++ b/libre/iceweasel/libre-process-json-files.py
@@ -0,0 +1,174 @@
+#! /usr/bin/python3
+
+#    Copyright (C) 2020  grizzlyuser <grizzlyuser@protonmail.com>
+#    Based on: https://gitlab.trisquel.org/trisquel/wrapage-helpers/-/blob/81881d89b2bf7d502dd14fcccdb471fec6f6b206/helpers/DATA/firefox/reprocess-search-config.py
+#    Below is the notice from the original author:
+#
+#    Copyright (C) 2020  Ruben Rodriguez <ruben@trisquel.info>
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+import json
+import sys
+import time
+import copy
+import argparse
+import pathlib
+from collections import namedtuple
+from jsonschema import validate
+
+parser = argparse.ArgumentParser()
+parser.add_argument(
+    'MAIN_PATH',
+    type=pathlib.Path,
+    help='path to main application source code directory')
+parser.add_argument(
+    'BRANDING_PATH',
+    type=pathlib.Path,
+    help='path to branding source code directory')
+parser.add_argument(
+    '-i',
+    '--indent',
+    type=int,
+    help='indent for pretty printing of output files')
+arguments = parser.parse_args()
+
+File = namedtuple('File', ['path', 'content'])
+
+
+class RemoteSettings:
+    DUMPS_PATH = arguments.MAIN_PATH / 'services/settings/dumps'
+    JSON_PATHS = tuple(DUMPS_PATH.glob('*/*.json'))
+    WRAPPER_NAME = 'data'
+
+    @classmethod
+    def wrap(cls, processed):
+        return File(processed.path, {cls.WRAPPER_NAME: processed.content})
+
+    @classmethod
+    def unwrap(cls, parsed_jsons):
+        return [File(json.path, json.content[cls.WRAPPER_NAME])
+                for json in parsed_jsons]
+
+    @classmethod
+    def process_raw(cls, unwrapped_jsons):
+        changes = []
+        output_path = cls.DUMPS_PATH / 'monitor/changes.json'
+
+        for collection in unwrapped_jsons:
+            if collection.path == cls.DUMPS_PATH / 'main/example.json':
+                continue
+            latest_change = {}
+            latest_change['last_modified'] = max(
+                (record['last_modified'] for record in collection.content), default=0)
+            latest_change['bucket'] = collection.path.parent.name
+            latest_change['collection'] = collection.path.stem
+            changes.append(latest_change)
+
+        output_path.parent.mkdir(exist_ok=True)
+
+        return File(output_path, changes)
+
+    @classmethod
+    def process(cls, parsed_jsons):
+        return cls.wrap(cls.process_raw(cls.unwrap(parsed_jsons)))
+
+
+class SearchConfig(RemoteSettings):
+    JSON_PATHS = (RemoteSettings.DUMPS_PATH / 'main/search-config.json',)
+
+    def _get_schema():
+        PATH = arguments.MAIN_PATH / \
+            'toolkit/components/search/schema/search-engine-config-schema.json'
+        with PATH.open() as file:
+            return json.load(file)
+
+    @classmethod
+    def process_raw(cls, unwrapped_jsons):
+        _WHITELIST = ('ddg@search.mozilla.org', 'wikipedia@search.mozilla.org')
+        SCHEMA = cls._get_schema()
+
+        search_engines, timestamps = [], []
+        search_config = unwrapped_jsons[0]
+
+        for search_engine in search_config.content:
+            if search_engine['webExtension']['id'] in _WHITELIST:
+                clone = copy.deepcopy(search_engine)
+
+                if 'telemetryId' in search_engine:
+                    del search_engine['telemetryId']
+                if 'extraParams' in search_engine:
+                    del search_engine['extraParams']
+
+                general_specifier = {}
+                for specifier in search_engine['appliesTo'].copy():
+                    if 'application' in specifier:
+                        if 'distributions' in specifier['application']:
+                            search_engine['appliesTo'].remove(specifier)
+                            continue
+                        if 'extraParams' in specifier['application']:
+                            del specifier['application']['extraParams']
+
+                    if 'included' in specifier and 'everywhere' in specifier[
+                            'included'] and specifier['included']['everywhere']:
+                        general_specifier = specifier
+
+                if not general_specifier:
+                    general_specifier = {'included': {'everywhere': True}}
+                    search_engine['appliesTo'].insert(0, general_specifier)
+                if search_engine['webExtension']['id'] == _WHITELIST[0]:
+                    general_specifier['default'] = 'yes'
+
+                if clone != search_engine:
+                    timestamp = int(round(time.time_ns() / 10 ** 6))
+                    while timestamp in timestamps:
+                        timestamp += 1
+                    timestamps.append(timestamp)
+                    search_engine['last_modified'] = timestamp
+
+                validate(search_engine, schema=SCHEMA)
+
+                search_engines.append(search_engine)
+
+        return File(search_config.path, search_engines)
+
+
+class TopSites:
+    JSON_PATHS = (
+        arguments.MAIN_PATH /
+        'browser/components/newtab/data/content/tippytop/top_sites.json',
+        arguments.BRANDING_PATH /
+        'tippytop/top_sites.json')
+
+    @classmethod
+    def process(cls, parsed_jsons):
+        main_top_sites = parsed_jsons[0]
+        branding_top_sites = parsed_jsons[1]
+        result = branding_top_sites.content + \
+            [site for site in main_top_sites.content if site['title'] == 'wikipedia']
+        return File(main_top_sites.path, result)
+
+
+processors = (SearchConfig, TopSites, RemoteSettings)
+
+for processor in processors:
+    parsed_jsons = []
+    for json_path in processor.JSON_PATHS:
+        with json_path.open() as file:
+            parsed_jsons.append(File(json_path, json.load(file)))
+
+    processed = processor.process(parsed_jsons)
+    with processed.path.open('w') as file:
+        json.dump(processed.content, file, indent=arguments.indent)

From d29e2144752ff5bbcb3760d6588cefeee3199f5c Mon Sep 17 00:00:00 2001
From: grizzlyuser <grizzlyuser@protonmail.com>
Date: Jan 05 2021 14:18:39 +0000
Subject: [PATCH 6/8] libre/iceweasel: Redone libre.patch


Remove patching of links to mobile apps from about:logins page, dropped
upstream [1]. Add patching of banners to mobile apps on
about:protections page.

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1668965

---

diff --git a/libre/iceweasel/libre.patch b/libre/iceweasel/libre.patch
index c4e9a44..124ff00 100644
--- a/libre/iceweasel/libre.patch
+++ b/libre/iceweasel/libre.patch
@@ -291,229 +291,97 @@ index 4c4ea76..e0f2880 100644
 -gecko.handlerService.schemes.ircs.0.name=Mibbit
 -gecko.handlerService.schemes.ircs.0.uriTemplate=https://www.mibbit.com/?url=%s
 diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js
-index cd9bc92969..e35c951e67 100644
+index 2588a53cf2..e818b254d2 100644
 --- a/browser/app/profile/firefox.js
 +++ b/browser/app/profile/firefox.js
-@@ -1639,10 +1639,6 @@ pref("browser.contentblocking.report.monitor.home_page_url", "https://monitor.fi
+@@ -1726,15 +1726,15 @@ pref("browser.contentblocking.report.monitor.enabled", true);
+ pref("browser.contentblocking.report.proxy.enabled", false);
+ 
+ // Disable the mobile promotion by default.
+-pref("browser.contentblocking.report.show_mobile_app", true);
++pref("browser.contentblocking.report.show_mobile_app", false);
+ 
+ // Enable the vpn card by default.
+-pref("browser.contentblocking.report.vpn.enabled", true);
++pref("browser.contentblocking.report.vpn.enabled", false);
+ // Only show vpn card to certain regions. Comma separated string of two letter ISO 3166-1 country codes.
+ pref("browser.contentblocking.report.vpn_regions", "us,ca,nz,sg,my,gb");
+ // Comma separated string of mozilla vpn supported platforms.
+ pref("browser.contentblocking.report.vpn_platforms", "win");
+-pref("browser.contentblocking.report.hide_vpn_banner", false);
++pref("browser.contentblocking.report.hide_vpn_banner", true);
+ pref("browser.contentblocking.report.vpn_sub_id", "sub_HrfCZF7VPHzZkA");
+ 
+ pref("browser.contentblocking.report.monitor.url", "https://monitor.firefox.com/?entrypoint=protection_report_monitor&utm_source=about-protections");
+@@ -1745,12 +1745,12 @@ pref("browser.contentblocking.report.monitor.home_page_url", "https://monitor.fi
  pref("browser.contentblocking.report.manage_devices.url", "https://accounts.firefox.com/settings/clients");
  pref("browser.contentblocking.report.endpoint_url", "https://monitor.firefox.com/user/breach-stats?includeResolved=true");
  pref("browser.contentblocking.report.proxy_extension.url", "https://fpn.firefox.com/browser?utm_source=firefox-desktop&utm_medium=referral&utm_campaign=about-protections&utm_content=about-protections");
--pref("browser.contentblocking.report.lockwise.mobile-ios.url", "https://apps.apple.com/app/id1314000270");
--pref("browser.contentblocking.report.lockwise.mobile-android.url", "https://play.google.com/store/apps/details?id=mozilla.lockbox&referrer=utm_source%3Dprotection_report%26utm_content%3Dmobile_promotion");
 -pref("browser.contentblocking.report.mobile-ios.url", "https://apps.apple.com/app/firefox-private-safe-browser/id989804926");
 -pref("browser.contentblocking.report.mobile-android.url", "https://play.google.com/store/apps/details?id=org.mozilla.firefox&referrer=utm_source%3Dprotection_report%26utm_content%3Dmobile_promotion");
+-pref("browser.contentblocking.report.vpn.url", "https://vpn.mozilla.org/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign=about-protections-card");
+-pref("browser.contentblocking.report.vpn-promo.url", "https://vpn.mozilla.org/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_campaign=about-protections-top-promo");
+-pref("browser.contentblocking.report.vpn-android.url", "https://play.google.com/store/apps/details?id=org.mozilla.firefox.vpn&referrer=utm_source%3Dfirefox-browser%26utm_medium%3Dfirefox-browser%26utm_campaign%3Dabout-protections-mobile-vpn%26anid%3D--");
+-pref("browser.contentblocking.report.vpn-ios.url", "https://apps.apple.com/us/app/firefox-private-network-vpn/id1489407738");
++pref("browser.contentblocking.report.mobile-ios.url", "");
++pref("browser.contentblocking.report.mobile-android.url", "");
++pref("browser.contentblocking.report.vpn.url", "");
++pref("browser.contentblocking.report.vpn-promo.url", "");
++pref("browser.contentblocking.report.vpn-android.url", "");
++pref("browser.contentblocking.report.vpn-ios.url", "");
  
  // Protection Report's SUMO urls
  pref("browser.contentblocking.report.lockwise.how_it_works.url", "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/password-manager-report");
-@@ -1774,11 +1770,6 @@ pref("signon.management.page.os-auth.enabled", false);
- pref("signon.management.page.breach-alerts.enabled", true);
- pref("signon.management.page.vulnerable-passwords.enabled", true);
- pref("signon.management.page.sort", "name");
--// The utm_creative value is appended within the code (specific to the location on
--// where it is clicked). Be sure that if these two prefs are updated, that
--// the utm_creative param be last.
--pref("signon.management.page.mobileAndroidURL", "https://app.adjust.com/6tteyjo?redirect=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dmozilla.lockbox&utm_campaign=Desktop&utm_adgroup=InProduct&utm_creative=");
--pref("signon.management.page.mobileAppleURL", "https://app.adjust.com/6tteyjo?redirect=https%3A%2F%2Fitunes.apple.com%2Fapp%2Fid1314000270%3Fmt%3D8&utm_campaign=Desktop&utm_adgroup=InProduct&utm_creative=");
- pref("signon.management.page.breachAlertUrl",
-      "https://monitor.firefox.com/breach-details/");
- pref("signon.management.page.hideMobileFooter", false);
-diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm
-index 5bc3a4b6c2..afc8d388e2 100644
---- a/browser/components/BrowserGlue.jsm
-+++ b/browser/components/BrowserGlue.jsm
-@@ -85,8 +85,6 @@ let ACTORS = {
-         AboutLoginsImport: { wantUntrusted: true },
-         AboutLoginsInit: { wantUntrusted: true },
-         AboutLoginsGetHelp: { wantUntrusted: true },
--        AboutLoginsOpenMobileAndroid: { wantUntrusted: true },
--        AboutLoginsOpenMobileIos: { wantUntrusted: true },
-         AboutLoginsOpenPreferences: { wantUntrusted: true },
-         AboutLoginsOpenSite: { wantUntrusted: true },
-         AboutLoginsRecordTelemetryEvent: { wantUntrusted: true },
-diff --git a/browser/components/aboutlogins/AboutLoginsChild.jsm b/browser/components/aboutlogins/AboutLoginsChild.jsm
-index a4cd976dd5..c24b42eed0 100644
---- a/browser/components/aboutlogins/AboutLoginsChild.jsm
-+++ b/browser/components/aboutlogins/AboutLoginsChild.jsm
-@@ -120,18 +120,6 @@ class AboutLoginsChild extends JSWindowActorChild {
-         this.sendAsyncMessage("AboutLogins:Import");
-         break;
-       }
--      case "AboutLoginsOpenMobileAndroid": {
--        this.sendAsyncMessage("AboutLogins:OpenMobileAndroid", {
--          source: event.detail,
--        });
--        break;
--      }
--      case "AboutLoginsOpenMobileIos": {
--        this.sendAsyncMessage("AboutLogins:OpenMobileIos", {
--          source: event.detail,
--        });
--        break;
--      }
-       case "AboutLoginsOpenPreferences": {
-         this.sendAsyncMessage("AboutLogins:OpenPreferences");
-         break;
-diff --git a/browser/components/aboutlogins/AboutLoginsParent.jsm b/browser/components/aboutlogins/AboutLoginsParent.jsm
-index 81141c342a..724369962b 100644
---- a/browser/components/aboutlogins/AboutLoginsParent.jsm
-+++ b/browser/components/aboutlogins/AboutLoginsParent.jsm
-@@ -286,31 +286,6 @@ class AboutLoginsParent extends JSWindowActorParent {
-         });
-         break;
-       }
--      case "AboutLogins:OpenMobileAndroid": {
--        const MOBILE_ANDROID_URL_PREF =
--          "signon.management.page.mobileAndroidURL";
--        const linkTrackingSource = message.data.source;
--        let MOBILE_ANDROID_URL = Services.prefs.getStringPref(
--          MOBILE_ANDROID_URL_PREF
--        );
--        // Append the `utm_creative` query parameter value:
--        MOBILE_ANDROID_URL += linkTrackingSource;
--        ownerGlobal.openWebLinkIn(MOBILE_ANDROID_URL, "tab", {
--          relatedToCurrent: true,
--        });
--        break;
--      }
--      case "AboutLogins:OpenMobileIos": {
--        const MOBILE_IOS_URL_PREF = "signon.management.page.mobileAppleURL";
--        const linkTrackingSource = message.data.source;
--        let MOBILE_IOS_URL = Services.prefs.getStringPref(MOBILE_IOS_URL_PREF);
--        // Append the `utm_creative` query parameter value:
--        MOBILE_IOS_URL += linkTrackingSource;
--        ownerGlobal.openWebLinkIn(MOBILE_IOS_URL, "tab", {
--          relatedToCurrent: true,
--        });
--        break;
--      }
-       case "AboutLogins:OpenPreferences": {
-         ownerGlobal.openPreferences("privacy-logins");
-         break;
-diff --git a/browser/components/aboutlogins/content/aboutLogins.html b/browser/components/aboutlogins/content/aboutLogins.html
-index 33c380a898..fdc1ccb38c 100644
---- a/browser/components/aboutlogins/content/aboutLogins.html
-+++ b/browser/components/aboutlogins/content/aboutLogins.html
-@@ -274,9 +274,6 @@
-         <button role="menuitem" class="menuitem-button menuitem-preferences ghost-button" data-event-name="AboutLoginsOpenPreferences" data-l10n-id="menu-menuitem-preferences"></button>
-         <hr role="separator" class="menuitem-separator"></hr>
-         <button role="menuitem" class="menuitem-button menuitem-help ghost-button" data-event-name="AboutLoginsGetHelp" data-l10n-id="about-logins-menu-menuitem-help"></button>
--        <hr role="separator" class="menuitem-separator"></hr>
--        <button role="menuitem" class="menuitem-button menuitem-mobile menuitem-mobile-android ghost-button" data-event-name="AboutLoginsOpenMobileAndroid" data-l10n-id="menu-menuitem-android-app"></button>
--        <button role="menuitem" class="menuitem-button menuitem-mobile menuitem-mobile-ios ghost-button" data-event-name="AboutLoginsOpenMobileIos" data-l10n-id="menu-menuitem-iphone-app"></button>
-       </ul>
-     </template>
+diff --git a/browser/components/protections/content/protections.ftl b/browser/components/protections/content/protections.ftl
+index 5ac8a7b08c..fec81698e3 100644
+--- a/browser/components/protections/content/protections.ftl
++++ b/browser/components/protections/content/protections.ftl
+@@ -18,7 +18,7 @@ get-vpn-link = Get { -mozilla-vpn-brand-name }
+ 
+ vpn-title-subscribed = VPN: Subscribed
+ # Note This text is not being translated, and the <br> will need to be removed if or when it does get translated
+-vpn-header-content-subscribed = Using the { -mozilla-vpn-brand-name } encrypts all your traffic and hides your location — on up to 5 devices. Get the most from your subscription — add it from <br> the <a data-l10n-name="vpn-google-playstore-link">Google Play Store</a> or <a data-l10n-name="vpn-app-store-link">Apple App Store</a>.
++vpn-header-content-subscribed = Using the { -mozilla-vpn-brand-name } encrypts all your traffic and hides your location — on up to 5 devices.
  
+ vpn-banner-header = Protection that extends beyond the browser
+ # Note This text is not being translated, and the <br> will need to be removed if or when it does get translated
 diff --git a/browser/components/protections/content/protections.html b/browser/components/protections/content/protections.html
-index e7aac37ed6..164a07988d 100644
+index e33c814f62..5698f2b3e9 100644
 --- a/browser/components/protections/content/protections.html
 +++ b/browser/components/protections/content/protections.html
-@@ -115,24 +115,6 @@
-             <div id="graph-total-summary"></div>
-           </div>
-         </div>
--        <div id="mobile-hanger" class="card-body hidden">
--          <div class="body-wrapper">
--            <button class="exit-icon" data-l10n-id="protections-close-button2"></button>
--            <div id="etp-mobile-content">
--              <img class="mobile-app-icon" src="chrome://browser/content/logos/etp-mobile.svg"/>
--              <span>
--                <h2 class="card-title" data-l10n-id="mobile-app-title"></h2>
--                <p class="content">
--                  <span data-l10n-id="mobile-app-card-content"></span>
--                  <span target="_blank" id="mobile-app-links" data-l10n-id="mobile-app-links">
--                    <a target="_blank" id="android-mobile-inline-link" data-l10n-name="android-mobile-inline-link" href=""></a>
--                    <a target="_blank" id="ios-mobile-inline-link" data-l10n-name="ios-mobile-inline-link" href=""></a>
--                  </span>
--                </p>
--              </span>
--            </div>
--          </div>
--        </div>
-       </div>
-      <!-- Markup for Monitor card. -->
-       <section class="card card-no-hover monitor-card hidden">
-@@ -256,20 +238,6 @@
-         </div>
-         <div class="card-body hidden">
-           <div id="lockwise-body-content" class="body-wrapper">
--            <div class="no-logins hidden">
--              <button class="exit-icon" data-l10n-id="protections-close-button2"></button>
--              <img class="mobile-app-icon" src="chrome://browser/content/logos/lockwise-mobile.svg"/>
--              <span>
--                <h2 class="card-title" data-l10n-id="lockwise-mobile-app-title"></h2>
--                <p class="content">
--                  <span data-l10n-id="lockwise-no-logins-card-content"></span>
--                  <span target="_blank" id="lockwise-app-links" data-l10n-id="lockwise-app-links" href="">
--                    <a id="lockwise-android-inline-link" target="_blank" data-l10n-name="lockwise-android-inline-link"></a>
--                    <a id="lockwise-ios-inline-link" target="_blank" data-l10n-name="lockwise-ios-inline-link"></a>
--                  </span>
--                </p>
--              </span>
--            </div>
-           </div>
-         </div>
-       </section>
-diff --git a/browser/locales/en-US/browser/aboutLogins.ftl b/browser/locales/en-US/browser/aboutLogins.ftl
-index 03feeef059..f9580d0f8f 100644
---- a/browser/locales/en-US/browser/aboutLogins.ftl
-+++ b/browser/locales/en-US/browser/aboutLogins.ftl
-@@ -35,8 +35,6 @@ menu-menuitem-preferences =
-      *[other] Preferences
-   }
- about-logins-menu-menuitem-help = Help
--menu-menuitem-android-app = { -lockwise-brand-short-name } for Android
--menu-menuitem-iphone-app = { -lockwise-brand-short-name } for iPhone and iPad
- 
- ## Login List
- 
-diff --git a/devtools/client/definitions.js b/devtools/client/definitions.js
-index 5cd41b3e36..ba6b2bc4d8 100644
---- a/devtools/client/definitions.js
-+++ b/devtools/client/definitions.js
-@@ -73,11 +73,6 @@ loader.lazyGetter(
-   "ApplicationPanel",
-   () => require("devtools/client/application/panel").ApplicationPanel
- );
--loader.lazyGetter(
--  this,
--  "WhatsNewPanel",
--  () => require("devtools/client/whats-new/panel").WhatsNewPanel
--);
- 
- // Other dependencies
- loader.lazyRequireGetter(
-@@ -529,7 +524,6 @@ var defaultTools = [
-   Tools.dom,
-   Tools.accessibility,
-   Tools.application,
--  Tools.whatsnew,
- ];
- 
- exports.defaultTools = defaultTools;
-diff --git a/devtools/client/jar.mn b/devtools/client/jar.mn
-index af42ded2ae..86cf0a650f 100644
---- a/devtools/client/jar.mn
-+++ b/devtools/client/jar.mn
-@@ -367,10 +367,6 @@ devtools.jar:
-     content/application/src/components/service-workers/Worker.css (application/src/components/service-workers/Worker.css)
-     content/application/src/components/ui/UIButton.css (application/src/components/ui/UIButton.css)
-
--    # WhatsNew panel
--    content/whats-new/index.html (whats-new/index.html)
--    content/whats-new/src/whats-new.css (whats-new/src/whats-new.css)
--
-     # about:profiling
-     skin/aboutprofiling.css (themes/aboutprofiling.css)
-     content/performance-new/aboutprofiling/initializer.js (performance-new/aboutprofiling/initializer.js)
-diff --git a/devtools/client/moz.build b/devtools/client/moz.build
-index 0dd219c13c..b589c7ac4d 100644
---- a/devtools/client/moz.build
-+++ b/devtools/client/moz.build
-@@ -28,7 +28,6 @@ DIRS += [
-     'styleeditor',
-     'themes',
-     'webconsole',
--    'whats-new',
- ]
+@@ -303,8 +303,6 @@
+               </div>
+               <p class="content" data-l10n-id="vpn-header-content"></p>
+               <p class="content subscribed" data-l10n-id="vpn-header-content-subscribed">
+-                <a target="_blank" id="vpn-google-playstore-link" data-l10n-name="vpn-google-playstore-link"></a>
+-                <a target="_blank" id="vpn-app-store-link" data-l10n-name="vpn-app-store-link"></a>
+               </p>
+             </div>
+             <a target="_blank" id="get-vpn-link" data-l10n-id="get-vpn-link"></a>
+diff --git a/browser/components/protections/content/vpn-card.js b/browser/components/protections/content/vpn-card.js
+index 2417f1a641..698c48ccc3 100644
+--- a/browser/components/protections/content/vpn-card.js
++++ b/browser/components/protections/content/vpn-card.js
+@@ -23,22 +23,6 @@ export default class VPNCard {
+     vpnLink.addEventListener("click", () => {
+       this.doc.sendTelemetryEvent("click", "vpn_card_link");
+     });
+-    let androidVPNAppLink = document.getElementById(
+-      "vpn-google-playstore-link"
+-    );
+-    androidVPNAppLink.href = RPMGetStringPref(
+-      "browser.contentblocking.report.vpn-android.url"
+-    );
+-    androidVPNAppLink.addEventListener("click", () => {
+-      document.sendTelemetryEvent("click", "vpn_app_link_android");
+-    });
+-    let iosVPNAppLink = document.getElementById("vpn-app-store-link");
+-    iosVPNAppLink.href = RPMGetStringPref(
+-      "browser.contentblocking.report.vpn-ios.url"
+-    );
+-    iosVPNAppLink.addEventListener("click", () => {
+-      document.sendTelemetryEvent("click", "vpn_app_link_ios");
+-    });
  
- JAR_MANIFESTS += ['jar.mn']
+     const vpnBanner = this.doc.querySelector(".vpn-banner");
+     const exitIcon = vpnBanner.querySelector(".exit-icon");

From 3917b805b2b840adafef1f0f076adb8d7415773d Mon Sep 17 00:00:00 2001
From: grizzlyuser <grizzlyuser@protonmail.com>
Date: Jan 05 2021 14:18:39 +0000
Subject: [PATCH 7/8] libre/iceweasel: checksums; move git clean step


git clean step needed to be moved, IIRC because some to-be-removed files
interfered with Remote Settings patching check.

---

diff --git a/libre/iceweasel/PKGBUILD b/libre/iceweasel/PKGBUILD
index aa726cc..e3375d2 100644
--- a/libre/iceweasel/PKGBUILD
+++ b/libre/iceweasel/PKGBUILD
@@ -84,18 +84,16 @@ source_i686=('avoid-libxul-OOM-python-check.patch'
              'rust-static-disable-network-test-on-static-libraries.patch')
 sha256sums=('ae5500d270a199f9a10674fbd4ba7a6beac1f260a4c009bbca8ea39967592243'
             'SKIP'
-            'e0eaec8ddd24bbebf4956563ebc6d7a56f8dada5835975ee4d320dd3d0c9c442'
-            'c2489a4ad3bfb65c064e07180a1de9a2fbc3b1b72d6bc4cd3985484d1b6b7b29'
-            '52cc26cda4117f79fae1a0ad59e1404b299191a1c53d38027ceb178dab91f3dc'
-            '2ffa37306bf8e5d79e074e612f88b6f3f671c45215724f84dd85cbea8b91e6bd'
+            '8b236bbf3ae5cb28d1dd742f543c0079fac06af5aa80bc2051defeba95f0ae21'
             '44be8e819b8334ed36e9410d62dbc6c16dd8f8329a191403bfdce3cf2e9181fc'
-            '228b7d316ab6836a6e69aa7070033b1ae073f3579474a49d8c306702b1c1413e'
+            'faf0faa5cc318515880e1c9854938f73e586b590c9696e95db323eea65d67a77'
             'SKIP'
-            '5cfcadbd168c52b1b1e3f2f2c45911a4ae1a9d8a05918be68475a31985607bd8'
-            '0ed6b8efa00f73a96bceaba2d6a31fb11d416106729ab9b8289b191eb9acccfa'
-            '0ace0929a7487bd3d464a432e9be643a8f62d135cdfc1b4b2c55846aee8c04dc')
-sha256sums_i686=('80b6461579398398c28f9b72b0c55220f261d9bf6c5a253e3bc66dc8a65131f6'
-                 'e661665ee00ecec66c33e115b0af3474452022f0d8ceda634a6315dc8cb99014')
+            'e4fc091da84f75f701e1f3e336a8d42b746075caf7cb5f23dbb4d8fdd0ac4708'
+            '926082110e92bdc8ca53b930f4717a5294b64f6ebcc4d22d46d97088c5e862f0'
+            'e9d1b74971d58c5b860601bd8c0c11df332dab8be2f61f5d238ba50a5c4efdde'
+            '714998c5fc379f54a66ff80a845b7880169cd5b4094b77b719a99d33b65c0940')
+sha256sums_i686=('2f0c81a38c4578f68f5456b618fe84a78974072821488173eb55e0e72287e353'
+                 'a9c49222de0423b52a0c60965ace4a0793807c9aba18c21a79bd290690e91892')
 sha256sums_armv7h=('bc00516032330760444939c516a60c78f868631e1b37f075f0fe71a53737b966'
                    '2d4d91f7e35d0860225084e37ec320ca6cae669f6c9c8fe7735cdbd542e3a7c9')
 validpgpkeys=('14F26682D0916CDD81E37B6D61B7B526D98F0353') # Mozilla Software Releases <release@mozilla.com>
@@ -284,10 +282,18 @@ END
   export QUILT_PC=$srcdir/.pc
   quilt push -av
 
-
   ## libre patching ##
 
   # Remove remaining non-free bits
+  # Upstream tarball can contain some ignored cruft,
+  # including binaries (for example, python3).
+  echo 'Removing files specified in .gitignore...'
+  git init && git clean -dfX \
+    -e '!ipc/chromium/src/third_party/libevent/evconfig-private.h' \
+    -e '!toolkit/crashreporter/google-breakpad/src/third_party/lss/' \
+    -e '!third_party/python/**/*.egg-info/'
+  rm -rf .git
+
   # Remove test-related networking dumps, because they contain code from
   # some Amazon webpage with no clear licensing, thus nonfree.
   # Also they interfere with checking of Remote Settings patching done later,
@@ -339,17 +345,6 @@ END
     -exec rm -frv {} \;
   popd
 
-  # Removing What's New tab from Developer Tools, usages are removed by libre.patch
-  rm -rf devtools/client/whats-new
-
-  # Upstream tarball can contain some ignored cruft,
-  # including binaries (for example, python3).
-  echo 'Removing files specified in .gitignore...'
-  git init && git clean -dfX \
-    -e '!ipc/chromium/src/third_party/libevent/evconfig-private.h' \
-    -e '!toolkit/crashreporter/google-breakpad/src/third_party/lss/' \
-    -e '!third_party/python/**/*.egg-info/'
-  rm -rf .git
   python ../libre-process-json-files.py "$srcdir/firefox-$pkgver" "${brandingsrcdir}"
 }
 

From 1345332c763a1dc67e9b1d71389ab268406ac355 Mon Sep 17 00:00:00 2001
From: grizzlyuser <grizzlyuser@protonmail.com>
Date: Jan 06 2021 11:35:03 +0000
Subject: [PATCH 8/8] libre/iceweasel: 84.0.2-1.parabola1


---

diff --git a/libre/iceweasel/PKGBUILD b/libre/iceweasel/PKGBUILD
index e3375d2..936085a 100644
--- a/libre/iceweasel/PKGBUILD
+++ b/libre/iceweasel/PKGBUILD
@@ -47,7 +47,7 @@
 
 pkgname=iceweasel
 epoch=1
-pkgver=84.0.1
+pkgver=84.0.2
 pkgrel=1
 pkgrel+=.parabola1
 _brandingver=84.0
@@ -82,7 +82,7 @@ source_armv7h=(arm.patch
                build-arm-libopus.patch)
 source_i686=('avoid-libxul-OOM-python-check.patch'
              'rust-static-disable-network-test-on-static-libraries.patch')
-sha256sums=('ae5500d270a199f9a10674fbd4ba7a6beac1f260a4c009bbca8ea39967592243'
+sha256sums=('92bfd518d4f9760c897388a8e06130b171c1c43524d8af181add9daac2be7b37'
             'SKIP'
             '8b236bbf3ae5cb28d1dd742f543c0079fac06af5aa80bc2051defeba95f0ae21'
             '44be8e819b8334ed36e9410d62dbc6c16dd8f8329a191403bfdce3cf2e9181fc'

