[tbb-commits] [Git][tpo/applications/tor-browser-build][maint-13.0] Bug 41067: Use Capture::Tiny instead of IO::CaptureOutput

richard (@richard) git at gitlab.torproject.org
Wed Jan 31 08:52:03 UTC 2024



richard pushed to branch maint-13.0 at The Tor Project / Applications / tor-browser-build


Commits:
74602df1 by Nicolas Vigier at 2024-01-31T08:51:48+00:00
Bug 41067: Use Capture::Tiny instead of IO::CaptureOutput

The IO::CaptureOutput perl module is deprecated, so we switch to
Capture::Tiny. We also remove some uses of IO::CaptureOutput where it
was not needed.

- - - - -


8 changed files:

- README
- rbm.conf
- tools/clean-old
- tools/dmg2mar
- tools/download-torbrowser
- tools/signing/machines-setup/setup-signing-machine
- tools/update-responses/README.md
- tools/update-responses/update_responses


Changes:

=====================================
README
=====================================
@@ -21,7 +21,7 @@ You also need a few perl modules installed:
 - Getopt::Long
 - Template
 - IO::Handle
-- IO::CaptureOutput
+- Capture::Tiny
 - JSON
 - File::Temp
 - Path::Tiny
@@ -41,7 +41,7 @@ If you are running Debian or Ubuntu, you can install them with:
 
 # apt-get install libdata-dump-perl libdata-uuid-perl libdatetime-perl \
                   libdigest-sha-perl libfile-copy-recursive-perl \
-                  libfile-slurp-perl libio-all-perl libio-captureoutput-perl \
+                  libfile-slurp-perl libio-all-perl libcapture-tiny-perl \
                   libio-handle-util-perl libjson-perl \
                   libparallel-forkmanager-perl libpath-tiny-perl \
                   libsort-versions-perl libstring-shellquote-perl \
@@ -51,7 +51,7 @@ If you are running Debian or Ubuntu, you can install them with:
 If you are running an Arch based system, you should be able to install them with:
 
 # pacman -S perl-datetime perl-path-tiny perl-yaml perl-yaml-libyaml \
-            perl-yaml-tiny perl-template-toolkit perl-io-captureoutput \
+            perl-yaml-tiny perl-template-toolkit perl-capture-tiny \
             perl-file-copy-recursive perl-string-shellquote \
             perl-sort-versions perl-data-uuid perl-data-dump perl-json \
             perl-digest-sha1 perl-io-all perl-file-slurp perl-sys-syscall \


=====================================
rbm.conf
=====================================
@@ -705,7 +705,6 @@ gpg_allow_expired_keys: 1
 
 --- |
   # This part of the file contains options written in perl
