diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-03-06 23:35:02 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-03-06 23:35:02 +0000 |
commit | b13a2c5c1515c9cc3845bf96cf25ef822e3192af (patch) | |
tree | 8621f80c20d614aa59f183db2a50bc3869f4d6ba /usr.sbin | |
parent | 4539f029e97c421ad749a389a714d1a2a82155ee (diff) |
get vfs size snapshotted and restored so that pkg_add -u has a harder
time overflowing the disk.
let stem work at the end of urls.
test sturm@ and bernd@,
okay deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 21 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageName.pm | 12 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Vstat.pm | 20 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 21 |
4 files changed, 57 insertions, 17 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index 2d68883fc16..ddc3563b582 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocator.pm,v 1.53 2006/03/08 12:10:47 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.54 2007/03/06 23:35:01 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -42,6 +42,15 @@ if (defined $ENV{PKG_PATH}) { $pkgpath->add(OpenBSD::PackageRepository->new("./")); } +sub path_parse +{ + use File::Basename; + + my ($pkgname, $path) = fileparse($_); + my $repository = OpenBSD::PackageRepository->new($path); + return ($repository, $path, $pkgname); +} + sub find { my $class = shift; @@ -59,10 +68,7 @@ sub find } my $package; if (m/\//) { - use File::Basename; - - my ($pkgname, $path) = fileparse($_); - my $repository = OpenBSD::PackageRepository->new($path); + my ($repository, undef, $pkgname) = path_parse($_); $package = $repository->find($pkgname, $arch, $srcpath); if (defined $package) { $pkgpath->add($repository); @@ -93,10 +99,7 @@ sub grabPlist } my $plist; if (m/\//) { - use File::Basename; - - my ($pkgname, $path) = fileparse($_); - my $repository = OpenBSD::PackageRepository->new($path); + my ($repository, undef, $pkgname) = path_parse($_); $plist = $repository->grabPlist($pkgname, $arch, $code); if (defined $plist) { $pkgpath->add($repository); diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm index 54b305f686b..d2d73b2290b 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageName.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageName.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageName.pm,v 1.13 2006/10/17 22:08:31 espie Exp $ +# $OpenBSD: PackageName.pm,v 1.14 2007/03/06 23:35:01 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -147,10 +147,10 @@ sub compile_stemlist bless $hash, "OpenBSD::PackageLocator::_compiled_stemlist"; } -sub available_stems +sub avail2stems { my $state = shift; - my @avail = OpenBSD::PackageLocator::available(); + my @avail = @_; if (@avail == 0) { require OpenBSD::Error; @@ -162,6 +162,12 @@ sub available_stems return OpenBSD::PackageName::compile_stemlist(@avail); } +sub available_stems +{ + my $state = shift; + return avail2stems($state, OpenBSD::PackageLocator::available()); +} + package OpenBSD::PackageLocator::_compiled_stemlist; sub findstem diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm index d88e198748f..3364d7bf33f 100644 --- a/usr.sbin/pkg_add/OpenBSD/Vstat.pm +++ b/usr.sbin/pkg_add/OpenBSD/Vstat.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Vstat.pm,v 1.15 2007/02/24 18:45:11 espie Exp $ +# $OpenBSD: Vstat.pm,v 1.16 2007/03/06 23:35:01 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -44,6 +44,24 @@ sub create_device($) return $n; } +sub remember_used +{ + my $h = {}; + while (my ($k, $v) = each %$devinfo) { + $h->{$k} = $v->{used}; + $v->{used} = 0; + } + return $h; +} + +sub restore_used +{ + my $h = shift; + while (my ($k, $v) = each %$h) { + $devinfo->{$k}->{used} += $v; + } +} + sub init_devices() { delete $ENV{'BLOCKSIZE'}; diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 9c5a7975071..08dc7bc4597 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.221 2007/02/04 12:46:54 espie Exp $ +# $OpenBSD: pkg_add,v 1.222 2007/03/06 23:35:01 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -280,7 +280,9 @@ sub really_add($$) } print "\n"; } + my $x = OpenBSD::Vstat::remember_used(); my $totsize = OpenBSD::Add::validate_plist($plist, $state); + OpenBSD::Vstat::restore_used($x); if (!defined $handle) { Fatal "Archive in $pkgname broken"; @@ -606,12 +608,20 @@ sub find_truenames { my ($old, $new, $state) = @_; - my $h; + my $allstems; for my $pkgname (@$old) { if (OpenBSD::PackageName::is_stem($pkgname)) { - if (!defined $h) { - $h = OpenBSD::PackageName::available_stems($state); + my ($h, $path, $repo); + if ($pkgname =~ m/\//) { + ($repo, $path, $pkgname) = OpenBSD::PackageLocator::path_parse($pkgname); + $h = OpenBSD::PackageName::avail2stems($state, $repo->available); + } else { + if (!defined $allstems) { + $allstems = OpenBSD::PackageName::available_stems($state); + } + $h = $allstems; + $path = ""; } my @l = $h->findstem($pkgname); if (@l > 1) { @@ -619,6 +629,9 @@ sub find_truenames } my $result = OpenBSD::Interactive::choose1($pkgname, $state->{interactive}, sort @l); if (defined $result) { + if (defined $path) { + $result = $path.$result; + } push(@$new, $result); } else { $bad = 1; |