summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/pkg_delete
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pkg_add/pkg_delete')
-rw-r--r--usr.sbin/pkg_add/pkg_delete58
1 files changed, 57 insertions, 1 deletions
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