Parcourir la source

scripts: Use length instead of defined when checking environment variables

In these cases we are not interested if the variables are defined, but
if they have actual content.
Guillem Jover il y a 12 ans
Parent
commit
b572af443f

+ 2 - 0
debian/changelog

@@ -16,6 +16,8 @@ dpkg (1.17.12) UNRELEASED; urgency=low
   * Use «tar --format=gnu» when creating source archives. This makes sure we
   * Use «tar --format=gnu» when creating source archives. This makes sure we
     get a deterministic output format, regardless of what tar defaults to.
     get a deterministic output format, regardless of what tar defaults to.
     Thanks to Jan Blunck <jblunck@infradead.org>..
     Thanks to Jan Blunck <jblunck@infradead.org>..
+  * Use perl's length instead of defined when checking some environment
+    variables, if we require them to have content.
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * German (Sven Joachim).
   * German (Sven Joachim).

+ 2 - 2
scripts/Dpkg/BuildFlags.pm

@@ -131,8 +131,8 @@ Update flags from the user configuration.
 sub load_user_config {
 sub load_user_config {
     my ($self) = @_;
     my ($self) = @_;
     my $confdir = $ENV{XDG_CONFIG_HOME};
     my $confdir = $ENV{XDG_CONFIG_HOME};
-    $confdir ||= $ENV{HOME} . '/.config' if defined $ENV{HOME};
-    if (defined $confdir) {
+    $confdir ||= $ENV{HOME} . '/.config' if length $ENV{HOME};
+    if (length $confdir) {
         $self->update_from_conffile("$confdir/dpkg/buildflags.conf", 'user');
         $self->update_from_conffile("$confdir/dpkg/buildflags.conf", 'user');
     }
     }
 }
 }

+ 1 - 1
scripts/Dpkg/Source/Package.pm

@@ -400,7 +400,7 @@ sub check_signature {
         push @exec, 'gpg', '--no-default-keyring', '-q', '--verify';
         push @exec, 'gpg', '--no-default-keyring', '-q', '--verify';
     }
     }
     if (scalar(@exec)) {
     if (scalar(@exec)) {
-        if (defined $ENV{HOME} and -r "$ENV{HOME}/.gnupg/trustedkeys.gpg") {
+        if (length $ENV{HOME} and -r "$ENV{HOME}/.gnupg/trustedkeys.gpg") {
             push @exec, '--keyring', "$ENV{HOME}/.gnupg/trustedkeys.gpg";
             push @exec, '--keyring', "$ENV{HOME}/.gnupg/trustedkeys.gpg";
         }
         }
         foreach my $vendor_keyring (run_vendor_hook('keyrings')) {
         foreach my $vendor_keyring (run_vendor_hook('keyrings')) {

+ 1 - 1
scripts/Dpkg/Vendor/Ubuntu.pm

@@ -58,7 +58,7 @@ sub run_hook {
         if (defined($fields->{'Version'}) and defined($fields->{'Maintainer'}) and
         if (defined($fields->{'Version'}) and defined($fields->{'Maintainer'}) and
            $fields->{'Version'} =~ /ubuntu/) {
            $fields->{'Version'} =~ /ubuntu/) {
            if ($fields->{'Maintainer'} !~ /ubuntu/i) {
            if ($fields->{'Maintainer'} !~ /ubuntu/i) {
-               if (defined ($ENV{DEBEMAIL}) and $ENV{DEBEMAIL} =~ /\@ubuntu\.com/) {
+               if (length $ENV{DEBEMAIL} and $ENV{DEBEMAIL} =~ /\@ubuntu\.com/) {
                    error(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
                    error(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
                } else {
                } else {
                    warning(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
                    warning(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));

+ 1 - 1
scripts/dpkg-architecture.pl

@@ -254,7 +254,7 @@ if (action_needs(DEB_HOST | DEB_GNU_INFO)) {
 
 
 
 
 for my $k (keys %arch_vars) {
 for my $k (keys %arch_vars) {
-    $v{$k} = $ENV{$k} if (defined ($ENV{$k}) && !$force);
+    $v{$k} = $ENV{$k} if (length $ENV{$k} && !$force);
 }
 }
 
 
 if ($action eq 'l') {
 if ($action eq 'l') {