[tbb-commits] [Git][tpo/applications/tor-browser-build][main] 2 commits: Bug 41088: Remove use of projects/browser/run_scripts

boklm (@boklm) git at gitlab.torproject.org
Tue Mar 12 17:49:45 UTC 2024



boklm pushed to branch main at The Tor Project / Applications / tor-browser-build


Commits:
ec2d06bd by Nicolas Vigier at 2024-03-11T15:52:12+01:00
Bug 41088: Remove use of projects/browser/run_scripts

The script run_scripts was used to generate multiple bundles (for the
different locales) in parallel. However now that we only have one bundle
for all locales, using run_scripts is not useful anymore, and we can
simplify the build script by removing the use of run_scripts.

- - - - -
fbc5b080 by Nicolas Vigier at 2024-03-11T15:52:14+01:00
Bug 41088: Simplify a little projects/browser/build

- - - - -


4 changed files:

- projects/browser/build
- projects/browser/config
- projects/browser/ddmg.sh
- − projects/browser/run_scripts


Changes:

=====================================
projects/browser/build
=====================================
@@ -14,7 +14,8 @@ mkdir -p $OUTDIR
 # When we build with MULTI_LINGUAL=1, the browser will be packaged inside a
 # directory named tor-browser (instead of tor-browser_en-US). Therefore we
 # stage everything under tor-browser-stage to avoid a conflict.
-TB_STAGE_DIR=$distdir/tor-browser-stage
+PKG_DIR='[% c("var/project-name") %]'
+TB_STAGE_DIR="$distdir/$PKG_DIR[% IF c('var/windows') %]/[% c('var/Project_Name') %][% END %]"
 GENERATEDPREFSPATH=$rootdir/Bundle-Data/generated-prefs.js
 # Create initially empty prefs file where we can dump our conditionally included/genetered prefs
 touch "$GENERATEDPREFSPATH"
@@ -37,7 +38,7 @@ touch "$GENERATEDPREFSPATH"
   tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/libdmg') %]
   export PATH=/var/tmp/dist/hfsplus-tools:/var/tmp/dist/libdmg-hfsplus:$PATH
 [% ELSE %]
-  TBDIR=$TB_STAGE_DIR/Browser
+  TBDIR="$TB_STAGE_DIR/Browser"
   TBDIRS=("$TBDIR")
 
   DOCSPATH=[% c('var/ProjectName') %]/Docs
@@ -124,7 +125,6 @@ mv [% c('input_files_by_name/noscript') %] "$TBDIR/$EXTSPATH/{73a6fe31-595d-460b
 
   # on linux, libstdc++ lives in it's own directory
   [% IF c("var/linux") %]
-    find $TBDIR/$TORBINPATH
     mkdir -p "$TBDIR/$TORBINPATH/libstdc++"
     mv "$TBDIR/$TORBINPATH"/libstdc++.so.* "$TBDIR/$TORBINPATH/libstdc++"
   [% END %]
@@ -145,32 +145,32 @@ do
 done
 
 [% IF c("var/linux") %]
-  cat > ${TB_STAGE_DIR}/start-[% c("var/project-name") %].desktop << 'RBM_TB_EOF'
+  cat > "${TB_STAGE_DIR}/start-[% c('var/project-name') %].desktop" << 'RBM_TB_EOF'
 [% INCLUDE 'RelativeLink/start-browser.desktop' -%]
 RBM_TB_EOF
-  cat > ${TB_STAGE_DIR}/Browser/start-[% c("var/project-name") %] << 'RBM_TB_EOF'
+  cat > "${TB_STAGE_DIR}/Browser/start-[% c('var/project-name') %]" << 'RBM_TB_EOF'
 [% INCLUDE 'RelativeLink/start-browser' -%]
 RBM_TB_EOF
-  cat > ${TB_STAGE_DIR}/Browser/execdesktop << 'RBM_TB_EOF'
+  cat > "${TB_STAGE_DIR}/Browser/execdesktop" << 'RBM_TB_EOF'
 [% INCLUDE 'RelativeLink/execdesktop' -%]
 RBM_TB_EOF
