diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-08-03 12:29:46 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-08-03 12:29:46 +0000 |
commit | 10fa5eb30005e85a8222b78e57b41847bcbfe059 (patch) | |
tree | 36e467f34b3aef489e76193050bfdb04d86ed54c | |
parent | 57bba588fb2f5a81bccbc1d52774403db366f7cc (diff) |
Support @sample, tested by fries@.
@mandir and @fontdir keywords recognition.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 25 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingList.pm | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 38 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete | 58 |
4 files changed, 120 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 7b09db64202..83b11517eac 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,4 +1,4 @@ -# $OpenBSD: PackingElement.pm,v 1.15 2004/08/02 12:12:36 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.16 2004/08/03 12:29:45 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -272,6 +272,17 @@ sub IsFile() { 1 } sub NoDuplicateNames() { 1 } +package OpenBSD::PackingElement::Sample; +our @ISA=qw(OpenBSD::PackingElement); +__PACKAGE__->setKeyword('sample'); +sub keyword() { "sample" } +sub destate +{ + my ($self, $state) = @_; + $self->{copyfrom} = $state->{lastfile}; + $self->compute_modes($state); +} + package OpenBSD::PackingElement::InfoFile; our @ISA=qw(OpenBSD::PackingElement::File); __PACKAGE__->setKeyword('info'); @@ -677,6 +688,18 @@ sub stringize($) return $_[0]->{name}."/"; } +package OpenBSD::PackingElement::Fontdir; +our @ISA=qw(OpenBSD::PackingElement::Dir); +__PACKAGE__->setKeyword('fontdir'); +sub keyword() { "fontdir" } +sub needs_keyword { 1 } + +package OpenBSD::PackingElement::Mandir; +our @ISA=qw(OpenBSD::PackingElement::Dir); +__PACKAGE__->setKeyword('mandir'); +sub keyword() { "mandir" } +sub needs_keyword { 1 } + package OpenBSD::PackingElement::Extra; our @ISA=qw(OpenBSD::PackingElement); diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index b12b1ac136c..b37e46018c9 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.14 2004/08/02 12:12:36 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.15 2004/08/03 12:29:45 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -73,7 +73,7 @@ sub DirrmOnly my ($fh, $cont) = @_; local $_; while (<$fh>) { - next unless m/^\@cwd\b/ || m/^\@dirrm\b/ || m/^\@dir\b/ || m/^\@name\b/ || m/^[^\@].*\/$/; + next unless m/^\@cwd\b/ || m/^\@dirrm\b/ || m/^\@dir\b/ || m/^\@fontdir\b/ || m/^\@name\b/ || m/^[^\@].*\/$/; &$cont($_); } } diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 27a1b8dec70..ca4df5a06d1 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.37 2004/08/02 12:12:36 espie Exp $ +# $OpenBSD: pkg_add,v 1.38 2004/08/03 12:29:44 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -95,6 +95,42 @@ sub install $self->set_modes($destdir.$fullname); } +package OpenBSD::PackingElement::Sample; +use File::Copy; +use OpenBSD::md5; + +sub install +{ + my ($self, $archive, $destdir, $verbose, $not) = @_; + + my $filename = $destdir.$self->{name}; + my $orig = $self->{copyfrom}; + if (!defined $orig) { + die "\@sample element does not reference a valid file\n"; + } + my $origname = $destdir.$orig->fullname(); + if (-e $filename) { + print "The existing configuration file $filename has NOT been changed\n"; + if (defined $orig->{md5}) { + my $md5 = OpenBSD::md5::fromfile($filename); + if ($md5 eq $orig->{md5}) { + print "\t(but it seems to match the sample file $origname)\n"; + } else { + print "\tIt does not match the sample file origname\n"; + print "You may wish to update it manually\n"; + } + } + } else { + if ($not) { + print "The configuration file $filename would be installed from $origname\n"; + } else { + copy($origname, $filename); + $self->set_modes($filename); + print "The configuration file $filename has been installed from $origname\n"; + } + } +} + package OpenBSD::PackingElement::InfoFile; use File::Basename; diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete index 80500b05761..463ec19f7ff 100644 --- a/usr.sbin/pkg_add/pkg_delete +++ b/usr.sbin/pkg_add/pkg_delete @@ -1,6 +1,6 @@ #!/usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_delete,v 1.28 2004/08/02 12:12:36 espie Exp $ +# $OpenBSD: pkg_delete,v 1.29 2004/08/03 12:29:45 espie Exp $ # # Copyright (c) 2003 Marc Espie. # @@ -174,6 +174,62 @@ sub delete } } +package OpenBSD::PackingElement::Sample; +use OpenBSD::md5; +sub delete +{ + my ($self, $state) = @_; + my $name = $self->{name}; + my $realname = $state->{destdir}.$name; + + my $orig = $self->{copyfrom}; + if (!defined $orig) { + die "\@sample element does not reference a valid file\n"; + } + my $origname = $state->{destdir}.$orig->fullname(); + if (! -e $realname) { + print "Config file $realname does not exist\n"; + return; + } + if (! -f $realname) { + print "Config file $realname is not a file\n"; + return; + } + if (!defined $orig->{md5}) { + print "Problem: config file $name does not have an md5 checksum\n"; + print "NOT deleting: $realname\n"; + $self->log_pkgname($state); + OpenBSD::Logger::log "rm $state->{destdirname}$name\n"; + return; + } + + if ($state->{quick}) { + unless ($state->{extra}) { + print "NOT'deleting config file $realname\n"; + return; + } + } else { + my $md5 = OpenBSD::md5::fromfile($realname); + if ($md5 eq $orig->{md5}) { + print "Config file $realname identical to sample\n"; + } else { + print "Config file $realname NOT identical to sample\n"; + unless ($state->{extra}) { + print "NOT deleting $realname\n"; + return; + } + } + } + return if $state->{not}; + print "deleting $realname\n"; + if (!unlink $realname) { + print "Problem deleting $realname\n"; + $self->log_pkgname($state); + OpenBSD::Logger::log "rm $state->{destdirname}$name\n"; + } +} + + package OpenBSD::PackingElement::InfoFile; use File::Basename; sub delete |