[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 03/04: Migrate some trival spawn calls to run_cmd



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 17197b6ab020892d03c008bb92bca6af0886a10e
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Apr 20 11:01:32 2017 +0000

    Migrate some trival spawn calls to run_cmd
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/po-debconf.pm               | 24 +++++++++++-------------
 collection/bin-pkg-control         |  4 ++--
 collection/strings                 |  5 ++---
 collection/unpacked                |  8 +++-----
 commands/reporting-harness.pm      |  6 ++----
 commands/reporting-html-reports.pm |  5 ++---
 lib/Lintian/Util.pm                |  6 +++---
 7 files changed, 25 insertions(+), 33 deletions(-)

diff --git a/checks/po-debconf.pm b/checks/po-debconf.pm
index 49aa54f..b2d8550 100644
--- a/checks/po-debconf.pm
+++ b/checks/po-debconf.pm
@@ -28,7 +28,7 @@ use File::Temp();
 
 use Lintian::Command qw(spawn);
 use Lintian::Tags qw(tag);
-use Lintian::Util qw(clean_env copy_dir);
+use Lintian::Util qw(clean_env copy_dir run_cmd);
 
 sub run {
     my (undef, undef, $info) = @_;
@@ -169,16 +169,14 @@ sub run {
         );
         my @msgcmp = ('msgcmp', '--use-untranslated');
         my %intltool_opts = (
-            'child_before_exec' => sub {
-                $ENV{'INTLTOOL_EXTRACT'}
-                  = '/usr/share/intltool-debian/intltool-extract';
+            'update-env-vars' => {
+                'INTLTOOL_EXTRACT' =>
+                  '/usr/share/intltool-debian/intltool-extract',
                 # safety of $debian_po is implied by us having
                 # accessed two of its children by now.
-                $ENV{'srcdir'} = $debian_po_dir->fs_path;
-                chdir($tempdir);
+                'srcdir' => $debian_po_dir->fs_path,
             },
-            'fail' => 'error',
-            'out' => \*STDOUT,
+            'chdir' => $tempdir,
         );
 
         # Create our extra level
@@ -189,12 +187,12 @@ sub run {
           if $d_templates;
 
         # Generate a "test.pot" (in a tempdir)
-        spawn(
+        run_cmd(
             \%intltool_opts,
-            [
-                '/usr/share/intltool-debian/intltool-update',
-                '--gettext-package=test','--pot'
-            ]);
+
+            '/usr/share/intltool-debian/intltool-update',
+            '--gettext-package=test','--pot'
+        );
 
         # Compare our "test.pot" with the existing "templates.pot"
         (
diff --git a/collection/bin-pkg-control b/collection/bin-pkg-control
index 9a0da43..11cdd93 100755
--- a/collection/bin-pkg-control
+++ b/collection/bin-pkg-control
@@ -31,7 +31,7 @@ use constant ERROR_FILES => qw(control-index-errors control-errors);
 
 use lib "$ENV{'LINTIAN_ROOT'}/lib";
 use Lintian::Command qw(spawn reap);
-use Lintian::Util qw(delete_dir fail pipe_tee);
+use Lintian::Util qw(delete_dir fail pipe_tee run_cmd);
 
 sub collect {
     my ($pkg, $type, $dir) = @_;
@@ -107,7 +107,7 @@ sub collect {
     }
 
     # fix permissions
-    spawn({ fail => 'error' }, ['chmod', '-R', 'u+rX,o-w', "$dir/control"]);
+    run_cmd('chmod', '-R', 'u+rX,o-w', "$dir/control");
 
     # Remove empty error files...
     for my $file (ERROR_FILES) {
diff --git a/collection/strings b/collection/strings
index c6977dd..7621ad7 100755
--- a/collection/strings
+++ b/collection/strings
@@ -32,7 +32,7 @@ use FileHandle;
 use lib "$ENV{'LINTIAN_ROOT'}/lib";
 use Lintian::Collect;
 use Lintian::Command qw(spawn reap);
-use Lintian::Util qw(delete_dir fail locate_helper_tool);
+use Lintian::Util qw(delete_dir fail locate_helper_tool run_cmd);
 
 my $helper = locate_helper_tool('coll/strings-helper');
 
@@ -95,8 +95,7 @@ sub collect {
             my $strdir = $dir . '/strings/' . File::Basename::dirname($file);
             # create the dir if needed.
             unless (-d $strdir) {
-                system('mkdir', '-p', $strdir) == 0
-                  or fail "mkdir -p $strdir failed " . (($? >> 8) & 256), "\n";
+                run_cmd('mkdir', '-p', $strdir);
             }
             spawn(
                 {out => "$dir/strings/${file}.gz", fail => 'fail'},
diff --git a/collection/unpacked b/collection/unpacked
index 27ca2d0..3392aaf 100755
--- a/collection/unpacked
+++ b/collection/unpacked
@@ -37,7 +37,7 @@ use constant READ_SIZE => 4096 * 1024 * 10;
 
 use lib "$ENV{'LINTIAN_ROOT'}/lib";
 use Lintian::Command qw(spawn reap);
-use Lintian::Util qw(check_path delete_dir fail pipe_tee);
+use Lintian::Util qw(check_path delete_dir fail run_cmd pipe_tee);
 
 sub collect {
     my ($pkg, $type, $dir) = @_;
@@ -103,8 +103,7 @@ sub collect {
             ['gzip', '-9nc']);
 
         # fix permissions
-        spawn({ fail => 'error' },
-            ['chmod', '-R', 'u+rwX,o+rX,o-w', "$dir/unpacked"]);
+        run_cmd('chmod', '-R', 'u+rwX,o+rX,o-w', "$dir/unpacked");
 
     } else {
         mkdir("$dir/unpacked", 0777);
@@ -112,8 +111,7 @@ sub collect {
         extract_and_index_deb($dir);
 
         # fix permissions
-        spawn({ fail => 'error' },
-            ['chmod', '-R', 'u+rwX,go-w', "$dir/unpacked"]);
+        run_cmd('chmod', '-R', 'u+rwX,go-w', "$dir/unpacked");
     }
 
     # Remove the error file if it is empty
diff --git a/commands/reporting-harness.pm b/commands/reporting-harness.pm
index eb6a311..2355821 100755
--- a/commands/reporting-harness.pm
+++ b/commands/reporting-harness.pm
@@ -36,7 +36,7 @@ use Lintian::Lab::Manifest;
 use Lintian::Processable;
 use Lintian::Relation::Version qw(versions_comparator);
 use Lintian::Util qw(open_gz slurp_entire_file strip visit_dpkg_paragraph
-  load_state_cache  save_state_cache);
+  load_state_cache run_cmd save_state_cache);
 
 sub usage {
     print <<END;
@@ -119,11 +119,9 @@ sub main {
 
     unless ($opt{'dry-run'}) {
         # rotate log files
-        my %savelog_opt = ('out' => '/dev/null',);
         my @rotate_logs
           = ($log_file, $html_reports_log, $lintian_perf_log, $sync_state_log);
-        spawn(\%savelog_opt, ['savelog', @rotate_logs])
-          or die("Cannot rotate log files.\n");
+        run_cmd('savelog', @rotate_logs);
 
         # create new log file
         open($LOG_FD, '>', $log_file)
diff --git a/commands/reporting-html-reports.pm b/commands/reporting-html-reports.pm
index 4d02415..d6cc3c5 100644
--- a/commands/reporting-html-reports.pm
+++ b/commands/reporting-html-reports.pm
@@ -33,7 +33,7 @@ use List::MoreUtils qw(uniq);
 use URI::Escape;
 use Text::Template ();
 
-use Lintian::Command qw(safe_qx spawn);
+use Lintian::Command qw(safe_qx);
 use Lintian::Data;
 use Lintian::Internal::FrontendUtil qw(split_tag);
 use Lintian::Profile;
@@ -430,8 +430,7 @@ sub setup_output_dir {
                 'install_method' => 'copy',
                 'source_file' => $lintian_log_file,
             });
-        spawn(\%opts, ['gzip', '-9nc'])
-          or die("cannot create $output_dir/lintian.log.gz.\n");
+        run_cmd(\%opts, ['gzip', '-9nc']);
         $RESOURCE_MANAGER->install_resource("$output_dir/lintian.log.gz");
         symlink($RESOURCE_MANAGER->resource_URL('lintian.log'),
             "$output_dir/lintian.log");
diff --git a/lib/Lintian/Util.pm b/lib/Lintian/Util.pm
index d8caad4..df17472 100644
--- a/lib/Lintian/Util.pm
+++ b/lib/Lintian/Util.pm
@@ -1104,7 +1104,7 @@ Convenient way of calling I<rm -fr ARGS>.
 =cut
 
 sub delete_dir {
-    return spawn(undef, ['rm', '-rf', '--', @_]);
+    return run_cmd('rm', '-rf', '--', @_);
 }
 
 =item copy_dir (ARGS)
@@ -1117,7 +1117,7 @@ sub copy_dir {
     # --reflink=auto (coreutils >= 7.5).  On FS that support it,
     # make a CoW copy of the data; otherwise fallback to a regular
     # deep copy.
-    return spawn(undef, ['cp', '-a', '--reflink=auto', '--', @_]);
+    return run_cmd('cp', '-a', '--reflink=auto', '--', @_);
 }
 
 =item gunzip_file (IN, OUT)
@@ -1130,7 +1130,7 @@ will cause a trappable error.
 
 sub gunzip_file {
     my ($in, $out) = @_;
-    spawn({out => $out, fail => 'error'}, ['gzip', '-dc', $in]);
+    run_cmd({out => $out}, 'gzip', '-dc', $in);
     return;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: