diff options
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgConfig.pm | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgConfig.pm b/usr.sbin/pkg_add/OpenBSD/PkgConfig.pm index 8d2ca8f1214..8cc5b0d4a98 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgConfig.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgConfig.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgConfig.pm,v 1.5 2006/11/30 01:04:35 espie Exp $ +# $OpenBSD: PkgConfig.pm,v 1.6 2006/11/30 13:18:22 espie Exp $ # # Copyright (c) 2006 Marc Espie <espie@openbsd.org> # @@ -20,6 +20,16 @@ use warnings; # this is a 'special' package, interface to the *.pc file format of pkg-config. package OpenBSD::PkgConfig; +# specific properties may have specific needs. + +my $parse = { + Requires => sub { [split /[,\s]\s*/, shift ] } +}; + +my $write = { + Libs => sub { " ".__PACKAGE__->compress(shift) } +}; + sub new { my $class = shift; @@ -49,11 +59,17 @@ sub add_property die "Duplicate property $name"; } push(@{$self->{proplist}}, $name); + my $v; if (defined $value) { - $self->{properties}->{$name} = [split /\s+/, $value] ; + if (defined $parse->{$name}) { + $v = $parse->{$name}($value); + } else { + $v = [split /\s+/, $value] ; + } } else { - $self->{properties}->{$name} = []; + $v = []; } + $self->{properties}->{$name} = $v; } sub read_fh @@ -77,6 +93,10 @@ sub read_fh die "Incorrect cfg file $name"; } } + if (defined $cfg->{properties}->{Libs}) { + $cfg->{properties}->{Libs} = + $cfg->compress_list($cfg->{properties}->{Libs}); + } return $cfg; } @@ -97,9 +117,14 @@ sub write_fh } print $fh "\n\n"; foreach my $property (@{$self->{proplist}}) { - print $fh "$property:", - (map { " $_" } @{$self->{properties}->{$property}}), - "\n"; + my $p = $self->{properties}->{$property}; + print $fh "$property:"; + if (defined $write->{$property}) { + print $fh $write->{$property}($p); + } else { + print $fh (map { " $_" } @$p); + } + print $fh "\n"; } } |