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

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=50b7e8cc41eb94a184087cc93cab86e401643c90

commit 50b7e8cc41eb94a184087cc93cab86e401643c90
Author: Guillem Jover <[email protected]>
AuthorDate: Wed Oct 10 09:41:11 2018 +0200

    Dpkg::Shlibs::Objdump: Only select objdump program when going to use it
    
    Running code in the module scope means that anything importing the
    module will execute that code, which is undesirable. Move the
    initialization into a _select_objdump() sub, which gets assigned into
    a state variable on demand.
---
 debian/changelog               |  1 +
 scripts/Dpkg/Shlibs/Objdump.pm | 23 +++++++++++++----------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 5ef764d80..e4d49221e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,6 +10,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium
       Based on a patch by Iain Lane <[email protected]> and
       Adam Conrad <[email protected]>. Closes: #915881
     - Dpkg::Shlibs::Objdump: Remove unused Dpkg::IPC import.
+    - Dpkg::Shlibs::Objdump: Only select objdump program when going to use it.
   * Documentation:
     - dpkg(1): Clarify --remove action. Closes: #914478
     - dpkg-query(1): Clarify --list option behavior when no arguments are
diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm
index d3a94113e..4cee866e7 100644
--- a/scripts/Dpkg/Shlibs/Objdump.pm
+++ b/scripts/Dpkg/Shlibs/Objdump.pm
@@ -1,4 +1,5 @@
 # Copyright © 2007-2010 Raphaël Hertzog <[email protected]>
+# Copyright © 2007-2009,2012-2015,2017-2018 Guillem Jover <[email protected]>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,16 +24,6 @@ our $VERSION = '0.01';
 
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
-use Dpkg::Path qw(find_command);
-use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch);
-
-# Decide which objdump to call
-our $OBJDUMP = 'objdump';
-if (get_build_arch() ne get_host_arch()) {
-    my $od = debarch_to_gnutriplet(get_host_arch()) . '-objdump';
-    $OBJDUMP = $od if find_command($od);
-}
-
 
 sub new {
     my $this = shift;
@@ -243,9 +234,12 @@ package Dpkg::Shlibs::Objdump::Object;
 
 use strict;
 use warnings;
+use feature qw(state);
 
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling;
+use Dpkg::Path qw(find_command);
+use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch);
 
 sub new {
     my $this = shift;
@@ -280,6 +274,14 @@ sub reset {
     return $self;
 }
 
+sub _select_objdump {
+    # Decide which objdump to call
+    if (get_build_arch() ne get_host_arch()) {
+        my $od = debarch_to_gnutriplet(get_host_arch()) . '-objdump';
+        return $od if find_command($od);
+    }
+    return 'objdump';
+}
 
 sub analyze {
     my ($self, $file) = @_;
@@ -297,6 +299,7 @@ sub analyze {
         return;
     }
 
+    state $OBJDUMP = _select_objdump();
     local $ENV{LC_ALL} = 'C';
     open(my $objdump, '-|', $OBJDUMP, '-w', '-f', '-p', '-T', '-R', $file)
         or syserr(g_('cannot fork for %s'), $OBJDUMP);

-- 
Dpkg.Org's dpkg

Reply via email to