summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2008-06-11 09:43:26 +0000
committerMarc Espie <espie@cvs.openbsd.org>2008-06-11 09:43:26 +0000
commitbcb7563761d3dea56ef7ed05b1fbca295b6747f5 (patch)
treea7c9a9c74fef9afaf988b0a9f3ac7fe4742db099 /usr.sbin
parentf926fe585d8fd182975f4f38e8245bbd4acd1821 (diff)
defer to the packing element for computing md5
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Add.pm9
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Delete.pm10
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Replace.pm6
-rw-r--r--usr.sbin/pkg_add/pkg_create6
4 files changed, 12 insertions, 19 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Add.pm b/usr.sbin/pkg_add/OpenBSD/Add.pm
index 8fd72fa0ac3..7df6f2701e6 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.82 2008/03/08 12:07:45 espie Exp $
+# $OpenBSD: Add.pm,v 1.83 2008/06/11 09:43:25 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -76,11 +76,10 @@ sub record_partial_installation
# last file may have not copied correctly
my $last = $n->{state}->{lastfile};
if (defined $last && defined($last->{md5})) {
- require OpenBSD::md5;
my $old = $last->{md5};
my $lastname = $last->realname($state);
- $last->{md5} = OpenBSD::md5::fromfile($lastname);
+ $last->{md5} = $last->compute_md5($lastname);
if ($old ne $last->{md5}) {
print "Adjusting md5 for $lastname from ",
unpack('H*', $old), " to ", unpack('H*', $last->{md5}), "\n";
@@ -510,9 +509,9 @@ sub install
if ($state->{verbose}) {
print "The existing file $filename has NOT been changed\n";
if (defined $orig->{md5}) {
- require OpenBSD::md5;
- my $md5 = OpenBSD::md5::fromfile($filename);
+ # XXX assume this would be the same type of file
+ my $md5 = $self->compute_md5($filename);
if ($md5 eq $orig->{md5}) {
print "(but it seems to match the sample file $origname)\n";
} else {
diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm
index 59068d96f5d..81b0d5a886d 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.75 2008/03/11 08:46:14 espie Exp $
+# $OpenBSD: Delete.pm,v 1.76 2008/06/11 09:43:25 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -248,7 +248,7 @@ sub do_not_delete
if (-l $realname) {
$self->{symlink} = readlink $realname;
} elsif (-f _) {
- $self->{md5} = OpenBSD::md5::fromfile($realname);
+ $self->{md5} = $self->compute_md5($realname);
} elsif (-d _) {
# what should we do ?
}
@@ -350,7 +350,6 @@ sub should_run
}
package OpenBSD::PackingElement::FileBase;
-use OpenBSD::md5;
use OpenBSD::Error;
use OpenBSD::Vstat;
@@ -401,7 +400,7 @@ sub delete
$state->print("Couldn't delete $realname (no checksum)\n");
return;
}
- my $md5 = OpenBSD::md5::fromfile($realname);
+ my $md5 = $self->compute_md5($realname);
if ($md5 ne $self->{md5}) {
print "Problem: checksum doesn't match for ",
$self->fullname, "\n";
@@ -480,7 +479,6 @@ sub copy_old_stuff
}
package OpenBSD::PackingElement::Sample;
-use OpenBSD::md5;
use OpenBSD::Error;
use File::Basename;
@@ -516,7 +514,7 @@ sub delete
return;
}
} else {
- my $md5 = OpenBSD::md5::fromfile($realname);
+ my $md5 = $self->compute_md5($realname);
if ($md5 eq $orig->{md5}) {
print "File $realname identical to sample\n" if $state->{not} or $state->{verbose};
} else {
diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm
index fe56bb59933..ca62b9b9dfc 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.44 2008/03/08 12:07:45 espie Exp $
+# $OpenBSD: Replace.pm,v 1.45 2008/06/11 09:43:25 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -446,15 +446,13 @@ sub save_old_libraries
$stub_list->to_cache;
$o->{plist}->to_cache;
} else {
- require OpenBSD::md5;
-
mkdir($dest);
open my $descr, '>', $dest.DESC;
print $descr "Stub libraries for $oldname\n";
close $descr;
my $f = OpenBSD::PackingElement::FDESC->add($stub_list, DESC);
$f->{ignore} = 1;
- $f->{md5} = OpenBSD::md5::fromfile($dest.DESC);
+ $f->{md5} = $f->compute_md5($dest.DESC);
$stub_list->to_installation;
$o->{plist}->to_installation;
}
diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create
index a5cfeebb60d..4eeaf88d923 100644
--- a/usr.sbin/pkg_add/pkg_create
+++ b/usr.sbin/pkg_add/pkg_create
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_create,v 1.116 2008/04/07 11:02:24 espie Exp $
+# $OpenBSD: pkg_create,v 1.117 2008/06/11 09:43:25 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -76,8 +76,6 @@ sub verify_checksum
{
}
-use OpenBSD::md5;
-
sub compute_checksum
{
my ($self, $result, $base, $stash) = @_;
@@ -96,7 +94,7 @@ sub compute_checksum
$result->make_hardlink($stash->{"$dev/$ino"});
} else {
$stash->{"$dev/$ino"} = $name;
- $result->add_md5(OpenBSD::md5::fromfile($fname));
+ $result->add_md5($self->compute_md5($fname));
$result->add_size($size);
}
} else {