diff options
author | 2009-10-11 10:49:05 +0000 | |
---|---|---|
committer | 2009-10-11 10:49:05 +0000 | |
commit | 9dac67a3054d58e017d4764ddccd76e8f0161c09 (patch) | |
tree | a1dd320eef63d2b612a2bf76e7f0d013579ee8e3 | |
parent | d_type isn't portable so use lstat to get dirent modes. Suggested by and (diff) | |
download | wireguard-openbsd-9dac67a3054d58e017d4764ddccd76e8f0161c09.tar.xz wireguard-openbsd-9dac67a3054d58e017d4764ddccd76e8f0161c09.zip |
move a bit of code around, update (C)
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index fc6f6048277..a4946300fea 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,9 +1,9 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.336 2009/05/24 11:05:24 espie Exp $ +# $OpenBSD: pkg_add,v 1.337 2009/10/11 10:49:05 espie Exp $ # -# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> +# Copyright (c) 2003-2009 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -40,6 +40,117 @@ my $bad = 0; our %defines = (); our $not; +package OpenBSD::PackingList; + +sub uses_old_libs +{ + my $plist = shift; + require OpenBSD::RequiredBy; + + return grep {/^\.libs\d*\-/o} + OpenBSD::Requiring->new($plist->pkgname)->list; +} + +sub has_new_sig +{ + my ($plist, $state) = @_; + if (!defined $plist->{new_sig}) { + my $n = OpenBSD::PackingList->from_installation($plist->pkgname)->signature; + my $o = $plist->signature; + print "Comparing full signature for ", $plist->pkgname, " \"$o\" vs. \"$n\": ", $n eq $o ? "equal\n" : "different\n" + if $state->{very_verbose}; + $plist->{new_sig} = $n ne $o; + } + return $plist->{new_sig}; +} + +package OpenBSD::Handle; +use OpenBSD::PackageInfo; + +sub get_plist +{ + my ($handle, $state) = @_; + + my $location = $handle->{location}; + my $pkg = $handle->{pkgname}; + + if ($state->{verbose}) { + print $state->deptree_header($pkg); + print "parsing $pkg\n"; + } + my $plist = $location->grabPlist; + unless (defined $plist) { + print "Can't find CONTENTS from ", $location->url, "\n"; + $location->close_with_client_error; + $location->wipe_info; + $handle->set_error(BAD_PACKAGE); + return; + } + if ($plist->localbase ne $state->{localbase}) { + print "Localbase mismatch: package has: ", $plist->localbase, " , user wants: ", $state->{localbase}, "\n"; + $location->close_with_client_error; + $location->wipe_info; + $handle->set_error(BAD_PACKAGE); + return; + } + my $pkgname = $handle->{pkgname} = $plist->pkgname; + + if (is_installed($pkgname) && + (!$state->{allow_replacing} || + !$state->{defines}->{installed} && + !$plist->has_new_sig($state) && + !$plist->uses_old_libs)) { + $handle->{tweaked} = + OpenBSD::Add::tweak_package_status($pkgname, $state); + print "Not reinstalling $pkgname\n" if $state->{verbose} and + !$handle->{tweaked}; + $state->mark_installed($pkgname); + $location->close_now; + $location->wipe_info; + $handle->set_error(ALREADY_INSTALLED); + return; + } + if ($pkg ne '-') { + if (!defined $pkgname or + OpenBSD::PackageName::url2pkgname($pkg) ne $pkgname) { + print "Package name is not consistent ???\n"; + $location->close_with_client_error; + $location->wipe_info; + $handle->set_error(BAD_PACKAGE); + return; + } + } + $handle->{plist} = $plist; +} + +sub complete +{ + my ($handle, $state) = @_; + + return if $handle->has_error; + + my $pkgname = $handle->{pkgname}; + + if (!defined $handle->{location}) { + my $location = OpenBSD::PackageLocator->find($pkgname, + $state->{arch}); + if (!$location) { + print $state->deptree_header($pkgname); + $handle->set_error(NOT_FOUND); + $handle->{tweaked} = + OpenBSD::Add::tweak_package_status($pkgname, + $state); + if (!$handle->{tweaked}) { + print "Can't find $pkgname\n"; + } + return; + } + $handle->{location} = $location; + } + if (!defined $handle->{plist}) { + $handle->get_plist($state); + } +} package OpenBSD::pkg_add::State; our @ISA=(qw(OpenBSD::pkg_foo::State)); @@ -728,114 +839,3 @@ if ($bad) { exit(1); } -package OpenBSD::PackingList; - -sub uses_old_libs -{ - my $plist = shift; - require OpenBSD::RequiredBy; - - return grep {/^\.libs\d*\-/o} - OpenBSD::Requiring->new($plist->pkgname)->list; -} - -sub has_new_sig -{ - my ($plist, $state) = @_; - if (!defined $plist->{new_sig}) { - my $n = OpenBSD::PackingList->from_installation($plist->pkgname)->signature; - my $o = $plist->signature; - print "Comparing full signature for ", $plist->pkgname, " \"$o\" vs. \"$n\": ", $n eq $o ? "equal\n" : "different\n" - if $state->{very_verbose}; - $plist->{new_sig} = $n ne $o; - } - return $plist->{new_sig}; -} - -package OpenBSD::Handle; -use OpenBSD::PackageInfo; - -sub get_plist -{ - my ($handle, $state) = @_; - - my $location = $handle->{location}; - my $pkg = $handle->{pkgname}; - - if ($state->{verbose}) { - print $state->deptree_header($pkg); - print "parsing $pkg\n"; - } - my $plist = $location->grabPlist; - unless (defined $plist) { - print "Can't find CONTENTS from ", $location->url, "\n"; - $location->close_with_client_error; - $location->wipe_info; - $handle->set_error(BAD_PACKAGE); - return; - } - if ($plist->localbase ne $state->{localbase}) { - print "Localbase mismatch: package has: ", $plist->localbase, " , user wants: ", $state->{localbase}, "\n"; - $location->close_with_client_error; - $location->wipe_info; - $handle->set_error(BAD_PACKAGE); - return; - } - my $pkgname = $handle->{pkgname} = $plist->pkgname; - - if (is_installed($pkgname) && - (!$state->{allow_replacing} || - !$state->{defines}->{installed} && - !$plist->has_new_sig($state) && - !$plist->uses_old_libs)) { - $handle->{tweaked} = - OpenBSD::Add::tweak_package_status($pkgname, $state); - print "Not reinstalling $pkgname\n" if $state->{verbose} and - !$handle->{tweaked}; - $state->mark_installed($pkgname); - $location->close_now; - $location->wipe_info; - $handle->set_error(ALREADY_INSTALLED); - return; - } - if ($pkg ne '-') { - if (!defined $pkgname or - OpenBSD::PackageName::url2pkgname($pkg) ne $pkgname) { - print "Package name is not consistent ???\n"; - $location->close_with_client_error; - $location->wipe_info; - $handle->set_error(BAD_PACKAGE); - return; - } - } - $handle->{plist} = $plist; -} - -sub complete -{ - my ($handle, $state) = @_; - - return if $handle->has_error; - - my $pkgname = $handle->{pkgname}; - - if (!defined $handle->{location}) { - my $location = OpenBSD::PackageLocator->find($pkgname, - $state->{arch}); - if (!$location) { - print $state->deptree_header($pkgname); - $handle->set_error(NOT_FOUND); - $handle->{tweaked} = - OpenBSD::Add::tweak_package_status($pkgname, - $state); - if (!$handle->{tweaked}) { - print "Can't find $pkgname\n"; - } - return; - } - $handle->{location} = $location; - } - if (!defined $handle->{plist}) { - $handle->get_plist($state); - } -} |