Pier Angelo Vendrame pushed to branch main at The Tor Project / Applications / tor-browser-build
Commits: 1c1deba7 by Pier Angelo Vendrame at 2024-01-08T14:42:54+01:00 Bug 42343 (TB): Pass pt_config.json to the browser
We modified TorSettings to handle pt_config.json, so we do not need to convert it to pref lines anymore, but we need to inject the updated file to omni.ja.
- - - - -
2 changed files:
- projects/browser/build - projects/browser/build.android
Changes:
===================================== projects/browser/build ===================================== @@ -257,26 +257,6 @@ done echo "${line/${pt_path}/${PT_PATH}}" >> "$TORRC_DEFAULTS" done done - - # Write Default Bridge Prefs - echo "# Tor Launcher preferences (default bridges):" >> "$GENERATEDPREFSPATH" - RECOMMMENDED_DEFAULT=$(jq -r .recommendedDefault "${PT_CONFIG}") - echo "pref("extensions.torlauncher.default_bridge_recommended_type", "${RECOMMMENDED_DEFAULT}");" >> "$GENERATEDPREFSPATH" - - # Writes bridge-line prefs for a given bridge type - function bridges_conf { - local bridge_type="$1" - local i=1 - jq -r ".bridges."$bridge_type" | .[]" "${PT_CONFIG}" | while read -r line; do - echo "pref("extensions.torlauncher.default_bridge.$bridge_type.$i", "$line");" >> "$GENERATEDPREFSPATH" - i=$((i + 1)) - done - } - - # Iterate over our bridge types and write default bridgelines for each - for bridge_type in $(jq -r ".bridges | keys[]" "${PT_CONFIG}"); do - bridges_conf $bridge_type - done [% END -%]
[% IF c("var/linux") && c("var/tor-browser") %] @@ -293,8 +273,17 @@ PKG_DIR='[% c("var/project-name") %]'
for tbdir in "${TBDIRS[@]}" do - tbdir="$tbdir[% IF c('var/macos') %]/Contents/Resources[% END %]/browser/" - pushd "$tbdir" + tbdir="$tbdir[% IF c('var/macos') %]/Contents/Resources[% END %]/" + [% IF c("var/tor-browser") -%] + pushd "$rootdir" + pt_config_dir=chrome/toolkit/content/global + mkdir -p "$pt_config_dir" + cp "pt_config.json" "$pt_config_dir/" + zip -Xm "$tbdir/omni.ja" "$pt_config_dir/pt_config.json" + rm -rf chrome + popd + [% END -%] + pushd "$tbdir/browser" unzip omni.ja defaults/preferences/[% c("var/prefs_file") %] || [ $? -lt 3 ] # Append our built extension-overrides.js to the preferences file cat "$GENERATEDPREFSPATH" >> defaults/preferences/[% c("var/prefs_file") %]
===================================== projects/browser/build.android ===================================== @@ -14,7 +14,7 @@ sorted_baseline_apk=$(basename $apk .apk)_sorted_baseline.apk $rootdir/sort-baseline.py --apk $apk $sorted_baseline_apk mv $sorted_baseline_apk $apk
-# Bundle our extensioni(s). +# Bundle our extension(s). # NoScript will be copied over to the profile folder # as a "regular" browser extension receiving regular AMO updates. noscript_path="$ext_dir/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi" @@ -23,6 +23,21 @@ mkdir -p /var/tmp/build/$ext_dir [% dest_dir _ '/' _ c('filename') %] cd /var/tmp/build mv $rootdir/[% c('input_files_by_name/noscript') %] "$noscript_path"
+[%IF c("var/tor-browser") -%] + unzip -j "$apk" assets/omni.ja + tar -xaf "$rootdir/[% c("input_files_by_name/tor-expert-bundle") %]" tor/pluggable_transports/pt_config.json + mkdir omni + pushd omni + unzip ../omni.ja + cp ../tor/pluggable_transports/pt_config.json chrome/toolkit/content/global/pt_config.json + [% c('zip', { + zip_src => [ '.' ], + zip_args => '../assets/omni.ja', + }) %] + popd +[% END -%] + + [% IF c("var/verify_allowed_addons") %] # Check that allowed_addons.json contains the right versions of our bundled extension(s). # If so, replace the default allowed_addons.json by ours in the apk assets folder. @@ -32,9 +47,9 @@ mv $rootdir/[% c('input_files_by_name/noscript') %] "$noscript_path" mv $rootdir/allowed_addons.json $assets_dir/allowed_addons.json
[% c('zip', { - zip_src => [ '$assets_dir' ], - zip_args => '$apk', - }) %] + zip_src => [ '$assets_dir' ], + zip_args => '$apk', + }) %]
aligned_apk=$(basename $apk .apk)_aligned.apk zipalign -vp 4 $apk $aligned_apk
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/1c...