Fix empty field fix, to take into account that "0" is a false value

Instead, avoid populating fields with empty strings if rpm fails to
get a field value, either due to not knowing the field, or due to the
field not being set.
This commit is contained in:
Joey Hess
2010-04-18 15:19:35 -04:00
parent 2f50988983
commit e75140dc5f
2 changed files with 7 additions and 7 deletions

BIN
Alien/Package/.Rpm.pm.swp Normal file

Binary file not shown.

View File

@@ -76,7 +76,7 @@ sub scan {
POSTIN => 'postinst',
PREUN => 'prerm',
POSTUN => 'postrm',
LICENSE => 'copyright', # RPM Copyright tag has been deprecated in favour of License tag since rpm 4.0
LICENSE => 'copyright',
);
# Use --queryformat to pull out all the fields we need.
@@ -84,6 +84,7 @@ sub scan {
SUMMARY DESCRIPTION PREFIXES},
keys(%fieldtrans)) {
my $value=$this->runpipe(0, "LANG=C rpm -qp --queryformat \%{$field} $file");
next if $? || $value eq 'none';
my $key;
if (exists $fieldtrans{$field}) {
$key=$fieldtrans{$field};
@@ -91,7 +92,6 @@ sub scan {
else {
$key=lc($field);
}
$value='' if $value eq '(none)';
$this->$key($value);
}
@@ -112,7 +112,7 @@ sub scan {
}
# Sanity check and sanitize fields.
if (! $this->summary) {
unless (defined $this->summary) {
# Older rpms will have no summary, but will have a
# description. We'll take the 1st line out of the
# description, and use it for the summary.
@@ -123,10 +123,10 @@ sub scan {
$this->summary('Converted RPM package');
}
}
if (! $this->description) {
unless (defined $this->description) {
$this->description($this->summary);
}
if (! $this->copyright) {
unless (defined $this->copyright) {
# Older rpms have no licence tag, but have a copyright.
$this->copyright($this->runpipe(0, "LANG=C rpm -qp --queryformat \%{COPYRIGHT} $file"));
@@ -135,8 +135,8 @@ sub scan {
$this->copyright('unknown');
}
}
if (! $this->release || ! $this->version ||
! $this->name) {
if (! defined $this->release || ! defined $this->version ||
! defined $this->name) {
die "Error querying rpm file";
}