summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-11-13 11:48:47 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-11-13 11:48:47 +0000
commit36b86cf7488c3abcd7c043b7b876b446e780c618 (patch)
tree389204beed4cf70e424d3ca81e7b7a752de8b345 /usr.sbin/pkg_add/OpenBSD
parentc653ebfbb06a735a5a647944357f87313acff6ef (diff)
likewise, packing-lists state will store refs to cwd, so make this
a true object with cwd()/set_cwd() functions.
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm7
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingList.pm37
2 files changed, 34 insertions, 10 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index 4a23f816f6e..5632b077dc7 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.69 2004/11/13 11:39:40 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.70 2004/11/13 11:48:46 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -839,8 +839,7 @@ sub keyword() { 'cwd' }
sub destate
{
my ($self, $state) = @_;
- my $name = File::Spec->canonpath($self->{name});
- $state->{cwd} = \$name;
+ $state->set_cwd($self->{name});
}
package OpenBSD::PackingElement::EndFake;
@@ -947,7 +946,7 @@ sub expand
}
if (m/\%D/) {
die "Bad expand" unless defined $state->{cwd};
- s/\%D/${$state->{cwd}}/g;
+ s/\%D/$state->cwd()/ge;
}
if (m/\%B/) {
die "Bad expand" unless defined $state->{lastfile};
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
index a8d004e47dc..e392d9445c7 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingList.pm,v 1.36 2004/11/13 11:39:40 espie Exp $
+# $OpenBSD: PackingList.pm,v 1.37 2004/11/13 11:48:46 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -17,20 +17,45 @@
use strict;
use warnings;
+
+package OpenBSD::PackingList::State;
+my $dot = '.';
+
+sub new
+{
+ my $class = shift;
+ bless { default_owner=>'root',
+ default_group=>'bin',
+ default_mode=> 0444,
+ cwd=>\$dot}, $class;
+}
+
+sub cwd
+{
+ return ${$_[0]->{cwd}};
+}
+
+sub set_cwd
+{
+ my ($self, $p) = @_;
+
+ require File::Spec;
+
+ $p = File::Spec->canonpath($p);
+ $self->{cwd} = \$p;
+}
+
package OpenBSD::PackingList;
use OpenBSD::PackingElement;
use OpenBSD::PackageInfo;
-my $dot = '.';
sub new
{
my $class = shift;
bless {state =>
- {default_owner=>'root',
- default_group=>'bin',
- default_mode=> 0444,
- cwd=>\$dot} }, $class;
+ OpenBSD::PackingList::State->new()
+ }, $class;
}
sub read