summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-04-30 09:31:26 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-04-30 09:31:26 +0000
commitdcfdab11cfbc95a5bff1cac8f8fb8f0804c82331 (patch)
tree7bf739962c436c1d25e9387715ca3eb4ce4c18ef /usr.sbin
parentf8e1be2a852d88a7c884638ccf15b0fd4b336db7 (diff)
move checksumming capabilities into base class
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/pkg_create50
1 files changed, 25 insertions, 25 deletions
diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create
index e4050d00b63..09a7e8dfd06 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.67 2007/04/30 09:30:03 espie Exp $
+# $OpenBSD: pkg_create,v 1.68 2007/04/30 09:31:25 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -80,6 +80,30 @@ sub makesum_plist
$self->add_object($plist);
}
+use OpenBSD::md5;
+
+sub compute_checksum
+{
+ my ($self, $result, $fname, $stash) = @_;
+
+ if (-l $fname) {
+ my $value = readlink $fname;
+ $result->make_symlink($value);
+ } elsif (-f _) {
+ my ($dev, $ino, $size) = (stat _)[0,1,7];
+ if (defined $stash->{"$dev/$ino"}) {
+ $result->make_hardlink($stash->{"$dev/$ino"});
+ } else {
+ $stash->{"$dev/$ino"} = $fname;
+ $result->add_md5(OpenBSD::md5::fromfile($fname));
+ $result->add_size($size);
+ }
+ } else {
+ print STDERR "Error in package: $fname does not exist\n";
+ $main::errors++;
+ }
+}
+
package OpenBSD::PackingElement::PkgConflict;
sub avert_duplicates_and_other_checks
{
@@ -183,30 +207,6 @@ sub verify_checksum
}
package OpenBSD::PackingElement::FileBase;
-use OpenBSD::md5;
-
-sub compute_checksum
-{
- my ($self, $result, $fname, $stash) = @_;
-
- if (-l $fname) {
- my $value = readlink $fname;
- $result->make_symlink($value);
- } elsif (-f _) {
- my ($dev, $ino, $size) = (stat _)[0,1,7];
- if (defined $stash->{"$dev/$ino"}) {
- $result->make_hardlink($stash->{"$dev/$ino"});
- } else {
- $stash->{"$dev/$ino"} = $fname;
- $result->add_md5(OpenBSD::md5::fromfile($fname));
- $result->add_size($size);
- }
- } else {
- print STDERR "Error in package: $fname does not exist\n";
- $main::errors++;
- }
-}
-
sub makesum_plist
{
my ($self, $plist, $base, $stash) = @_;