-  chmod +x ${TB_STAGE_DIR}/start-[% c("var/project-name") %].desktop \
-           ${TB_STAGE_DIR}/Browser/start-[% c("var/project-name") %] \
-           ${TB_STAGE_DIR}/Browser/execdesktop
-  cp ${TB_STAGE_DIR}/start-[% c("var/project-name") %].desktop \
-     ${TB_STAGE_DIR}/Browser
+  chmod +x "${TB_STAGE_DIR}/start-[% c('var/project-name') %].desktop" \
+           "${TB_STAGE_DIR}/Browser/start-[% c('var/project-name') %]" \
+           "${TB_STAGE_DIR}/Browser/execdesktop"
+  cp "${TB_STAGE_DIR}/start-[% c('var/project-name') %].desktop" \
+     "${TB_STAGE_DIR}/Browser"
   [% IF c("var/namecoin") %]
-    pushd ${TB_STAGE_DIR}/Browser/
+    pushd "${TB_STAGE_DIR}/Browser/"
     patch -p1 < $rootdir/namecoin.patch
     popd
   [% END %]
   # Make sure we get the desired scrollbar behavior with Gtk3, see bug 27546.
-  GTK_SETTINGS_DIR=${TB_STAGE_DIR}/Browser/.config/gtk-3.0
+  GTK_SETTINGS_DIR="${TB_STAGE_DIR}/Browser/.config/gtk-3.0"
   mkdir -p $GTK_SETTINGS_DIR
   cp $rootdir/gtk3-settings.ini $GTK_SETTINGS_DIR/settings.ini
 [% END %]
 
-tar -C ${TB_STAGE_DIR} -xf [% c('input_files_by_name/firefox') %]/browser.tar.[% c("compress_tar") %]
+tar -C "${TB_STAGE_DIR}" -xf [% c('input_files_by_name/firefox') %]/browser.tar.[% c("compress_tar") %]
 
 [% IF c("var/macos_universal") -%]
   # Use symlink in tmp dir to extract "Tor Browser.app" to "Tor Browser-aarch64.app"
@@ -215,8 +215,8 @@ tar -C ${TB_STAGE_DIR} -xf [% c('input_files_by_name/firefox') %]/browser.tar.[%
    END; %]
 
 [% IF c("var/macos") %]
-  tar -C "Bundle-Data/[% c('var/ProjectName') %].dmg" -c . | tar -C $TB_STAGE_DIR -x
-  pushd $TB_STAGE_DIR
+  tar -C "Bundle-Data/[% c('var/ProjectName') %].dmg" -c . | tar -C "$TB_STAGE_DIR" -x
+  pushd "$TB_STAGE_DIR"
   cp [% c('var/channel') %].DS_Store .DS_Store
   rm *.DS_Store
   popd
@@ -264,17 +264,10 @@ done
 [% END -%]
 
 [% IF c("var/linux") && c("var/tor-browser") %]
-  chmod 700 ${TB_STAGE_DIR}/Browser/[% c('var/ProjectName') %]/Data/Browser
-  chmod 700 ${TB_STAGE_DIR}/Browser/TorBrowser/Data/Tor
+  chmod 700 "${TB_STAGE_DIR}/Browser/[% c('var/ProjectName') %]/Data/Browser"
+  chmod 700 "${TB_STAGE_DIR}/Browser/TorBrowser/Data/Tor"
 [% END %]
 
-# With multi-lingual builds, we use "ALL" in the package name as the locale for
-# update purposes. But we do not include "ALL" in the name of the directory that
-# is inside the package (in other words, users will not see tor-browser_ALL
-# after they install Tor Browser).
-PKG_LOCALE="ALL"
-PKG_DIR='[% c("var/project-name") %]'
-
 for tbdir in "${TBDIRS[@]}"
 do
   tbdir="$tbdir[% IF c('var/macos') %]/Contents/Resources[% END %]/"
@@ -325,12 +318,13 @@ done
     # we write the uninstaller from the installer.
     # Instead, we need to write an updated postupdate.exe also when updating.
     makensis postupdate.nsi
-    mv postupdate.exe ${TB_STAGE_DIR}/Browser/
+    mv postupdate.exe "${TB_STAGE_DIR}/Browser/"
     popd
   [% END -%]
 
-  mv ${TB_STAGE_DIR} $distdir/windows-installer/"[% c('var/Project_Name') %]"
-  mv $distdir/windows-installer ${TB_STAGE_DIR}
+  mv "${TB_STAGE_DIR}" "$distdir/windows-installer/[% c('var/Project_Name') %]"
+  rmdir "$distdir/$PKG_DIR"
+  mv $distdir/windows-installer "$distdir/$PKG_DIR"
 [% END %]
 
 [% IF c("var/macos_universal") -%]