-  use IO::CaptureOutput qw(capture_exec);
   (
     var_p => {
       nightly_torbrowser_version => sub {


=====================================
tools/clean-old
=====================================
@@ -1,6 +1,5 @@
 #!/usr/bin/perl -w
 use strict;
-use IO::CaptureOutput qw(capture_exec);
 use FindBin;
 use lib "$FindBin::Bin/../rbm/lib";
 use RBM;


=====================================
tools/dmg2mar
=====================================
@@ -29,7 +29,7 @@
 #  $ export "PATH=$p7zipdir/bin:$PATH"
 
 use strict;
-use IO::CaptureOutput qw(capture_exec);
+use Capture::Tiny qw(capture);
 use File::Slurp;
 use File::Find;
 use Parallel::ForkManager;
@@ -48,6 +48,15 @@ sub exit_error {
     exit (exists $_[1] ? $_[1] : 1);
 }
 
+sub capture_exec {
+  my @cmd = @_;
+  my ($stdout, $stderr, $exit) = capture {
+    system(@cmd);
+  };
+  return ($stdout, $stderr, $exit == 0, $exit) if wantarray();
+  return $stdout;
+}
+
 sub osname {
     my ($osname) = capture_exec('uname', '-s');
     my ($arch) = capture_exec('uname', '-m');


=====================================
tools/download-torbrowser
=====================================
@@ -6,7 +6,6 @@
 use strict;
 use English;
 use LWP::Simple;
-use IO::CaptureOutput qw(capture_exec);
 use File::Temp;
 use File::Basename qw(fileparse);
 use FindBin;


=====================================
tools/signing/machines-setup/setup-signing-machine
=====================================
@@ -100,7 +100,7 @@ authorized_keys richard richard.pub
 # Install rbm deps
 install_packages libyaml-libyaml-perl libtemplate-perl libdatetime-perl \
                  libio-handle-util-perl libio-all-perl \
-                 libio-captureoutput-perl libjson-perl libpath-tiny-perl \
+                 libcapture-tiny-perl libjson-perl libpath-tiny-perl \
                  libstring-shellquote-perl libsort-versions-perl \
                  libdigest-sha-perl libdata-uuid-perl libdata-dump-perl \
                  libfile-copy-recursive-perl libfile-slurp-perl


=====================================
tools/update-responses/README.md
=====================================
@@ -13,14 +13,14 @@ Dependencies
 
 The following perl modules need to be installed to run the script:
   FindBin YAML::XS File::Slurp Digest::SHA XML::Writer File::Temp
-  IO::CaptureOutput Parallel::ForkManager XML::LibXML LWP JSON
+  Capture::Tiny Parallel::ForkManager XML::LibXML LWP JSON
 
 On Debian / Ubuntu you can install them with:
 
 ```
   # apt-get install libfindbin-libs-perl libyaml-libyaml-perl \
                     libfile-slurp-perl libdigest-sha-perl libxml-writer-perl \
-                    libio-captureoutput-perl libparallel-forkmanager-perl \
+                    libcapture-tiny-perl libparallel-forkmanager-perl \
                     libxml-libxml-perl libwww-perl libjson-perl
 ```
 
@@ -28,7 +28,7 @@ On Red Hat / Fedora you can install them with:
 
 ```
   # for module in FindBin YAML::XS File::Slurp Digest::SHA XML::Writer \
-                  File::Temp IO::CaptureOutput Parallel::ForkManager \
+                  File::Temp Capture::Tiny Parallel::ForkManager \
                   XML::LibXML LWP JSON
     do yum install "perl($module)"; done
 ```


=====================================
tools/update-responses/update_responses
=====================================
@@ -14,7 +14,7 @@ use File::Copy;
 use File::Temp;
 use File::Find;
 use POSIX qw(setlocale LC_ALL);
-use IO::CaptureOutput qw(capture_exec);
+use Capture::Tiny qw(capture);
 use Parallel::ForkManager;
 use File::Basename;
 use XML::LibXML '1.70';
@@ -265,9 +265,11 @@ sub create_incremental_mar {
     local $ENV{MOZ_PRODUCT_VERSION} = $new_version;
     local $ENV{MAR_CHANNEL_ID} = get_config($config, $new_version, $os, 'mar_channel_id');
     local $ENV{TMPDIR} = $tmpdir;
-    my ($out, $err, $success) = capture_exec('make_incremental_update.sh',
-                                   $mar_file_path, "$tmpdir/A", "$tmpdir/B");
-    if (!$success) {
+    my ($out, $err, $exit) = capture {
+      system('make_incremental_update.sh',
+        $mar_file_path, "$tmpdir/A", "$tmpdir/B");
+    };
+    if ($exit) {
         unlink $mar_file_path if -f $mar_file_path;
         exit_error "making incremental mar:\n" . $err;
     }
@@ -490,9 +492,11 @@ sub extract_martools {
     $martools_tmpdir = get_tmpdir($config);
     my $old_cwd = getcwd;
     chdir $martools_tmpdir;
-    my (undef, undef, $success) = capture_exec('unzip', $marzip);
+    my (undef, undef, $exit) = capture {
+      system('unzip', $marzip);
+    };
     chdir $old_cwd;
-    exit_error "Error extracting $marzip" unless $success;
+    exit_error "Error extracting $marzip" if $exit;
     $ENV{PATH} = "$martools_tmpdir/mar-tools:$initPATH";
     if ($initLD_LIBRARY_PATH) {
         $ENV{LD_LIBRARY_PATH} = "$initLD_LIBRARY_PATH:$martools_tmpdir/mar-tools";



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/74602df1c80a92a426331b1645791a04314375c4

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/74602df1c80a92a426331b1645791a04314375c4
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/20240131/769862cf/attachment-0001.htm>


More information about the tbb-commits mailing list