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

richard (@richard) git at gitlab.torproject.org
Tue Jan 30 16:46:23 UTC 2024



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


Commits:
0ed7a191 by Nicolas Vigier at 2024-01-30T11:49:05+01: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 Fedora, CentOS or RHEL, you can install them with:
 
 # dnf install "perl(YAML::XS)" "perl(File::Basename)" "perl(Getopt::Long)" \
-              "perl(Template)" "perl(IO::Handle)" "perl(IO::CaptureOutput)" \
+              "perl(Template)" "perl(IO::Handle)" "perl(Capture::Tiny)" \
               "perl(JSON)" "perl(File::Temp)" "perl(Path::Tiny)" \
               "perl(File::Path)" "perl(File::Slurp)" \
               "perl(File::Copy::Recursive)" "perl(String::ShellQuote)"
@@ -62,7 +62,7 @@ If you are running Fedora, CentOS or RHEL, 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
=====================================
@@ -704,7 +704,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/0ed7a191b673f156b046aa796addc363f89e474f

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/0ed7a191b673f156b046aa796addc363f89e474f
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/tor-commits/attachments/20240130/aa319f04/attachment-0001.htm>


More information about the tor-commits mailing list