@@ -355,18 +349,47 @@ done
   rm -Rf "$TBDIR_AARCH64"
 [% END -%]
 
-[% IF c("var/windows") %]
-  TBDIR="$distdir/$PKG_DIR/[% c("var/Project_Name") %]/Browser"
-[% ELSIF c("var/macos") %]
-  TBDIR="$distdir/$PKG_DIR/[% c('var/display_name') %].app"
-[% ELSE %]
-  TBDIR="$distdir/$PKG_DIR/Browser"
-[% END %]
+[% IF c("var/updater_enabled") -%]
+  cp $rootdir/[% c('input_files_by_name/firefox') %]/mar-tools-*.zip "$OUTDIR"/
+[% END -%]
 
-cat > "$scripts_dir/create-$PKG_DIR" << SCRIPT_EOF
-#!/bin/bash
-set -e
-cp -a ${TB_STAGE_DIR} $distdir/$PKG_DIR
+[% IF c("var/windows") -%]
+  archive_ext=zip
+[% ELSE -%]
+  archive_ext=tar.xz
+[% END -%]
+
+debug_symbols="$rootdir/[% c('input_files_by_name/firefox') %]/browser-debug-symbols.$archive_ext"
+if [[ -f "$debug_symbols" ]]; then
+  cp "$debug_symbols"  "$OUTDIR/[% c('var/project-name') %]-debug-symbols-[% c('var/mar_osname') %]-[% c('var/torbrowser_version') %].$archive_ext"
+fi
+
+geckodriver="$rootdir/[% c('input_files_by_name/firefox') %]/geckodriver.$archive_ext"
+if [[ -f "$geckodriver" ]]; then
+  cp "$geckodriver" "$OUTDIR/geckodriver-[% c('var/osname') %]-[% c('var/torbrowser_version') %].$archive_ext"
+fi
+[% IF c("var/macos_universal") -%]
+  geckodriver="$rootdir/[% c('input_files_by_name/firefox-aarch64') %]/geckodriver.$archive_ext"
+  if [[ -f "$geckodriver" ]]; then
+    cp "$geckodriver" "$OUTDIR/geckodriver-macos-aarch64-[% c('var/torbrowser_version') %].$archive_ext"
+  fi
+[% END -%]
+
+[%IF c("var/tor-browser") -%]
+  tor_expert_bundle_src="[% c("input_files_by_name/tor-expert-bundle") %]"
+  # strip off trailing "$buildid.tar.gz"
+  tor_expert_bundle_dest=${tor_expert_bundle_src:0:-7}.tar.gz
+  cp $rootdir/[% c("input_files_by_name/tor-expert-bundle") %]/tor-expert-bundle.tar.gz "$OUTDIR"/$tor_expert_bundle_dest
+  [% IF c("var/macos_universal") %]
+    tor_expert_bundle_src="[% c('input_files_by_name/tor-expert-bundle-aarch64') %]"
+    # strip off trailing "$buildid.tar.gz"
+    tor_expert_bundle_dest=${tor_expert_bundle_src:0:-7}.tar.gz
+    cp $rootdir/[% c('input_files_by_name/tor-expert-bundle-aarch64') %]/tor-expert-bundle.tar.gz "$OUTDIR"/$tor_expert_bundle_dest
+  [% END -%]
+[% END -%]
+[% IF c("var/build_infos_json") -%]
+  cp $rootdir/[% c('input_files_by_name/firefox') %]/build-infos.json "$OUTDIR"/build-infos-[% c("var/mar_osname") %].json
+[% END -%]
 
 [% IF c("var/updater_enabled") -%]
   pushd "$TBDIR[% IF c("var/macos") %]/Contents/Resources/[% END %]"
@@ -378,7 +401,7 @@ cd $distdir
 
 [% IF c("var/build_mar") && c("var/updater_enabled") -%]
   # Create full MAR file and compressed package.
-  [% SET mar_file = c("var/project-name") _ '-' _ c("var/mar_osname") _ '-' _ c("var/torbrowser_version") _ '_${PKG_LOCALE}.mar' %]
+  [% SET mar_file = c("var/project-name") _ '-' _ c("var/mar_osname") _ '-' _ c("var/torbrowser_version") _ '_ALL.mar' %]
   MAR=$MARTOOLS/mar \
   MOZ_PRODUCT_VERSION=[% c("var/torbrowser_version") %] \
   MAR_CHANNEL_ID=[% c("var/mar_channel_id") %] \
