diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-06-18 10:47:04 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-06-18 10:47:04 +0000 |
commit | 23f72804857bec013f8ffa103f42ac1fb1f849e3 (patch) | |
tree | ce96a64e9f81fc8a7441126f5923b95e45298bd4 | |
parent | 82351d991e59bf56dff6fac296a0f2a365ca1f33 (diff) |
add tag no shadow, to allow us to specify that we do NOT want tempfiles
into some directories.
a few minor style tweaks, such as using a nice join(map()) to build some
strings.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Add.pm | 10 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Delete.pm | 9 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 60 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Replace.pm | 4 |
4 files changed, 59 insertions, 24 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm index c61b55904d7..89f85d27ab2 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.79 2007/06/16 11:50:49 espie Exp $ +# $OpenBSD: Add.pm,v 1.80 2007/06/18 10:47:03 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -341,6 +341,14 @@ sub install $name.'='.$self->{value}); } +package OpenBSD::PackingElement::DirBase; +sub prepare_for_addition +{ + my ($self, $state, $pkgname) = @_; + return unless $self->{noshadow}; + $state->{noshadow}->{$self->{destdir}.$self->fullname} = 1; +} + package OpenBSD::PackingElement::FileBase; use OpenBSD::Error; use File::Basename; diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index 39e469aa154..ed780746c5d 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.68 2007/06/16 11:50:49 espie Exp $ +# $OpenBSD: Delete.pm,v 1.69 2007/06/18 10:47:03 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -299,6 +299,13 @@ sub record_shared } package OpenBSD::PackingElement::DirBase; +sub prepare_for_deletion +{ + my ($self, $state, $pkgname) = @_; + return unless $self->{noshadow}; + $state->{noshadow}->{$self->{destdir}.$self->fullname} = 1; +} + sub delete { my ($self, $state) = @_; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index cd2f41cd06e..32de9812e08 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.141 2007/06/17 12:09:36 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.142 2007/06/18 10:47:03 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -132,7 +132,8 @@ sub fullstring sub stringize { - return $_[0]->{name}; + my $self = shift; + return $self->{name}; } sub IsFile() { 0 } @@ -357,7 +358,6 @@ sub make_hardlink sub IsFile() { 1 } - package OpenBSD::PackingElement::File; our @ISA=qw(OpenBSD::PackingElement::FileBase); @@ -585,6 +585,8 @@ sub add if ($args eq 'no checksum') { $plist->{state}->{lastfile}->{nochecksum} = 1; + } elsif ($args eq 'no shadow') { + $plist->{state}->{lastdir}->{noshadow} = 1; } else { my $object = $plist->{state}->{lastfileobject}; $object->{tags}->{$args} = 1; @@ -726,9 +728,9 @@ sub may_quote } } -sub stringize($) +sub stringize { - my $self = $_[0]; + my $self = shift; return "subdir=".$self->{subdir}." cdrom=".may_quote($self->{cdrom}). " ftp=".may_quote($self->{ftp}); } @@ -770,10 +772,11 @@ sub new def => $def }, $class; } -sub stringize($) +sub stringize { - my $self = $_[0]; - return $self->{pkgpath}.':'.$self->{pattern}.':'.$self->{def}; + my $self = shift; + return join(':', map { $self->{$_}} + (qw(pkgpath pattern def))); } sub spec @@ -868,12 +871,11 @@ sub check return 1; } -sub stringize($) +sub stringize { - my $self = $_[0]; - return $self->{name}.':'.$self->{uid}.':'.$self->{group}.':'. - $self->{class}.':'.$self->{comment}.':'.$self->{home}.':'. - $self->{shell}; + my $self = shift; + return join(':', map { $self->{$_}} + (qw(name uid group class comment home shell))); } package OpenBSD::PackingElement::NewGroup; @@ -906,7 +908,8 @@ sub check sub stringize($) { my $self = $_[0]; - return $self->{name}.':'.$self->{gid}; + return join(':', map { $self->{$_}} + (qw(name gid))); } package OpenBSD::PackingElement::Cwd; @@ -1008,7 +1011,7 @@ sub new sub stringize { - my $self = $_[0]; + my $self = shift; return $self->{name}.$self->{mode}.$self->{value}; } @@ -1019,8 +1022,8 @@ our @ISA=qw(OpenBSD::PackingElement::Action); sub expand { - my $state = $_[2]; - local $_ = $_[1]; + my ($self, $state) = @_; + local $_ = $self->{name}; if (m/\%F/o) { die "Bad expand" unless defined $state->{lastfile}; s/\%F/$state->{lastfile}->{name}/g; @@ -1043,7 +1046,7 @@ sub expand sub destate { my ($self, $state) = @_; - $self->{expanded} = $self->expand($self->{name}, $state); + $self->{expanded} = $self->expand($state); } sub run @@ -1116,12 +1119,29 @@ our @ISA=qw(OpenBSD::PackingElement::FileObject); package OpenBSD::PackingElement::DirBase; our @ISA=qw(OpenBSD::PackingElement::DirlikeObject); -sub stringize($) +sub destate { - my $self = $_[0]; + my ($self, $state) = @_; + $state->{lastdir} = $self; + $self->SUPER::destate($state); +} + + +sub stringize +{ + my $self = shift; return $self->{name}."/"; } +sub write +{ + my ($self, $fh) = @_; + $self->SUPER::write($fh); + if (defined $self->{noshadow}) { + print $fh "\@tag no shadow\n"; + } +} + package OpenBSD::PackingElement::Dir; our @ISA=qw(OpenBSD::PackingElement::DirBase); diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm index c4f2418b4b4..756598fbd76 100644 --- a/usr.sbin/pkg_add/OpenBSD/Replace.pm +++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Replace.pm,v 1.41 2007/06/16 11:50:49 espie Exp $ +# $OpenBSD: Replace.pm,v 1.42 2007/06/18 10:47:03 espie Exp $ # # Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org> # @@ -106,7 +106,7 @@ sub extract my $d = dirname($file->{destdir}.$file->{name}); # we go back up until we find an existing directory. # hopefully this will be on the same file system. - while (!-d $d && -e _) { + while (!-d $d && -e _ || defined $state->{noshadow}->{$d}) { $d = dirname($d); } if ($state->{not}) { |