From 4830133bfa372b70d042963bb409b11ebf70c913 Mon Sep 17 00:00:00 2001 From: althafvly Date: Mon, 29 Sep 2025 15:14:07 +0530 Subject: [PATCH 1/6] Remove unused build args --- build.sh | 2 +- build/browser.gn_args | 1 - build/filters.gn_args | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/build.sh b/build.sh index ddf03f31..7caa645d 100755 --- a/build.sh +++ b/build.sh @@ -60,7 +60,7 @@ build() { build_args+=' trichrome_certdigest="c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8"' echo ">> [$(date)] Building chromium $chromium_version for $1" - gn gen "out/$1" --args="$build_args" + gn gen "out/$1" --fail-on-unused-args --args="$build_args" if [ $1 '==' "x64" ] || [ $1 '==' "arm64" ]; then build_targets="trichrome_webview_64_32_apk trichrome_chrome_64_32_apk trichrome_library_64_32_apk" else diff --git a/build/browser.gn_args b/build/browser.gn_args index bef67ac5..d1759b38 100644 --- a/build/browser.gn_args +++ b/build/browser.gn_args @@ -16,7 +16,6 @@ enable_hangout_services_extension=false enable_iterator_debugging=false enable_mdns=false enable_mse_mpeg2ts_stream_parser=true -enable_nacl=false enable_openxr=false enable_platform_dolby_vision=false enable_platform_dts_audio=false diff --git a/build/filters.gn_args b/build/filters.gn_args index 3313db3d..ab1c9223 100644 --- a/build/filters.gn_args +++ b/build/filters.gn_args @@ -1,6 +1,5 @@ target_cpu="x64" target_os="linux" -enable_nacl=false is_component_build=false is_debug=false blink_symbol_level=0 -- GitLab From 2a2cf7dba42fa3cfff7351f7783199df034fa22b Mon Sep 17 00:00:00 2001 From: althafvly Date: Fri, 26 Sep 2025 11:23:15 +0530 Subject: [PATCH 2/6] Browser: Allow legacy builds - Make trichrome optional --- build.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 7caa645d..b0a05aa1 100755 --- a/build.sh +++ b/build.sh @@ -13,6 +13,7 @@ chromium_url=https://github.com/chromium/chromium.git clean=0 gsync=0 history=1 +trichrome=0 patchonly=0 arch="" @@ -27,6 +28,7 @@ usage() { echo " -s Sync source" echo " -h Sync without history" echo " -p Apply patches - Only after synced" + echo " -t Build trichrome chromium, webview and library" echo exit 1 } @@ -34,7 +36,7 @@ usage() { build() { echo ">> [$(date)] Head commit: $(git show -s --format=%s)" apks="TrichromeChrome TrichromeLibrary TrichromeWebView TrichromeChrome6432 \ - TrichromeLibrary6432 TrichromeWebView6432" + TrichromeLibrary6432 TrichromeWebView6432 ChromePublic SystemWebView" build_args="$(cat "${root_dir}"/build/browser.gn_args) target_cpu=\"${1}\" " apk_arch=${1} @@ -61,7 +63,9 @@ build() { echo ">> [$(date)] Building chromium $chromium_version for $1" gn gen "out/$1" --fail-on-unused-args --args="$build_args" - if [ $1 '==' "x64" ] || [ $1 '==' "arm64" ]; then + if [[ $trichrome -eq 0 ]]; then + build_targets="chrome_public_apk system_webview_apk" + elif [ $1 '==' "x64" ] || [ $1 '==' "arm64" ]; then build_targets="trichrome_webview_64_32_apk trichrome_chrome_64_32_apk trichrome_library_64_32_apk" else build_targets="trichrome_webview_apk trichrome_chrome_apk trichrome_library_apk" @@ -221,7 +225,7 @@ init_repo() { fi } -while getopts ":a:cur:shp" opt; do +while getopts ":a:cur:shpt" opt; do case $opt in a) arch="$OPTARG" ;; c) clean=1 ;; @@ -229,6 +233,7 @@ while getopts ":a:cur:shp" opt; do s) gsync=1 ;; h) history=0 ;; p) patchonly=1 ;; + t) trichrome=1 ;; :) echo "Option -$OPTARG requires an argument" echo -- GitLab From 53fb747662928576034a9b26ec5fdb8ccfa7b23f Mon Sep 17 00:00:00 2001 From: althafvly Date: Mon, 29 Sep 2025 15:38:27 +0530 Subject: [PATCH 3/6] Rename trichrome library package --- build/browser.gn_args | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/browser.gn_args b/build/browser.gn_args index d1759b38..394545c1 100644 --- a/build/browser.gn_args +++ b/build/browser.gn_args @@ -54,5 +54,5 @@ use_thin_lto=false use_v8_context_snapshot=false chrome_public_manifest_package = "foundation.e.browser" -trichrome_library_package = "org.chromium.trichromelibrary" +trichrome_library_package = "foundation.e.trichromelibrary" system_webview_package_name="com.android.webview" -- GitLab From 13bb43548256fb0e96d2b4841758e2632d9c3764 Mon Sep 17 00:00:00 2001 From: althafvly Date: Mon, 29 Sep 2025 15:50:17 +0530 Subject: [PATCH 4/6] Compress legacy apk builds --- ...ress-libchrome-to-free-up-some-space.patch | 24 +++++++++++++++++++ build/cromite_patches_list.txt | 1 + 2 files changed, 25 insertions(+) create mode 100644 build/cromite_patches/Compress-libchrome-to-free-up-some-space.patch diff --git a/build/cromite_patches/Compress-libchrome-to-free-up-some-space.patch b/build/cromite_patches/Compress-libchrome-to-free-up-some-space.patch new file mode 100644 index 00000000..ef077093 --- /dev/null +++ b/build/cromite_patches/Compress-libchrome-to-free-up-some-space.patch @@ -0,0 +1,24 @@ +From: uazo +Date: Wed, 19 Jul 2023 09:32:36 +0000 +Subject: Compress libchrome to free up some space + +upstream removed ModernLinker support for developer build (apk releases). +see https://bugs.chromium.org/p/chromium/issues/detail?id=1383210 + +License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html +--- + chrome/android/chrome_public_apk_tmpl.gni | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/chrome/android/chrome_public_apk_tmpl.gni b/chrome/android/chrome_public_apk_tmpl.gni +--- a/chrome/android/chrome_public_apk_tmpl.gni ++++ b/chrome/android/chrome_public_apk_tmpl.gni +@@ -677,6 +677,7 @@ template("chrome_common_apk_or_module_tmpl") { + [ "//components/crash/core/app:chrome_crashpad_handler_named_as_so" ] + loadable_modules += [ "$root_out_dir/libchrome_crashpad_handler.so" ] + library_always_compress += [ "libchrome_crashpad_handler.so" ] ++ library_always_compress += [ "libchrome.so" ] + } else if (!_is_trichrome) { + # Crashpad trampoline lives in TrichromeLibrary.apk. + # https://chromium.googlesource.com/chromium/src/+/main/docs/android_native_libraries.md#Crashpad-Packaging +-- diff --git a/build/cromite_patches_list.txt b/build/cromite_patches_list.txt index 751c447b..7009ffd9 100644 --- a/build/cromite_patches_list.txt +++ b/build/cromite_patches_list.txt @@ -178,6 +178,7 @@ Disable-Feeback-Collector.patch Fix-chromium-build-bugs.patch Disable-privacy-issues-in-password-manager.patch Use-browser-navigation-handler.patch +Compress-libchrome-to-free-up-some-space.patch Disable-Android-Tab-Declutter.patch Temp-disable-UseContextSnapshot.patch -- GitLab From b87d58ab52e8745bf148ae0d5b927113ce8b9674 Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 1 Oct 2025 16:22:46 +0530 Subject: [PATCH 5/6] Format shell scripts - ./generate_filters.sh --- .gitlab-ci.yml | 2 +- build.sh | 410 +++++++++++++++--------------- build_subresource_filter_tools.sh | 36 +-- format_script.sh | 27 ++ generate_filters.sh | 38 +-- push.sh | 28 +- update_cromite_patches.sh | 13 +- update_domain_substitution.sh | 13 +- update_e_patches.sh | 76 +++--- update_third_party_patches.sh | 6 +- 10 files changed, 338 insertions(+), 311 deletions(-) create mode 100755 format_script.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a1722e91..3ebb04fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,7 +56,7 @@ update-filters: stage: filters extends: .build-filters needs: [] - script: + script: - $CI_PROJECT_DIR/generate_filters.sh artifacts: paths: diff --git a/build.sh b/build.sh index b0a05aa1..13a4fd71 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ set -e chromium_dir="${CHROMIUM_DIR}" root_dir=$(dirname "$(readlink -f "$0")") if [ ! -d "$chromium_dir" ]; then - chromium_dir=$root_dir + chromium_dir=$root_dir fi chromium_version=$(grep 'chromium_version' versions.txt | awk -F'"' '{print $2}') chromium_code=$(echo "${chromium_version}" | tr -d '.' | cut -c1-8) @@ -18,185 +18,185 @@ patchonly=0 arch="" usage() { - echo "Usage:" - echo " $(basename $(readlink -nf $0)) [ options ]" - echo - echo " Options:" - echo " -a Build specified arch" - echo " -c Clean" - echo " -u Show this message" - echo " -s Sync source" - echo " -h Sync without history" - echo " -p Apply patches - Only after synced" - echo " -t Build trichrome chromium, webview and library" - echo - exit 1 + echo "Usage:" + echo " $(basename $(readlink -nf $0)) [ options ]" + echo + echo " Options:" + echo " -a Build specified arch" + echo " -c Clean" + echo " -u Show this message" + echo " -s Sync source" + echo " -h Sync without history" + echo " -p Apply patches - Only after synced" + echo " -t Build trichrome chromium, webview and library" + echo + exit 1 } build() { - echo ">> [$(date)] Head commit: $(git show -s --format=%s)" - apks="TrichromeChrome TrichromeLibrary TrichromeWebView TrichromeChrome6432 \ + echo ">> [$(date)] Head commit: $(git show -s --format=%s)" + apks="TrichromeChrome TrichromeLibrary TrichromeWebView TrichromeChrome6432 \ TrichromeLibrary6432 TrichromeWebView6432 ChromePublic SystemWebView" - build_args="$(cat "${root_dir}"/build/browser.gn_args) target_cpu=\"${1}\" " + build_args="$(cat "${root_dir}"/build/browser.gn_args) target_cpu=\"${1}\" " - apk_arch=${1} - build_args+=' android_default_version_name="'$chromium_version'"' - build_args+=' android_default_version_code="'$chromium_code'"' + apk_arch=${1} + build_args+=' android_default_version_name="'$chromium_version'"' + build_args+=' android_default_version_code="'$chromium_code'"' - if [ $clean -eq 1 ]; then - if [ -d "out/$1" ]; then - rm -rf "out/$1" - fi - if [ -d "${root_dir}/apks/${apk_arch}" ]; then - rm -rf "${root_dir}/apks/${apk_arch}" - fi + if [ $clean -eq 1 ]; then + if [ -d "out/$1" ]; then + rm -rf "out/$1" fi - - build_args+=' cc_wrapper="ccache"' - - echo ">> [$(date)] Using AOSP test-key for release build" - keystore_path="${root_dir}/platform.jks" - build_args+=' android_keystore_path="'$keystore_path'"' - build_args+=' android_keystore_name="platform"' - build_args+=' android_keystore_password="platform"' - build_args+=' trichrome_certdigest="c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8"' - - echo ">> [$(date)] Building chromium $chromium_version for $1" - gn gen "out/$1" --fail-on-unused-args --args="$build_args" - if [[ $trichrome -eq 0 ]]; then - build_targets="chrome_public_apk system_webview_apk" - elif [ $1 '==' "x64" ] || [ $1 '==' "arm64" ]; then - build_targets="trichrome_webview_64_32_apk trichrome_chrome_64_32_apk trichrome_library_64_32_apk" - else - build_targets="trichrome_webview_apk trichrome_chrome_apk trichrome_library_apk" + if [ -d "${root_dir}/apks/${apk_arch}" ]; then + rm -rf "${root_dir}/apks/${apk_arch}" fi + fi + + build_args+=' cc_wrapper="ccache"' + + echo ">> [$(date)] Using AOSP test-key for release build" + keystore_path="${root_dir}/platform.jks" + build_args+=' android_keystore_path="'$keystore_path'"' + build_args+=' android_keystore_name="platform"' + build_args+=' android_keystore_password="platform"' + build_args+=' trichrome_certdigest="c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8"' + + echo ">> [$(date)] Building chromium $chromium_version for $1" + gn gen "out/$1" --fail-on-unused-args --args="$build_args" + if [[ $trichrome -eq 0 ]]; then + build_targets="chrome_public_apk system_webview_apk" + elif [ $1 '==' "x64" ] || [ $1 '==' "arm64" ]; then + build_targets="trichrome_webview_64_32_apk trichrome_chrome_64_32_apk trichrome_library_64_32_apk" + else + build_targets="trichrome_webview_apk trichrome_chrome_apk trichrome_library_apk" + fi + + ninja -C out/$1 $build_targets + mkdir -p "${root_dir}/apks/${apk_arch}" + + for apk in $apks; do + if [ -f "out/${1}/apks/$apk.apk" ]; then + echo ">> [$(date)] Moving release $apk for ${apk_arch} to output folder" + mv "out/${1}/apks/$apk.apk" "${root_dir}/apks/${apk_arch}/$(echo "$apk" | sed 's/[0-9]*//g').apk" + fi + done - ninja -C out/$1 $build_targets - mkdir -p "${root_dir}/apks/${apk_arch}" - - for apk in $apks; do - if [ -f "out/${1}/apks/$apk.apk" ]; then - echo ">> [$(date)] Moving release $apk for ${apk_arch} to output folder" - mv "out/${1}/apks/$apk.apk" "${root_dir}/apks/${apk_arch}/$(echo "$apk" | sed 's/[0-9]*//g').apk" - fi - done - - 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 + 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() { - 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 + 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 } patch() { - cd $chromium_dir/src - echo ">> [$(date)] Applying cromite patches" + cd $chromium_dir/src + echo ">> [$(date)] Applying cromite patches" - cromite_patches_list=$(cat "${root_dir}/build/cromite_patches_list.txt") - for file in $cromite_patches_list; do - git am -C0 -3 --ignore-whitespace "${root_dir}/build/cromite_patches/$file" - done + cromite_patches_list=$(cat "${root_dir}/build/cromite_patches_list.txt") + for file in $cromite_patches_list; do + git am -C0 -3 --ignore-whitespace "${root_dir}/build/cromite_patches/$file" + done - echo ">> [$(date)] Applying /e/ patches" + echo ">> [$(date)] Applying /e/ patches" - e_patches_list=$(cat "${root_dir}/build/e_patches_list.txt") - for file in $e_patches_list; do - git am -C0 -3 --ignore-whitespace "${root_dir}/build/e_patches/$file" - done + e_patches_list=$(cat "${root_dir}/build/e_patches_list.txt") + for file in $e_patches_list; do + git am -C0 -3 --ignore-whitespace "${root_dir}/build/e_patches/$file" + done - echo ">> [$(date)] Applying third party patches" + echo ">> [$(date)] Applying third party patches" - while read dir patch; do - [ -z "$dir" ] && continue # skip empty lines - cd $chromium_dir/src/third_party/$dir - git am -C0 -3 --ignore-whitespace "${root_dir}/build/third_party/$patch" - cd $chromium_dir/src - done < "${root_dir}/build/third_party_patches_list.txt" + while read dir patch; do + [ -z "$dir" ] && continue # skip empty lines + cd $chromium_dir/src/third_party/$dir + git am -C0 -3 --ignore-whitespace "${root_dir}/build/third_party/$patch" + cd $chromium_dir/src + done <"${root_dir}/build/third_party_patches_list.txt" - # Rename Chrome to Browser - rename + # Rename Chrome to Browser + rename - # domain_substitution from ungoogled-chromium - domain_substitution + # domain_substitution from ungoogled-chromium + domain_substitution } rename() { - cd $chromium_dir/src - - replacements=( - "Chrome browser=Browser" - "Chrome=Browser" - "Bromite=Browser" - "Cromite=Browser" - "Google Password Manager=Password Manager" - ) - - for replacement in "${replacements[@]}"; do - replaced_string=${replacement%%=*} - replacement_string=${replacement#*=} - - find . -type f -not -name 'foundation_e.grdp' -name '*.grd*' | while read -r filename; do - sed -i "s/\b${replaced_string}\b/${replacement_string}/g" "$filename" - done - find . -type f -name '*.xtb' | while read -r filename; do - sed -i "s/\b${replaced_string}\b/${replacement_string}/g" "$filename" - done + cd $chromium_dir/src + + replacements=( + "Chrome browser=Browser" + "Chrome=Browser" + "Bromite=Browser" + "Cromite=Browser" + "Google Password Manager=Password Manager" + ) + + for replacement in "${replacements[@]}"; do + replaced_string=${replacement%%=*} + replacement_string=${replacement#*=} + + find . -type f -not -name 'foundation_e.grdp' -name '*.grd*' | while read -r filename; do + sed -i "s/\b${replaced_string}\b/${replacement_string}/g" "$filename" + done + find . -type f -name '*.xtb' | while read -r filename; do + sed -i "s/\b${replaced_string}\b/${replacement_string}/g" "$filename" done + done - git add . - git commit -m "Browser: Replace Chrome with Browser" + git add . + git commit -m "Browser: Replace Chrome with Browser" } domain_substitution() { - cd "${root_dir}/domain_substitution" - python3 domain_substitution.py apply -r domain_regex.list -f domain_substitution.list $chromium_dir/src - cd $chromium_dir/src - git add . - git commit -m "Browser: Automated domain substitution" + cd "${root_dir}/domain_substitution" + python3 domain_substitution.py apply -r domain_regex.list -f domain_substitution.list $chromium_dir/src + cd $chromium_dir/src + git add . + git commit -m "Browser: Automated domain substitution" } sync() { - echo ">> [$(date)] Syncing chromium $chromium_version" - cd $chromium_dir - gclient_config - if [ -d "$chromium_dir/src" ]; then - cd $chromium_dir/src - git fetch origin refs/tags/$chromium_version - if [ $clean -eq 1 ]; then - git checkout main - git reset --hard FETCH_HEAD - else - git reset --hard $chromium_commit_hash - fi - fi - if [ $history -eq 1 ]; then - gclient sync -D --nohooks -R --force + echo ">> [$(date)] Syncing chromium $chromium_version" + cd $chromium_dir + gclient_config + if [ -d "$chromium_dir/src" ]; then + cd $chromium_dir/src + git fetch origin refs/tags/$chromium_version + if [ $clean -eq 1 ]; then + git checkout main + git reset --hard FETCH_HEAD else - gclient sync --no-history -D --nohooks -R --force + git reset --hard $chromium_commit_hash fi - gclient runhooks - patch + fi + if [ $history -eq 1 ]; then + gclient sync -D --nohooks -R --force + else + gclient sync --no-history -D --nohooks -R --force + fi + gclient runhooks + patch } gclient_config() { - cat <"$chromium_dir/.gclient" + cat <"$chromium_dir/.gclient" solutions = [{ "url": "$chromium_url@$chromium_commit_hash", "managed": False, @@ -215,87 +215,87 @@ EOF } init_repo() { - echo ">> [$(date)] Init chromium $chromium_version" - cd $chromium_dir - rm -rf .gclient* - if [ $history -eq 1 ]; then - fetch android - else - fetch --no-history android - fi + echo ">> [$(date)] Init chromium $chromium_version" + cd $chromium_dir + rm -rf .gclient* + if [ $history -eq 1 ]; then + fetch android + else + fetch --no-history android + fi } while getopts ":a:cur:shpt" opt; do - case $opt in - a) arch="$OPTARG" ;; - c) clean=1 ;; - u) usage ;; - s) gsync=1 ;; - h) history=0 ;; - p) patchonly=1 ;; - t) trichrome=1 ;; - :) - echo "Option -$OPTARG requires an argument" - echo - usage - ;; - \?) - echo "Invalid option: -$OPTARG" - echo - usage - ;; - esac + case $opt in + a) arch="$OPTARG" ;; + c) clean=1 ;; + u) usage ;; + s) gsync=1 ;; + h) history=0 ;; + p) patchonly=1 ;; + t) trichrome=1 ;; + :) + echo "Option -$OPTARG requires an argument" + echo + usage + ;; + \?) + echo "Invalid option: -$OPTARG" + echo + usage + ;; + esac done shift $((OPTIND - 1)) # Add depot_tools to PATH if [ ! -d "$chromium_dir/depot_tools" ]; then - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "$chromium_dir/depot_tools" + git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git "$chromium_dir/depot_tools" else - cd $chromium_dir/depot_tools - git fetch https://chromium.googlesource.com/chromium/tools/depot_tools.git main - git reset --hard FETCH_HEAD - cd $chromium_dir + cd $chromium_dir/depot_tools + git fetch https://chromium.googlesource.com/chromium/tools/depot_tools.git main + git reset --hard FETCH_HEAD + cd $chromium_dir fi export PATH="$chromium_dir/depot_tools:$PATH" chromium_commit_hash=$(git ls-remote --refs $chromium_url refs/tags/$chromium_version | awk '{print $1}') if [ $clean -eq 1 ]; then - echo ">> [$(date)] Cleaning chromium source code" - if [ -d "$chromium_dir/src" ]; then - cd $chromium_dir/src - git reset --hard && git clean -xfdf - fi + echo ">> [$(date)] Cleaning chromium source code" + if [ -d "$chromium_dir/src" ]; then + cd $chromium_dir/src + git reset --hard && git clean -xfdf + fi fi if [ ! -d "$chromium_dir/src" ]; then - init_repo - sync + init_repo + sync fi 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." - fi - find ".git" -name "*.lock" -delete - if [ ! -z $(find .git -name "*.lock") ]; then - echo ">> [$(date)] Re-init chromium." - cd ${root_dir} - rm -fr $chromium_dir/src - init_repo - fi - sync + 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." + fi + find ".git" -name "*.lock" -delete + if [ ! -z $(find .git -name "*.lock") ]; then + echo ">> [$(date)] Re-init chromium." + cd ${root_dir} + rm -fr $chromium_dir/src + init_repo + fi + sync elif [ $patchonly -eq 1 ]; then - cd $chromium_dir/src - git fetch origin refs/tags/$chromium_version - git checkout main - git reset --hard FETCH_HEAD - patch + cd $chromium_dir/src + git fetch origin refs/tags/$chromium_version + git checkout main + git reset --hard FETCH_HEAD + patch fi cd $chromium_dir/src @@ -303,10 +303,10 @@ cd $chromium_dir/src setup_ccache if [ ! -z "$arch" ]; then - build $arch + build $arch else - build arm - build arm64 - build x86 - build x64 + build arm + build arm64 + build x86 + build x64 fi diff --git a/build_subresource_filter_tools.sh b/build_subresource_filter_tools.sh index c2e9ed58..19dda170 100755 --- a/build_subresource_filter_tools.sh +++ b/build_subresource_filter_tools.sh @@ -5,30 +5,30 @@ set -e chromium_dir="${CHROMIUM_DIR}" root_dir=$(dirname "$(readlink -f "$0")") if [ ! -d "$chromium_dir" ]; then - chromium_dir=$root_dir + 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 + 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 + 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" diff --git a/format_script.sh b/format_script.sh new file mode 100755 index 00000000..88e3730d --- /dev/null +++ b/format_script.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Check if shfmt is installed +if ! command -v shfmt &>/dev/null; then + echo "shfmt is not installed. Please install shfmt (curl -sS https://webi.sh/shfmt | sh) to fix formatting." + exit 0 +fi + +# Get the directory of the script +SCRIPT_DIR="$(cd "$(dirname "$0")"/ && pwd)" + +# Use git to list all shell scripts (respects .gitignore) +FILES=$(git -C "$SCRIPT_DIR" ls-files --cached --others --exclude-standard '*.sh') + +if [[ -z "$FILES" ]]; then + echo "No shell scripts found to format." + exit 0 +fi + +# Format each file +for script_file in $FILES; do + echo "Formatting $script_file ..." + shfmt -w -i 2 "$SCRIPT_DIR/$script_file" + git add "$SCRIPT_DIR/$script_file" +done + +echo "Formatting complete!" diff --git a/generate_filters.sh b/generate_filters.sh index d7256637..01510896 100755 --- a/generate_filters.sh +++ b/generate_filters.sh @@ -6,37 +6,37 @@ GITLAB_API="https://gitlab.e.foundation/api/v4" PROJECT_PATH=$(echo -n "e/os/browser" | jq -sRr @uri) for tag in $(curl -s "${GITLAB_API}/projects/${PROJECT_PATH}/repository/tags" | jq -r '.[].name'); do - echo "Checking tag: $tag" + echo "Checking tag: $tag" - pipeline_id=$(curl -s "${GITLAB_API}/projects/${PROJECT_PATH}/pipelines?ref=${tag}&status=success" \ - | jq -r '.[0].id') + pipeline_id=$(curl -s "${GITLAB_API}/projects/${PROJECT_PATH}/pipelines?ref=${tag}&status=success" | + jq -r '.[0].id') - if [ "$pipeline_id" != "null" ] && [ -n "$pipeline_id" ]; then - echo "Found successful pipeline for tag $tag (Pipeline ID: $pipeline_id)" - selected_tag=$tag - break - fi + if [ "$pipeline_id" != "null" ] && [ -n "$pipeline_id" ]; then + echo "Found successful pipeline for tag $tag (Pipeline ID: $pipeline_id)" + selected_tag=$tag + break + fi done if [ -z "$selected_tag" ]; then - echo "No tag with successful pipeline found" - exit 1 + echo "No tag with successful pipeline found" + exit 1 fi echo "Looking for build-cromite-x64 job in pipeline $pipeline_id..." -job_id=$(curl -s "${GITLAB_API}/projects/${PROJECT_PATH}/pipelines/${pipeline_id}/jobs" \ - | jq -r '.[] | select(.name=="build-cromite-x64") | .id') +job_id=$(curl -s "${GITLAB_API}/projects/${PROJECT_PATH}/pipelines/${pipeline_id}/jobs" | + jq -r '.[] | select(.name=="build-cromite-x64") | .id') if [ -z "$job_id" ]; then - echo "No job named build-cromite-x64 found in pipeline $pipeline_id" - exit 1 + echo "No job named build-cromite-x64 found in pipeline $pipeline_id" + exit 1 fi echo "Downloading ruleset_converter from job $job_id..." curl -L \ - --output ruleset_converter \ - "${GITLAB_API}/projects/${PROJECT_PATH}/jobs/${job_id}/artifacts/bin/ruleset_converter" + --output ruleset_converter \ + "${GITLAB_API}/projects/${PROJECT_PATH}/jobs/${job_id}/artifacts/bin/ruleset_converter" chmod +x ruleset_converter @@ -48,6 +48,6 @@ filter_inputs="easyprivacy.txt,easylist.txt" echo "Generating filters.dat from $filter_inputs" ./ruleset_converter --input_format=filter-list \ - --output_format=unindexed-ruleset \ - --input_files=$filter_inputs \ - --output_file=filters.dat >/dev/null 2>&1 + --output_format=unindexed-ruleset \ + --input_files=$filter_inputs \ + --output_file=filters.dat >/dev/null 2>&1 diff --git a/push.sh b/push.sh index 6a7915f9..322bad0c 100755 --- a/push.sh +++ b/push.sh @@ -5,29 +5,31 @@ DO_CLEAR=false while getopts "uc" opt; do case $opt in - u) DO_UNINSTALL=true ;; - c) DO_CLEAR=true ;; - *) echo "Usage: $0 [-u] [-c]" >&2 - exit 1 ;; + u) DO_UNINSTALL=true ;; + c) DO_CLEAR=true ;; + *) + echo "Usage: $0 [-u] [-c]" >&2 + exit 1 + ;; esac done PACKAGES=( - "foundation.e.browser" - "com.android.webview" - "org.chromium.trichromelibrary" + "foundation.e.browser" + "com.android.webview" + "org.chromium.trichromelibrary" ) if [ "$DO_UNINSTALL" = true ]; then - for pkg in "${PACKAGES[@]}"; do - adb shell pm uninstall "$pkg" - done + for pkg in "${PACKAGES[@]}"; do + adb shell pm uninstall "$pkg" + done fi if [ "$DO_CLEAR" = true ]; then - for pkg in "${PACKAGES[@]}"; do - adb shell pm clear "$pkg" - done + for pkg in "${PACKAGES[@]}"; do + adb shell pm clear "$pkg" + done fi adb install -r apks/arm64/TrichromeLibrary.apk diff --git a/update_cromite_patches.sh b/update_cromite_patches.sh index 3f1c6506..64c0065f 100755 --- a/update_cromite_patches.sh +++ b/update_cromite_patches.sh @@ -2,24 +2,23 @@ root_dir=$(dirname "$(readlink -f "$0")") - branch=$(grep 'cromite_branch' versions.txt | awk -F'"' '{print $2}') cd $root_dir/build if [ -d cromite ]; then - cd cromite - git fetch origin $branch - git reset --hard FETCH_HEAD - cd .. + cd cromite + git fetch origin $branch + git reset --hard FETCH_HEAD + cd .. else - git clone https://gitlab.e.foundation/e/os/cromite.git -b $branch cromite --depth=1 + git clone https://gitlab.e.foundation/e/os/cromite.git -b $branch cromite --depth=1 fi rm -rf cromite_patches/* cromite_patches_list=$(cat "cromite_patches_list.txt") for file in $cromite_patches_list; do - cp cromite/build/patches/$file "cromite_patches/$file" + cp cromite/build/patches/$file "cromite_patches/$file" done echo "Copy done" diff --git a/update_domain_substitution.sh b/update_domain_substitution.sh index ebeb3ab5..e810379e 100755 --- a/update_domain_substitution.sh +++ b/update_domain_substitution.sh @@ -2,21 +2,20 @@ root_dir=$(dirname "$(readlink -f "$0")") - branch=$(grep 'ungoogled_chromium_branch' versions.txt | awk -F'"' '{print $2}') cd $root_dir/domain_substitution if [ -d ungoogled-chromium ]; then - cd ungoogled-chromium - git fetch origin $branch - git reset --hard FETCH_HEAD - cd .. + cd ungoogled-chromium + git fetch origin $branch + git reset --hard FETCH_HEAD + cd .. else - git clone https://github.com/ungoogled-software/ungoogled-chromium -b $branch ungoogled-chromium --depth=1 + git clone https://github.com/ungoogled-software/ungoogled-chromium -b $branch ungoogled-chromium --depth=1 fi -grep -vFf domain_blacklist.list ungoogled-chromium/domain_substitution.list > domain_substitution.list +grep -vFf domain_blacklist.list ungoogled-chromium/domain_substitution.list >domain_substitution.list cp -r ungoogled-chromium/domain_regex.list domain_regex.list cd ungoogled-chromium/utils cp _common.py domain_substitution.py _extraction.py prune_binaries.py ../../ diff --git a/update_e_patches.sh b/update_e_patches.sh index 2e592dac..2a6ff72a 100755 --- a/update_e_patches.sh +++ b/update_e_patches.sh @@ -7,12 +7,12 @@ output_patch_file="${root_dir}/build/e_patches_list.txt" output_patch_dir="${root_dir}/build/e_patches" if [ ! -f "$patch_list_file" ]; then - echo "Error: $patch_list_file does not exist." - exit 1 + echo "Error: $patch_list_file does not exist." + exit 1 fi if [ -f "$output_patch_file" ]; then - rm "$output_patch_file" + rm "$output_patch_file" fi last_patch=$(tail -n 1 "$patch_list_file") @@ -24,49 +24,49 @@ cd "${root_dir}/src" || exit 1 chromium_commit_hash=$(git log --pretty=format:"%H %s" | grep -F "$formatted_subject" | head -n 1 | awk '{print $1}') if [ -z "$chromium_commit_hash" ]; then - echo "Error: Could not retrieve commit hash for the last patch subject: $formatted_subject" - exit 1 + echo "Error: Could not retrieve commit hash for the last patch subject: $formatted_subject" + exit 1 fi -> "$output_patch_file" +>"$output_patch_file" mkdir -p "$output_patch_dir" # Patches to ignore ignore_patches=("Browser-Replace-Chrome-with-Browser.patch" "Browser-Automated-domain-substitution.patch") for commit in $(git rev-list --reverse "$chromium_commit_hash"..HEAD); do - subject=$(git log -n 1 --pretty=format:%s "$commit" | tr -d '[:punct:]') - formatted_subject=${subject// /-} - patch_filename="${formatted_subject}.patch" - patch_path="${output_patch_dir}/${patch_filename}" - - # Check if the patch filename is in the ignore list - if [[ " ${ignore_patches[@]} " =~ " ${patch_filename} " ]]; then - echo "Ignoring patch: $patch_filename" - continue + subject=$(git log -n 1 --pretty=format:%s "$commit" | tr -d '[:punct:]') + formatted_subject=${subject// /-} + patch_filename="${formatted_subject}.patch" + patch_path="${output_patch_dir}/${patch_filename}" + + # Check if the patch filename is in the ignore list + if [[ " ${ignore_patches[@]} " =~ " ${patch_filename} " ]]; then + echo "Ignoring patch: $patch_filename" + continue + fi + + # Generate the patch to a temporary file + temp_patch_file=$(mktemp) + git format-patch -1 --stdout "$commit" --subject-prefix="" >"$temp_patch_file" + + # Check if the patch differs from any existing one, ignoring the first line and the last non-empty line + if [ -f "$patch_path" ]; then + # Remove trailing empty lines and skip the first and last non-empty line + temp_content=$(sed '/./!d' "$temp_patch_file" | tail -n +2 | head -n -1) + existing_content=$(sed '/./!d' "$patch_path" | tail -n +2 | head -n -1) + + # Compare processed content + if diff -q <(echo "$temp_content") <(echo "$existing_content") >/dev/null; then + echo "Patch already up-to-date: $patch_filename" + rm "$temp_patch_file" + echo "$patch_filename" >>"$output_patch_file" + continue fi + fi - # Generate the patch to a temporary file - temp_patch_file=$(mktemp) - git format-patch -1 --stdout "$commit" --subject-prefix="" > "$temp_patch_file" - - # Check if the patch differs from any existing one, ignoring the first line and the last non-empty line - if [ -f "$patch_path" ]; then - # Remove trailing empty lines and skip the first and last non-empty line - temp_content=$(sed '/./!d' "$temp_patch_file" | tail -n +2 | head -n -1) - existing_content=$(sed '/./!d' "$patch_path" | tail -n +2 | head -n -1) - - # Compare processed content - if diff -q <(echo "$temp_content") <(echo "$existing_content") > /dev/null; then - echo "Patch already up-to-date: $patch_filename" - rm "$temp_patch_file" - echo "$patch_filename" >> "$output_patch_file" - continue - fi - fi - - # Move the patch to the output directory if it’s new or updated - echo "Updating patch: $patch_filename" - mv "$temp_patch_file" "$patch_path" - echo "$patch_filename" >> "$output_patch_file" + # Move the patch to the output directory if it’s new or updated + echo "Updating patch: $patch_filename" + mv "$temp_patch_file" "$patch_path" + echo "$patch_filename" >>"$output_patch_file" done diff --git a/update_third_party_patches.sh b/update_third_party_patches.sh index c4b84099..595978e4 100755 --- a/update_third_party_patches.sh +++ b/update_third_party_patches.sh @@ -3,11 +3,11 @@ root_dir=$(dirname "$(readlink -f "$0")") while read dir patch; do - [ -z "$dir" ] && continue # skip empty lines + [ -z "$dir" ] && continue # skip empty lines subject=${patch%.patch} formatted_subject=${subject//-/" "} echo "Updating patch: $formatted_subject" cd $root_dir/src/third_party/$dir commit_hash=$(git log --pretty=format:"%H %s" | grep -F "$formatted_subject" | head -n 1 | awk '{print $1}') - git format-patch -1 --stdout "$commit_hash" --subject-prefix="" > $root_dir/build/third_party/$patch -done < "${root_dir}/build/third_party_patches_list.txt" + git format-patch -1 --stdout "$commit_hash" --subject-prefix="" >$root_dir/build/third_party/$patch +done <"${root_dir}/build/third_party_patches_list.txt" -- GitLab From bc669b73b016d5e946f42a468bd8f4df501da2f2 Mon Sep 17 00:00:00 2001 From: althafvly Date: Fri, 3 Oct 2025 15:09:32 +0530 Subject: [PATCH 6/6] Build trichrome by default --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3ebb04fb..03f0f879 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,25 +24,25 @@ build-cromite-arm: stage: build extends: .build-cromite script: - - $CI_PROJECT_DIR/build.sh -c -s -a arm + - $CI_PROJECT_DIR/build.sh -c -t -s -a arm build-cromite-arm64: stage: build extends: .build-cromite script: - - $CI_PROJECT_DIR/build.sh -c -s -a arm64 + - $CI_PROJECT_DIR/build.sh -c -t -s -a arm64 build-cromite-x86: stage: build extends: .build-cromite script: - - $CI_PROJECT_DIR/build.sh -c -s -a x86 + - $CI_PROJECT_DIR/build.sh -c -t -s -a x86 build-cromite-x64: stage: build extends: .build-cromite script: - - $CI_PROJECT_DIR/build.sh -c -s -a x64 + - $CI_PROJECT_DIR/build.sh -c -t -s -a x64 .build-filters: image: registry.gitlab.e.foundation/e/os/docker-android-apps-cicd:slim-latest -- GitLab