summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2011-03-18 15:15:00 +0000
committerJasper Lievisse Adriaanse <jasper@cvs.openbsd.org>2011-03-18 15:15:00 +0000
commit4e9e4b7ae361c975661cca96483ca974826e39d6 (patch)
treee04567306175258dd3ecb85eb293668f0ce046b6
parentd8b8ff2d95ae1fbb3f78f90d36f1f6d1c1950022 (diff)
- add basic validation for .pc files, at least Name, Description and Version have to be
set. this is what fd.o pkg-config requires at least.
-rw-r--r--usr.bin/pkg-config/pkg-config22
1 files changed, 20 insertions, 2 deletions
diff --git a/usr.bin/pkg-config/pkg-config b/usr.bin/pkg-config/pkg-config
index 929fec50d52..8fe37c9b3ee 100644
--- a/usr.bin/pkg-config/pkg-config
+++ b/usr.bin/pkg-config/pkg-config
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# $OpenBSD: pkg-config,v 1.36 2011/03/18 15:13:33 jasper Exp $
+# $OpenBSD: pkg-config,v 1.37 2011/03/18 15:14:59 jasper Exp $
#$CSK: pkgconfig.pl,v 1.39 2006/11/27 16:26:20 ckuethe Exp $
# Copyright (c) 2006 Chris Kuethe <ckuethe@openbsd.org>
@@ -294,7 +294,7 @@ sub get_config
$cfg = OpenBSD::PkgConfig->read_file($f);
};
if (!$@) {
- return $cfg;
+ return validate_config($f, $cfg);
} else {
print STDERR $@, "\n" if $D;
}
@@ -314,6 +314,24 @@ sub cache_find_config
}
}
+# Required elements for a valid .pc file: Name, Description, Version
+sub validate_config
+{
+ my ($f, $cfg) = @_;
+ my @required_elems = ('Name', 'Description', 'Version');
+ my $e;
+
+ foreach (@required_elems) {
+ $e = $cfg->get_property($_, $variables);
+ if (!defined $e) {
+ print STDERR "incomplete or corrupt file: $f\n" if $D;
+ return undef;
+ }
+ }
+
+ return $cfg;
+}
+
# pkg-config won't install a pkg-config.pc file itself, but it may be
# listed as a dependency in other files.