From f09bd59b0434323aa2c47f588e30e2088feff236 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 10 Sep 2024 12:00:02 +0530 Subject: [PATCH 1/4] Browser: add support to build ruleset_converter --- .gitignore | 1 + .gitlab-ci.yml | 1 + build.sh | 12 ++++++++++ build/filters.gn_args | 7 ++++++ build_subresource_filter_tools.sh | 39 +++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 build/filters.gn_args create mode 100755 build_subresource_filter_tools.sh diff --git a/.gitignore b/.gitignore index ce24e63b..84c0539c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ src/ apks/ +bin/ _gclient_src*/ .ccache/ .cipd/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4fc43f02..6b53b4e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,6 +29,7 @@ build-docker: name: "$CI_JOB_NAME" paths: - apks/* + - bin/* build-cromite-arm: stage: build diff --git a/build.sh b/build.sh index 4a8f8c36..1c5daf68 100755 --- a/build.sh +++ b/build.sh @@ -99,6 +99,18 @@ build() { echo ">> [$(date)] Creating archive with debug apks" archive_name="${root_dir}/apks/${apk_arch}/browser_${apk_arch}_debug_apks.7z" 7z a -t7z -mx=9 "$archive_name" "out/${1}/apks"/*.apk + + if [ $1 '==' "x64" ]; then + echo ">> [$(date)] Building chromium subresource_filter_tools" + mkdir -p "${root_dir}/bin" + build_args=$(cat "${root_dir}"/build/filters.gn_args) + build_args+=' cc_wrapper="ccache"' + gn gen out/${1} --args="$build_args" + autoninja -C out/${1} subresource_filter_tools + if [ -f "out/${1}/ruleset_converter" ]; then + cp -r out/${1}/ruleset_converter ${root_dir}/bin/ruleset_converter + fi + fi } setup_ccache() { diff --git a/build/filters.gn_args b/build/filters.gn_args new file mode 100644 index 00000000..3313db3d --- /dev/null +++ b/build/filters.gn_args @@ -0,0 +1,7 @@ +target_cpu="x64" +target_os="linux" +enable_nacl=false +is_component_build=false +is_debug=false +blink_symbol_level=0 +enable_reporting=false diff --git a/build_subresource_filter_tools.sh b/build_subresource_filter_tools.sh new file mode 100755 index 00000000..a33067a8 --- /dev/null +++ b/build_subresource_filter_tools.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e + +chromium_dir="${CHROMIUM_DIR}" +root_dir=$(dirname "$(readlink -f "$0")") +if [ ! -d "$chromium_dir" ]; then + chromium_dir=$root_dir +fi + +build() { + echo ">> [$(date)] Building chromium subresource_filter_tools" + mkdir -p "${root_dir}/bin" + build_args=$(cat "${root_dir}"/build/filters.gn_args) + build_args+=' cc_wrapper="ccache"' + gn gen out/x64 --args="$build_args" + autoninja -C out/x64 subresource_filter_tools + if [ -f "out/x64/ruleset_converter" ]; then + cp -r out/x64/ruleset_converter ${root_dir}/bin/ruleset_converter + fi +} + +setup_ccache() { + echo ">> [$(date)] Settings up ccache" + export USE_CCACHE=1 + export CCACHE_EXEC=$(command -v ccache) + export PATH=$chromium_dir/src/third_party/llvm-build/Release+Asserts/bin:$PATH + export CCACHE_CPP2=yes + export CCACHE_SLOPPINESS=time_macros + export CCACHE_DIR=$chromium_dir/.ccache + ccache -M 200G +} + +export PATH="$chromium_dir/depot_tools:$PATH" + +cd $chromium_dir/src +. build/android/envsetup.sh +setup_ccache +build -- GitLab From f9110ccdb4a154afef1b4481fd9a740c6248aa83 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 10 Sep 2024 12:03:21 +0530 Subject: [PATCH 2/4] Browser: format script --- build.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 1c5daf68..c4fa1abc 100755 --- a/build.sh +++ b/build.sh @@ -204,7 +204,7 @@ sync() { } gclient_config() { - cat < "$chromium_dir/.gclient" + cat <"$chromium_dir/.gclient" solutions = [{ "url": "$chromium_url@$chromium_commit_hash", "managed": False, @@ -217,7 +217,7 @@ target_os = ["android"] EOF } -init_repo(){ +init_repo() { echo ">> [$(date)] Init chromium $chromium_version" cd $chromium_dir rm -rf .gclient* @@ -233,7 +233,7 @@ while getopts ":a:cur:shp" opt; do a) arch="$OPTARG" ;; c) clean=1 ;; u) usage ;; - s) gsync=1 ;; + s) gsync=1 ;; h) history=0 ;; p) patchonly=1 ;; :) @@ -275,9 +275,9 @@ if [ $gsync -eq 1 ]; then cd $chromium_dir/src # Check if a rebase is in progress if [ -d "$(git rev-parse --git-dir)/rebase-apply" ] || [ -d "$(git rev-parse --git-dir)/rebase-merge" ]; then - git am --skip 2>/dev/null || true - git rebase --abort 2>/dev/null || true - echo ">> [$(date)] Rebase aborted." + git am --skip 2>/dev/null || true + git rebase --abort 2>/dev/null || true + echo ">> [$(date)] Rebase aborted." fi find ".git" -name "*.lock" -delete if [ ! -z $(find .git -name "*.lock") ]; then -- GitLab From a212729c0d1ca8f990345a4dc7652d5690c1e93d Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 10 Sep 2024 12:19:17 +0530 Subject: [PATCH 3/4] Browser: Block using bromite filter - Use our url --- ...1-Browser-Change-adblock-url-to-ours.patch | 85 +++++++++++++++++++ build/e_patches_list.txt | 1 + 2 files changed, 86 insertions(+) create mode 100644 build/e_patches/0001-Browser-Change-adblock-url-to-ours.patch diff --git a/build/e_patches/0001-Browser-Change-adblock-url-to-ours.patch b/build/e_patches/0001-Browser-Change-adblock-url-to-ours.patch new file mode 100644 index 00000000..28564aac --- /dev/null +++ b/build/e_patches/0001-Browser-Change-adblock-url-to-ours.patch @@ -0,0 +1,85 @@ +From 9a9eda608ee4cf68f82f5d8060b4df134efa34fc Mon Sep 17 00:00:00 2001 +From: althafvly +Date: Tue, 10 Sep 2024 12:17:23 +0530 +Subject: [PATCH] Browser: Change adblock url to ours + +--- + chrome/android/java/res/values/values.xml | 2 +- + .../chromium/chrome/browser/settings/AdBlockEditor.java | 8 ++++++++ + chrome/browser/browser_process_impl.cc | 9 ++++++++- + chrome/browser/net/system_network_context_manager.cc | 2 +- + 4 files changed, 18 insertions(+), 3 deletions(-) + +diff --git a/chrome/android/java/res/values/values.xml b/chrome/android/java/res/values/values.xml +index 3b318d09034f4..09f051950404c 100644 +--- a/chrome/android/java/res/values/values.xml ++++ b/chrome/android/java/res/values/values.xml +@@ -24,7 +24,7 @@ found in the LICENSE file. + + Autoupdate enabled + Autoupdate disabled +- https://www.bromite.org/custom-filters ++ https://doc.e.foundation/browser-custom-filters + + Proxy configuration + chrome://proxy +diff --git a/chrome/android/java/src/org/chromium/chrome/browser/settings/AdBlockEditor.java b/chrome/android/java/src/org/chromium/chrome/browser/settings/AdBlockEditor.java +index ef6d1652c97f0..24cd56084827d 100644 +--- a/chrome/android/java/src/org/chromium/chrome/browser/settings/AdBlockEditor.java ++++ b/chrome/android/java/src/org/chromium/chrome/browser/settings/AdBlockEditor.java +@@ -37,6 +37,14 @@ public class AdBlockEditor extends Fragment implements TextWatcher { + View scrollView = v.findViewById(R.id.scroll_view); + scrollView.getViewTreeObserver().addOnScrollChangedListener( + SettingsUtils.getShowShadowOnScrollListener(v, v.findViewById(R.id.shadow))); ++ ++ String defaultBromiteURL = "https://www.bromite.org/filters/filters.dat"; ++ if (defaultBromiteURL.equals(AdBlockNativeGateway.getAdBlockFiltersURL())) { ++ String newFiltersURL = "https://images.ecloud.global/apps/browser/filters.dat"; ++ AdBlockNativeGateway.setAdBlockFiltersURL( ++ UrlFormatter.fixupUrl(newFiltersURL).getSpec()); ++ } ++ + mAdBlockFiltersUrlEdit = (EditText) v.findViewById(R.id.adblock_url_edit); + mAdBlockFiltersUrlEdit.setText(AdBlockNativeGateway.getAdBlockFiltersURL()); + mAdBlockFiltersUrlEdit.addTextChangedListener(this); +diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc +index 74c5396245c07..fdbd35e786d0b 100644 +--- a/chrome/browser/browser_process_impl.cc ++++ b/chrome/browser/browser_process_impl.cc +@@ -1208,12 +1208,19 @@ BrowserProcessImpl::adblock_updater() { + std::unique_ptr scheduler = + std::make_unique(); + ++ std::string filters_url = local_state()->GetString(prefs::kAdBlockFiltersURL); ++ ++ // Check if the current URL is Bromite filters URL. If so, use the new URL ++ if (!filters_url.empty() && filters_url == "https://www.bromite.org/filters/filters.dat") { ++ filters_url = "https://images.ecloud.global/apps/browser/filters.dat"; ++ } ++ + adblock_updater_ = std::make_unique( + g_browser_process->system_network_context_manager()->GetSharedURLLoaderFactory(), + std::move(scheduler), + g_browser_process->subresource_filter_ruleset_service(), + local_state()->GetBoolean(prefs::kAdBlockEnabled), +- local_state()->GetString(prefs::kAdBlockFiltersURL)); ++ filters_url); + + return adblock_updater_.get(); + } +diff --git a/chrome/browser/net/system_network_context_manager.cc b/chrome/browser/net/system_network_context_manager.cc +index 5aa4ba0c2dbc6..1232086093038 100644 +--- a/chrome/browser/net/system_network_context_manager.cc ++++ b/chrome/browser/net/system_network_context_manager.cc +@@ -647,7 +647,7 @@ void SystemNetworkContextManager::RegisterPrefs(PrefRegistrySimple* registry) { + + registry->RegisterBooleanPref(prefs::kAdBlockEnabled, false); + registry->RegisterStringPref(prefs::kAdBlockFiltersURL, +- "https://www.bromite.org/filters/filters.dat"); ++ "https://images.ecloud.global/apps/browser/filters.dat"); + + // Static auth params + registry->RegisterStringPref(prefs::kAuthSchemes, +-- +2.34.1 + diff --git a/build/e_patches_list.txt b/build/e_patches_list.txt index 8958172e..1c11d330 100644 --- a/build/e_patches_list.txt +++ b/build/e_patches_list.txt @@ -52,3 +52,4 @@ 0052-Browser-Hide-settings-when-parental-control-is-activ.patch 0053-Browser-Use-correct-switch-scale.patch +0001-Browser-Change-adblock-url-to-ours.patch -- GitLab From 548cb745daba8deb5e2a665ebcb66840c911e97a Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 10 Sep 2024 13:15:59 +0530 Subject: [PATCH 4/4] Browser: Update chromium to 127.0.6533.106 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4aeec0c7..c3ffed22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:20.04 ENV CHROMIUM_DIR "/srv/chromium" -ENV CHROMIUM_VER "127.0.6533.103" +ENV CHROMIUM_VER "127.0.6533.106" RUN dpkg --add-architecture i386 -- GitLab