@@ -415,55 +438,3 @@ cd $distdir
   [% END -%]
   popd
 [% END %]
-rm -rf $distdir/${PKG_DIR}
-SCRIPT_EOF
-
-[% IF c("var/updater_enabled") -%]
-  cp $rootdir/[% c('input_files_by_name/firefox') %]/mar-tools-*.zip "$OUTDIR"/
-[% END -%]
-
-[% IF c("var/windows") -%]
-  archive_ext=zip
-[% ELSE -%]
-  archive_ext=tar.xz
-[% END -%]
-
-debug_symbols="$rootdir/[% c('input_files_by_name/firefox') %]/browser-debug-symbols.$archive_ext"
-if [[ -f "$debug_symbols" ]]; then
-  cp "$debug_symbols"  "$OUTDIR/[% c('var/project-name') %]-debug-symbols-[% c('var/mar_osname') %]-[% c('var/torbrowser_version') %].$archive_ext"
-fi
-
-[% IF c("var/macos_universal") -%]
-  geckodriver="$rootdir/[% c('input_files_by_name/firefox') %]/geckodriver.$archive_ext"
-  if [[ -f "$geckodriver" ]]; then
-    cp "$geckodriver" "$OUTDIR/geckodriver-[% c('var/osname') %]-[% c('var/torbrowser_version') %].$archive_ext"
-  fi
-  geckodriver="$rootdir/[% c('input_files_by_name/firefox-aarch64') %]/geckodriver.$archive_ext"
-  if [[ -f "$geckodriver" ]]; then
-    cp "$geckodriver" "$OUTDIR/geckodriver-macos-aarch64-[% c('var/torbrowser_version') %].$archive_ext"
-  fi
-[% ELSE -%]
-  geckodriver="$rootdir/[% c('input_files_by_name/firefox') %]/geckodriver.$archive_ext"
-  if [[ -f "$geckodriver" ]]; then
-    cp "$geckodriver" "$OUTDIR/geckodriver-[% c('var/osname') %]-[% c('var/torbrowser_version') %].$archive_ext"
-  fi
-[% END -%]
-
-[%IF c("var/tor-browser") -%]
-  tor_expert_bundle_src="[% c("input_files_by_name/tor-expert-bundle") %]"
-  # strip off trailing "$buildid.tar.gz"
-  tor_expert_bundle_dest=${tor_expert_bundle_src:0:-7}.tar.gz
-  cp $rootdir/[% c("input_files_by_name/tor-expert-bundle") %]/tor-expert-bundle.tar.gz "$OUTDIR"/$tor_expert_bundle_dest
-  [% IF c("var/macos_universal") %]
-    tor_expert_bundle_src="[% c('input_files_by_name/tor-expert-bundle-aarch64') %]"
-    # strip off trailing "$buildid.tar.gz"
-    tor_expert_bundle_dest=${tor_expert_bundle_src:0:-7}.tar.gz
-    cp $rootdir/[% c('input_files_by_name/tor-expert-bundle-aarch64') %]/tor-expert-bundle.tar.gz "$OUTDIR"/$tor_expert_bundle_dest
-  [% END -%]
-[% END -%]
-[% IF c("var/build_infos_json") -%]
-  cp $rootdir/[% c('input_files_by_name/firefox') %]/build-infos.json "$OUTDIR"/build-infos-[% c("var/mar_osname") %].json
-[% END -%]
-
-chmod 775 $rootdir/run_scripts "$scripts_dir"/*
-$rootdir/run_scripts [% c("num_procs") %] "$scripts_dir"


=====================================
projects/browser/config
=====================================
@@ -8,8 +8,6 @@ var:
   ddmg: '[% INCLUDE ddmg.sh %]'
   deps:
     - python3
-    - libparallel-forkmanager-perl
-    - libfile-slurp-perl
     - bzip2
     - jq
   mar_osname: '[% c("var/osname") %]'
@@ -67,8 +65,6 @@ targets:
 
 input_files:
   - project: container-image
-  - filename: run_scripts
-    enable: '[% ! c("var/android") %]'
   - project: firefox
     name: firefox
     enable: '[% ! c("var/android") %]'


=====================================
projects/browser/ddmg.sh
=====================================
@@ -7,8 +7,8 @@ find [% src %] ! -executable -exec chmod 0644 {} \;
 
 find [% src %] -exec [% c("touch") %] {} \;
 
-dmg_tmpdir=\$(mktemp -d)
-hfsfile="\$dmg_tmpdir/tbb-uncompressed.dmg"
+dmg_tmpdir=$(mktemp -d)
+hfsfile="$dmg_tmpdir/tbb-uncompressed.dmg"
 
 # hfsplus sets all the times to time(NULL)
 export LD_PRELOAD=[% c("var/faketime_path") %]
@@ -16,29 +16,29 @@ export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d
 
 src_dir=[% src %]
 # 1 for ceiling and 1 for the inode
-fileblocks=\$(find "\$src_dir" -type f -printf '%s\n' | awk '{s += int(\$1 / 4096) + 2} END {print s}')
-directories=\$(find "\$src_dir" -type d | wc -l)
+fileblocks=$(find "$src_dir" -type f -printf '%s\n' | awk '{s += int($1 / 4096) + 2} END {print s}')
+directories=$(find "$src_dir" -type d | wc -l)
 # Give some room to breathe
-size=\$(echo \$((\$fileblocks + \$directories)) | awk '{print int(\$1 * 1.1)}')
-dd if=/dev/zero of="\$hfsfile" bs=4096 count=\$size
-newfs_hfs -v "[% c('var/display_name') %]" "\$hfsfile"
+size=$(echo $(($fileblocks + $directories)) | awk '{print int($1 * 1.1)}')
+dd if=/dev/zero of="$hfsfile" bs=4096 count=$size
+newfs_hfs -v "[% c('var/display_name') %]" "$hfsfile"
 
 pushd [% src %]
 
 find -type d -mindepth 1 | sed -e 's/^\.\///' | sort | while read dirname; do
-  hfsplus "\$hfsfile" mkdir "/\$dirname"
-  hfsplus "\$hfsfile" chmod 0755 "/\$dirname"
+  hfsplus "$hfsfile" mkdir "/$dirname"
+  hfsplus "$hfsfile" chmod 0755 "/$dirname"
 done
 find -type f | sed -e 's/^\.\///' | sort | while read filename; do
-  hfsplus "\$hfsfile" add "\$filename" "/\$filename"
-  hfsplus "\$hfsfile" chmod \$(stat --format '0%a' "\$filename") "/\$filename"
+  hfsplus "$hfsfile" add "$filename" "/$filename"
+  hfsplus "$hfsfile" chmod $(stat --format '0%a' "$filename") "/$filename"
 done
 # hfsplus does not play well with dangling links
-hfsplus "\$hfsfile" symlink /Applications /Applications
+hfsplus "$hfsfile" symlink /Applications /Applications
 # Show the volume icon
-hfsplus "\$hfsfile" attr / C
+hfsplus "$hfsfile" attr / C
 
-dmg dmg "\$hfsfile" [% c('dmg_out', { error_if_undef => 1 }) %]
+dmg dmg "$hfsfile" [% c('dmg_out', { error_if_undef => 1 }) %]
 popd
 
-rm -Rf "\$dmg_tmpdir"
+rm -Rf "$dmg_tmpdir"


=====================================
projects/browser/run_scripts deleted
=====================================
@@ -1,30 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-
-use Parallel::ForkManager;
-use File::Slurp;
-
-sub exit_error {
-    print STDERR "Error: ", $_[0], "\n";
-    chdir '/';
-    exit (exists $_[1] ? $_[1] : 1);
-}
-
-exit_error "Wrong number of arguments" unless @ARGV == 2;
-my ($nb_threads, $scripts_dir) = @ARGV;
-exit_error "Could not enter $scripts_dir" unless chdir $scripts_dir;
-my $pm = Parallel::ForkManager->new($nb_threads);
-$pm->run_on_finish(
-    sub {
-        my ($pid, $exit, $id) = @_;
-        exit_error "Error running $id" unless $exit == 0;
-        print "Finished $id\n";
-    }
-);
-foreach my $script (sort(read_dir($scripts_dir))) {
-    $pm->start($script) and next;
-    print "Running $script\n";
-    exit_error "Error running $script" unless system("./$script") == 0;
-    $pm->finish;
-}
-$pm->wait_all_children;



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/5e9f8f0cb98f39e1cbf3d6275c7b22dccd26e5a7...fbc5b0800ab23ccacc4528de2f541853c0ea644d

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/5e9f8f0cb98f39e1cbf3d6275c7b22dccd26e5a7...fbc5b0800ab23ccacc4528de2f541853c0ea644d
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240312/11b8bb30/attachment-0001.htm>


More information about the tbb-commits mailing list