diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 53 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Delete.pm | 50 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Vstat.pm | 43 |
3 files changed, 75 insertions, 71 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index e13006c9336..a30fe381579 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.56 2007/05/28 11:15:11 espie Exp $ +# $OpenBSD: Add.pm,v 1.57 2007/05/28 12:16:55 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -300,28 +300,13 @@ sub prepare_for_addition my $s = OpenBSD::Vstat::add($fname, $self->{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"; - } - $state->{problems}++; + $s->report_ro($state, $fname); } 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"; - } - $state->{overflow} = 1; - $state->{problems}++; + $s->report_overflow($state, $fname); } } @@ -433,28 +418,13 @@ sub prepare_for_addition 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"; - } - $state->{problems}++; + $s->report_ro($state, $fname); } 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"; - } - $state->{overflow} = 1; - $state->{problems}++; + $s->report_overflow($state, $fname); } } @@ -607,27 +577,22 @@ sub prepare_for_addition if ($self->exec_on_add) { my $s2 = OpenBSD::Vstat::filestat($cname); if (defined $s2 && $s2->{noexec}) { - Warn "Error: ", $s2->{dev}, " is noexec ($cname)\n"; - $state->{problems}++; + $s2->report_noexec($state, $cname); } } my $s = OpenBSD::Vstat::add($fname, $self->{size}, \$pkgname); return unless defined $s; if ($s->{ro}) { - Warn "Error: ", $s->{dev}, " is read-only ($fname)\n"; - $state->{problems}++; + $s->report_ro($state, $fname); } if ($s->{noexec} && $self->exec_on_delete) { - Warn "Error: ", $s->{dev}, " is noexec ($fname)\n"; - $state->{problems}++; + $s->report_noexec($state, $fname); } if ($state->{forced}->{kitchensink} && $state->{not}) { return; } if ($s->avail < 0) { - Warn "Error: ", $s->{dev}, " is not large enough ($fname)\n"; - $state->{overflow} = 1; - $state->{problems}++; + $s->report_overflow($state, $fname); } } diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index dac8350bdc9..e532dcb6bbc 100644 --- a/usr.sbin/pkg_add/OpenBSD/Delete.pm +++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Delete.pm,v 1.47 2007/05/28 11:15:11 espie Exp $ +# $OpenBSD: Delete.pm,v 1.48 2007/05/28 12:16:55 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -108,20 +108,7 @@ sub validate_plist $state->{problems} = 0; $state->{totsize} = 0; - $plist->prepare_for_deletion($state); - my $dir = installed_info($plist->pkgname); - for my $i (info_names()) { - my $fname = $dir.$i; - if (-e $fname) { - my $size = (stat _)[7]; - my $s = OpenBSD::Vstat::remove($fname, $size); - next unless defined $s; - if ($s->{ro}) { - Warn "Error: ", $s->{dev}, " is read-only ($fname)\n"; - $state->{problems}++; - } - } - } + $plist->prepare_for_deletion($state, $plist->pkgname); Fatal "fatal issues in deinstalling ", $plist->pkgname if $state->{problems}; $state->{totsize} = 1 if $state->{totsize} == 0; @@ -363,21 +350,14 @@ use OpenBSD::Vstat; sub prepare_for_deletion { - my ($self, $state) = @_; + my ($self, $state, $pkgname) = @_; my $fname = $state->{destdir}.$self->fullname; $state->{totsize} += $self->{size} if defined $self->{size}; my $s = OpenBSD::Vstat::remove($fname, $self->{size}); 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 removed from ", - $s->{dev}, "\n"; - } - $state->{problems}++; + $s->report_ro($state, $fname); } } @@ -438,6 +418,28 @@ sub delete } } +package OpenBSD::PackingElement::SpecialFile; +use OpenBSD::PackageInfo; + +sub prepare_for_deletetion +{ + my ($self, $state, $pkgname) = @_; + + my $fname = installed_info($pkgname).$self->{name}; + my $size = $self->{size}; + if (!defined $size) { + $size = (stat $fname)[7]; + } + my $s = OpenBSD::Vstat::remove($fname, $self->{size}); + return unless defined $s; + if ($s->{ro}) { + $s->report_ro($state, $fname); + } + if ($s->{noexec} && $self->exec_on_delete) { + $s->report_noexec($state, $fname); + } +} + package OpenBSD::PackingElement::Sample; use OpenBSD::md5; use OpenBSD::Error; diff --git a/usr.sbin/pkg_add/OpenBSD/Vstat.pm b/usr.sbin/pkg_add/OpenBSD/Vstat.pm index 6ebe056cba0..0af1ffb1559 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.26 2007/05/27 22:18:14 espie Exp $ +# $OpenBSD: Vstat.pm,v 1.27 2007/05/28 12:16:55 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -71,7 +71,7 @@ sub init_devices() } } close($cmd1) or print STDERR "Error running mount: $!\n"; - $giveup = { used => 0 }; + $giveup = { used => 0, dev => '???' }; bless $giveup, "OpenBSD::Vstat::Failsafe"; } @@ -194,12 +194,49 @@ sub tally() package OpenBSD::Vstat::MountPoint; sub avail { - my $self = $_[0]; + my $self = shift; return $self->{avail} - $self->{used}/$self->{blocksize}; } +sub report_ro +{ + my ($s, $state, $fname) = @_; + + if ($state->{very_verbose} or ++($s->{problems}) < 4) { + print STDERR "Error: ", $s->{dev}, + " is read-only ($fname)\n"; + } elsif ($s->{problems} == 4) { + print STDERR "Error: ... more files on ", $s->{dev}, "\n"; + } + $state->{problems}++; +} + +sub report_overflow +{ + my ($s, $state, $fname) = @_; + + if ($state->{very_verbose} or ++($s->{problems}) < 4) { + print STDERR "Error: ", $s->{dev}, + " is not large enough ($fname)\n"; + } elsif ($s->{problems} == 4) { + print STDERR "Error: ... more files do not fit on ", + $s->{dev}, "\n"; + } + $state->{problems}++; + $state->{overflow} = 1; +} + +sub report_noexec +{ + my ($s, $state, $fname) = @_; + print STDERR "Error: ", $s->{dev}, " is noexec ($fname)\n"; + $state->{problems}++; +} + package OpenBSD::Vstat::Failsafe; +our @ISA=(qw(OpenBSD::Vstat::MountPoint)); + sub avail { return 1; |