summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2019-06-30 14:57:26 +0000
committerMarc Espie <espie@cvs.openbsd.org>2019-06-30 14:57:26 +0000
commit94c0bb6431c92978a0db8871177b3919b9f1d2ee (patch)
tree2cadbcb7a5073952b91167b324f9801ad66eee89 /usr.sbin
parent9b1c123e8645f076b05f1bc659c922b6f4baa5ef (diff)
refactor a bit of code: retrieve_fullname/retrieve_size, so that
special files are a bit less special. Leave ::Sample for now
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm28
-rw-r--r--usr.sbin/pkg_add/OpenBSD/AddDelete.pm37
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Delete.pm26
3 files changed, 45 insertions, 46 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 50077ef7527..783f1257453 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.180 2019/06/03 19:21:05 espie Exp $
+# $OpenBSD: Add.pm,v 1.181 2019/06/30 14:57:25 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -415,7 +415,7 @@ sub find_extractible
sub prepare_for_addition
{
my ($self, $state, $pkgname) = @_;
- my $fname = $state->{destdir}.$self->fullname;
+ my $fname = $self->retrieve_fullname($state, $pkgname);
# check for collisions with existing stuff
if ($state->vstat->exists($fname)) {
push(@{$state->{colliding}}, $self);
@@ -424,8 +424,8 @@ sub prepare_for_addition
return;
}
return if $state->defines('stub');
- my $s = $state->vstat->add($fname, $self->{tieto} ? 0 : $self->{size},
- $pkgname);
+ my $s = $state->vstat->add($fname,
+ $self->{tieto} ? 0 : $self->retrieve_size, $pkgname);
return unless defined $s;
if ($s->ro) {
$s->report_ro($state, $fname);
@@ -821,26 +821,6 @@ package OpenBSD::PackingElement::SpecialFile;
use OpenBSD::PackageInfo;
use OpenBSD::Error;
-sub prepare_for_addition
-{
- my ($self, $state, $pkgname) = @_;
-
- my $fname = installed_info($pkgname).$self->name;
- my $cname = $self->fullname;
- my $size = $self->{size};
- if (!defined $size) {
- $size = (stat $cname)[7];
- }
- my $s = $state->vstat->add($fname, $self->{size}, $pkgname);
- return unless defined $s;
- if ($s->ro) {
- $s->report_ro($state, $fname);
- }
- if ($s->avail < 0) {
- $s->report_overflow($state, $fname);
- }
-}
-
sub copy_info
{
my ($self, $dest, $state) = @_;
diff --git a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
index 8c74c503f59..b0cdba6df60 100644
--- a/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
+++ b/usr.sbin/pkg_add/OpenBSD/AddDelete.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: AddDelete.pm,v 1.84 2019/04/07 12:30:39 espie Exp $
+# $OpenBSD: AddDelete.pm,v 1.85 2019/06/30 14:57:25 espie Exp $
#
# Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org>
#
@@ -23,6 +23,41 @@ use warnings;
package main;
our $not;
+package OpenBSD::PackingElement::FileObject;
+sub retrieve_fullname
+{
+ my ($self, $state, $pkgname) = @_;
+ return $state->{destdir}.$self->fullname;
+}
+
+package OpenBSD::PackingElement::FileBase;
+sub retrieve_size
+{
+ my $self = shift;
+ return $self->{size};
+}
+
+package OpenBSD::PackingElement::SpecialFile;
+use OpenBSD::PackageInfo;
+sub retrieve_fullname
+{
+ my ($self, $state, $pkgname);
+ return installed_info($pkgname).$self->name;
+}
+
+package OpenBSD::PackingElement::FCONTENTS;
+sub retrieve_size
+{
+ my $self = shift;
+ my $size = 0;
+ my $cname = $self->fullname;
+ if (defined $cname) {
+ $size = (stat $cname)[7];
+ }
+ return $size;
+}
+
+
package OpenBSD::AddDelete;
use OpenBSD::Error;
use OpenBSD::Paths;
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm
index 1d1a4ca5101..4f88063e588 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.157 2018/07/07 11:32:01 espie Exp $
+# $OpenBSD: Delete.pm,v 1.158 2019/06/30 14:57:25 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -303,8 +303,8 @@ package OpenBSD::PackingElement::DirBase;
sub prepare_for_deletion
{
my ($self, $state, $pkgname) = @_;
- my $fname = $state->{destdir}.$self->fullname;
- $state->vstat->remove_directory($fname, $self);
+ $state->vstat->remove_directory(
+ $self->retrieve_fullname($state, $pkgname), $self);
}
sub delete
@@ -401,9 +401,9 @@ sub prepare_for_deletion
{
my ($self, $state, $pkgname) = @_;
- my $fname = $state->{destdir}.$self->fullname;
+ my $fname = $self->retrieve_fullname($state, $pkgname);
my $s;
- my $size = $self->{tied} ? 0 : $self->{size};
+ my $size = $self->{tied} ? 0 : $self->retrieve_size;
if ($state->{delete_first}) {
$s = $state->vstat->remove_first($fname, $size);
} else {
@@ -507,22 +507,6 @@ sub copy_old_stuff
package OpenBSD::PackingElement::SpecialFile;
use OpenBSD::PackageInfo;
-sub prepare_for_deletion
-{
- my ($self, $state, $pkgname) = @_;
-
- my $fname = $self->fullname;
- my $size = $self->{size};
- if (!defined $size) {
- $size = (stat $fname)[7];
- }
- my $s = $state->vstat->remove($fname, $self->{size});
- return unless defined $s;
- if ($s->ro) {
- $s->report_ro($state, $fname);
- }
-}
-
sub copy_old_stuff
{
}