summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2006-02-16 11:21:59 +0000
committerMarc Espie <espie@cvs.openbsd.org>2006-02-16 11:21:59 +0000
commitd7614498fdc78317e5cc1b7f0330fa0149c77bff (patch)
tree59f1ba97d9551a6f072856160c85ca5181d92042 /usr.sbin
parentbbc5bccbb8d13f33bdb682557f3e796427ab5be3 (diff)
validate() can also take sample files into account.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm36
1 files changed, 34 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 7429cf6d0bf..8450ed3f3e3 100644
--- a/usr.sbin/pkg_add/OpenBSD/Add.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Add.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Add.pm,v 1.47 2006/02/09 09:42:10 espie Exp $
+# $OpenBSD: Add.pm,v 1.48 2006/02/16 11:21:58 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -412,10 +412,42 @@ use File::Copy;
sub validate
{
- my $self = shift;
+ my ($self, $state, $problems, $colliding, $totsize, $pkgname) = @_;
if (!defined $self->{copyfrom}) {
Fatal "\@sample element does not reference a valid file\n";
}
+ my $fname = $state->{destdir}.$self->fullname();
+ # If file already exists, we won't change it
+ if (OpenBSD::Vstat::vexists($fname)) {
+ return;
+ }
+ my $size = $self->{copyfrom}->{size};
+ $$totsize += $size if defined $size;
+ my $s = OpenBSD::Vstat::add($fname, $size, \$pkgname);
+ return unless defined $s;
+ if ($s->{ro}) {
+ if ($state->{very_verbose} or ++($s->{problems}) < 4) {
+ Warn "Error: ", $s->{dev},
+ " is read-only ($fname)\n";
+ } elsif ($s->{problems} == 4) {
+ Warn "Error: ... more files can't be written to ",
+ $s->{dev}, "\n";
+ }
+ $$problems++;
+ }
+ if ($state->{forced}->{kitchensink} && $state->{not}) {
+ return;
+ }
+ if ($s->avail() < 0) {
+ if ($state->{very_verbose} or ++($s->{problems}) < 4) {
+ Warn "Error: ", $s->{dev},
+ " is not large enough ($fname)\n";
+ } elsif ($s->{problems} == 4) {
+ Warn "Error: ... more files do not fit on ",
+ $s->{dev}, "\n";
+ }
+ $$problems++;
+ }
}
sub install