From 4523f77bba9b97925030bcf641584a4a74819178 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 3 Feb 2017 21:54:56 +0000 Subject: [PATCH] Dgit.pm: runcmd: Break out from dgit Move runcmd into Dgit.pm. We need to change dgit-repos-server too, but luckily its definition is essentially equivalent. No functional change to dgit. dgit-repos-server now prints somewhat better error messages when subprocesses fail. Signed-off-by: Ian Jackson --- Debian/Dgit.pm | 8 +++++++- dgit | 6 ------ infra/dgit-repos-server | 7 ------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index dcecbd1a..5b5591d5 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -45,7 +45,7 @@ BEGIN { fail ensuredir executable_on_path waitstatusmsg failedcmd_waitstatus failedcmd_report_cmd failedcmd - cmdoutput cmdoutput_errok + runcmd cmdoutput cmdoutput_errok git_rev_parse git_cat_file git_get_ref git_for_each_ref git_for_each_tag_referring is_fast_fwd @@ -276,6 +276,12 @@ sub failedcmd { fail failedcmd_waitstatus(); } +sub runcmd { + debugcmd "+",@_; + $!=0; $?=-1; + failedcmd @_ if system @_; +} + sub cmdoutput_errok { confess Dumper(\@_)." ?" if grep { !defined } @_; debugcmd "|",@_; diff --git a/dgit b/dgit index 9c7ec734..54ba4d65 100755 --- a/dgit +++ b/dgit @@ -493,12 +493,6 @@ sub url_get { our ($dscdata,$dscurl,$dsc,$dsc_checked,$skew_warning_vsn); -sub runcmd { - debugcmd "+",@_; - $!=0; $?=-1; - failedcmd @_ if system @_; -} - sub act_local () { return $dryrun_level <= 1; } sub act_scary () { return !$dryrun_level; } diff --git a/infra/dgit-repos-server b/infra/dgit-repos-server index ec9b2c9a..a8b9400b 100755 --- a/infra/dgit-repos-server +++ b/infra/dgit-repos-server @@ -303,13 +303,6 @@ sub reject ($) { die "\ndgit-repos-server: reject: $why\n\n"; } -sub runcmd { - debugcmd '+',@_; - $!=0; $?=0; - my $r = system @_; - die (shellquote @_)." $? $!" if $r; -} - sub policyhook { my ($policyallowbits, @polargs) = @_; # => ($exitstatuspolicybitmap); -- 2.30.2