From aa4bec8342bc433b9cc45237f416706fac18736e Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Fri, 1 Jun 2007 22:35:48 +0000 Subject: very small clean-up of dependencies list handling. --- usr.sbin/pkg_add/OpenBSD/Dependencies.pm | 9 ++++----- usr.sbin/pkg_add/OpenBSD/Replace.pm | 5 ++--- usr.sbin/pkg_add/OpenBSD/RequiredBy.pm | 9 ++++----- usr.sbin/pkg_add/pkg_add | 6 +++--- usr.sbin/pkg_add/pod/OpenBSD::RequiredBy.pod | 6 +++--- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm index 8cb633fa640..bf563df6be8 100644 --- a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm +++ b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Dependencies.pm,v 1.43 2007/05/31 22:33:45 espie Exp $ +# $OpenBSD: Dependencies.pm,v 1.44 2007/06/01 22:35:46 espie Exp $ # # Copyright (c) 2005-2007 Marc Espie # @@ -184,12 +184,11 @@ sub register_dependencies require OpenBSD::RequiredBy; my $pkgname = $self->pkgname; + my @l = $self->dependencies; - my $r = OpenBSD::Requiring->new($pkgname); - - for my $dep ($self->dependencies) { + OpenBSD::Requiring->new($pkgname)->add(@l); + for my $dep (@l) { OpenBSD::RequiredBy->new($dep)->add($pkgname); - $r->add($dep); } } diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm index 829bfaca859..1991c8bef1b 100644 --- a/usr.sbin/pkg_add/OpenBSD/Replace.pm +++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Replace.pm,v 1.29 2007/06/01 22:06:03 espie Exp $ +# $OpenBSD: Replace.pm,v 1.30 2007/06/01 22:35:46 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie # @@ -374,8 +374,7 @@ sub walk_depends_closure print "\t$pkg2\n" if $state->{beverbose}; $done->{$pkg2} = 1; $write->add($pkg2); - my $l = OpenBSD::Requiring->new($pkg2); - $l->add($name); + OpenBSD::Requiring->new($pkg2)->add($name); $depend = 1; } } diff --git a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm index 888547ee0e9..176303f00f0 100644 --- a/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm +++ b/usr.sbin/pkg_add/OpenBSD/RequiredBy.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: RequiredBy.pm,v 1.14 2007/05/14 09:49:27 espie Exp $ +# $OpenBSD: RequiredBy.pm,v 1.15 2007/06/01 22:35:47 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie # @@ -21,12 +21,11 @@ use warnings; package OpenBSD::RequirementList; use OpenBSD::PackageInfo; -sub fill_entries($) +sub fill_entries { my $self = shift; if (!exists $self->{entries}) { - my $l = {}; - $self->{entries} = $l; + my $l = $self->{entries} = {}; if (-f $self->{filename}) { open(my $fh, '<', $self->{filename}) or @@ -34,9 +33,9 @@ sub fill_entries($) $self->{filename}, ": $!"; local $_; while(<$fh>) { - chomp $_; s/\s+$//; next if /^$/; + chomp; $l->{$_} = 1; } close($fh); diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index b9b15e4da5b..333b6658a17 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.302 2007/06/01 21:50:46 espie Exp $ +# $OpenBSD: pkg_add,v 1.303 2007/06/01 22:35:46 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -780,8 +780,8 @@ sub uses_old_libs my $plist = shift; require OpenBSD::RequiredBy; - my $d = OpenBSD::Requiring->new($plist->pkgname); - return grep {/^\.libs\-/} $d->list; + return grep {/^\.libs\-/} + OpenBSD::Requiring->new($plist->pkgname)->list; } sub has_new_sig diff --git a/usr.sbin/pkg_add/pod/OpenBSD::RequiredBy.pod b/usr.sbin/pkg_add/pod/OpenBSD::RequiredBy.pod index 096168e52fe..4927bd26daa 100644 --- a/usr.sbin/pkg_add/pod/OpenBSD::RequiredBy.pod +++ b/usr.sbin/pkg_add/pod/OpenBSD::RequiredBy.pod @@ -1,4 +1,4 @@ -$OpenBSD: OpenBSD::RequiredBy.pod,v 1.2 2005/08/17 18:53:08 espie Exp $ +$OpenBSD: OpenBSD::RequiredBy.pod,v 1.3 2007/06/01 22:35:47 espie Exp $ =head1 NAME @@ -16,7 +16,7 @@ OpenBSD::RequiredBy - manage installed package dependencies my $o2 = OpenBSD::Requiring->new($pkgname); - print "Requirements for $pkgname are ", join(' ',$o2->list()), "\n"; + print "Requirements for $pkgname are ", join(' ',$o2->list), "\n"; # add some reverse dependencies $o->add($reverse_dep1, $reverse_dep2); @@ -47,7 +47,7 @@ dependencies, C<$o =OpenBSD::Requiring-Enew($pkgname)> gives access to the forward dependencies. -Such an object can be used to list the dependencies C<$o-Elist()>, +Such an object can be used to list the dependencies C<$o-Elist>, add names to them C<$o-Eadd(name1, name2, ...)> or remove name from them C<$o-Edelete(name1, name2, ...)>. -- cgit v1.2.3