From b1a99bfe922d9636aedd85d5a14aa01ce59bf207 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Thu, 5 Aug 2004 23:36:41 +0000 Subject: refactor classes in PackingElement to share more code. - all files go through FileBase, all directories go through DirBase. - dirclass() is used to switch classes based on final /, so that @sample, @extra, and @file all take directories as well. - set NoDuplicateNames() more thoroughly. - make sure all no-default-conflict objects are correct. compute_fullname() checks for absolute paths, allowed for @sample and @extra. lastfile only gets set for actual files. special names like INSTALL are only checked for normal files. add a CVSTag class for @comment $OpenBSD$, so that these get sorted first. Changes for make-plist rewrite: clone() method that can create copies of all hash objects, to specialize if needed. add_object() method so that add() is now new() followed by add_object() for most objects (useful for cloned objects). Check that plist has a name in pkg_create, allowing PackingList to write unnamed plists. --- usr.sbin/pkg_add/OpenBSD/PackingList.pm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'usr.sbin/pkg_add/OpenBSD/PackingList.pm') diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index f302e8539a1..37adf5682c4 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm @@ -1,4 +1,4 @@ -# $OpenBSD: PackingList.pm,v 1.16 2004/08/03 12:33:48 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.17 2004/08/05 23:36:40 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -73,7 +73,7 @@ sub DirrmOnly my ($fh, $cont) = @_; local $_; while (<$fh>) { - next unless m/^\@(?:cwd|dirrm|dir|fontdir|mandir|name)\b/ || m/^[^\@].*\/$/; + next unless m/^\@(?:cwd|dirrm|dir|fontdir|mandir|name)\b/ || m/^\@(?:sample|extra)\b.*\/$/ || m/^[^\@].*\/$/; &$cont($_); } } @@ -121,16 +121,19 @@ MAINLOOP: sub write { - my ($self, $fh) = @_; - if (!defined $self->{name}) { - print STDERR "Can't write unnamed packing list\n"; - exit 1; - } - $self->{name}->write($fh); - if (defined $self->{'no-default-conflict'}) { - $self->{'no-default-conflict'}->write($fh); + my ($self, $fh, $w) = @_; + + $w = sub { + my ($o, $fh) = @_; + $o->write($fh); + } unless defined $w; + + if (defined $self->{cvstags}) { + for my $item (@{$self->{cvstags}}) { + $item->write($fh); + } } - for my $unique_item (qw(extrainfo arch)) { + for my $unique_item (qw(name no-default-conflict extrainfo arch)) { $self->{$unique_item}->write($fh) if defined $self->{$unique_item}; } for my $listname (qw(pkgcfl pkgdep newdepend libdepend items)) { -- cgit v1.2.3