diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2010-06-07 09:54:29 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2010-06-07 09:54:29 +0000 |
commit | 64580240830d1828dbe872e372d70326d82d0609 (patch) | |
tree | 7cdb0b192efc1400c1365dd0371b9cad104f915c /usr.sbin | |
parent | f08145417ac3028f7e7ab87a0d8502bc3b4d01bc (diff) |
check symlinks upfront, so we don't warn if they don't exist, assuming
they point to the correct location.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgCheck.pm | 69 |
1 files changed, 47 insertions, 22 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm b/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm index a9477f3a00a..bd212fd6e0a 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCheck.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCheck.pm,v 1.5 2010/06/07 09:18:11 espie Exp $ +# $OpenBSD: PkgCheck.pm,v 1.6 2010/06/07 09:54:28 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -47,12 +47,13 @@ sub basic_check my $name = $state->{destdir}.$self->fullname; $state->{known}{dirname($name)}{basename($name)} = 1; - if (!-e $name) { - $state->log("$name should exist\n"); - } if ($self->{symlink}) { if (!-l $name) { - $state->log("$name is not a symlink\n"); + if (!-e $name) { + $state->log("$name should be a symlink but does not exist"); + } else { + $state->log("$name is not a symlink\n"); + } } else { if (readlink($name) ne $self->{symlink}) { $state->log("$name should point to $self->{symlink} but points to ", readlink($name), " instead\n"); @@ -60,6 +61,13 @@ sub basic_check } return; } + if (!-e $name) { + if (-l $name) { + $state->log("$name points to non-existent ".readlink($name)."\n"); + } else { + $state->log("$name should exist\n"); + } + } if (!-f _) { $state->log("$name is not a file\n"); } @@ -320,14 +328,26 @@ sub ask_add_deps } } -sub sanity_check +sub for_all_packages { - my ($self, $state, $l) = @_; - $state->progress->set_header("Packing-list sanity"); + my ($self, $state, $l, $msg, $code) = @_; + + my $total = scalar @$l; + $state->progress->set_header($msg); my $i = 0; for my $name (@$l) { + $state->progress->show(++$i, $total); + next if $state->{removed}{$name}; + &$code($name); + } +} + +sub sanity_check +{ + my ($self, $state, $l) = @_; + $self->for_all_packages($state, $l, "Packing-list sanity", sub { + my $name = shift; my $info = installed_info($name); - $state->progress->show(++$i, scalar @$l); if (-f $info) { $state->errsay("$name: $info should be a directory"); if ($info =~ m/\.core$/) { @@ -359,24 +379,32 @@ sub sanity_check $self->may_remove($state, $name); } $plist->mark_available_lib($plist->pkgname); - } + $state->{exists}{$plist->pkgname} = 1; + }); } sub dependencies_check { my ($self, $state, $l) = @_; - $state->progress->set_header("Dependencies"); OpenBSD::SharedLibs::add_libs_from_system($state->{destdir}); my $i = 0; - for my $name (@$l) { - $state->progress->show(++$i, scalar @$l); + $self->for_all_packages($state, $l, "Dependencies", sub { + my $name = shift; my $plist = OpenBSD::PackingList->from_installation($name, \&OpenBSD::PackingList::DependOnly); my $req = OpenBSD::Requiring->new($name); my @known = $req->list; - my %not_yet =map {($_, 1)} @known; - my %possible = map {($_, 1)} @known; + my %not_yet = (); + my %possible = (); my %other = (); + for my $pkg (@known) { + $not_yet{$pkg} = 1; + if ($state->{exists}{$pkg}) { + $possible{$pkg} = 1; + } else { + $state->errsay("$name: bogus dependency $pkg"); + } + } $state->{localbase} = $plist->localbase; $plist->find_dependencies($state, $l, \%not_yet, \%possible, \%other); @@ -391,17 +419,14 @@ sub dependencies_check join(' ', @todo)); $self->ask_add_deps($state, $name, \@todo, $req); } - } + }); } sub package_files_check { my ($self, $state, $l) = @_; - $state->progress->set_header("Files from packages"); - my $i = 0; - for my $name (@$l) { - next if $state->{removed}{$name}; - $state->progress->show(++$i, scalar @$l); + $self->for_all_packages($state, $l, "Files from packages", sub { + my $name = shift; my $plist = OpenBSD::PackingList->from_installation($name); $state->log->set_context($name); if ($state->{quick}) { @@ -410,7 +435,7 @@ sub package_files_check $plist->thorough_check($state); } $plist->mark_available_lib($plist->pkgname); - } + }); } sub localbase_check |