summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/pkg_create
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-04-30 10:52:24 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-04-30 10:52:24 +0000
commitfd4383d6e091171ec427e497b48e5b0c9550a8ad (patch)
treee4511a42829fa48dd7e6d0fc779eb0b48e3a91ad /usr.sbin/pkg_add/pkg_create
parentb8fbfbbc7a40e0f644230728c273af43ea326bfd (diff)
unsimplify checksum creation, fix @link markers.
found out by bernd@
Diffstat (limited to 'usr.sbin/pkg_add/pkg_create')
-rw-r--r--usr.sbin/pkg_add/pkg_create34
1 files changed, 15 insertions, 19 deletions
diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create
index c4a788559dd..a25a40ccf9a 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.74 2007/04/30 10:30:50 espie Exp $
+# $OpenBSD: pkg_create,v 1.75 2007/04/30 10:52:23 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -88,7 +88,8 @@ use OpenBSD::md5;
sub compute_checksum
{
- my ($self, $result, $fname, $stash) = @_;
+ my ($self, $result, $base, $name, $stash) = @_;
+ my $fname = "$base/$name";
if (-l $fname) {
my $value = readlink $fname;
@@ -98,7 +99,7 @@ sub compute_checksum
if (defined $stash->{"$dev/$ino"}) {
$result->make_hardlink($stash->{"$dev/$ino"});
} else {
- $stash->{"$dev/$ino"} = $fname;
+ $stash->{"$dev/$ino"} = $name;
$result->add_md5(OpenBSD::md5::fromfile($fname));
$result->add_size($size);
}
@@ -110,22 +111,22 @@ sub compute_checksum
sub makesum_plist_filename
{
- my ($self, $plist, $fname, $stash) = @_;
- $self->compute_checksum($self, $fname, $stash);
+ my ($self, $plist, $base, $name, $stash) = @_;
+ $self->compute_checksum($self, $base, $name, $stash);
$self->add_object($plist);
}
sub verify_checksum_filename
{
- my ($self, $fname, $stash) = @_;
+ my ($self, $base, $name, $stash) = @_;
my $check = ref($self)->new($self->{name});
- $self->compute_checksum($check, $fname, $stash);
+ $self->compute_checksum($check, $base, $name, $stash);
for my $field (qw(symlink link md5 size)) {
if ((defined $check->{$field} && defined $self->{$field} &&
$check->{$field} ne $self->{$field}) ||
(defined $check->{$field} xor defined $self->{$field})) {
- print STDERR "Error: $field inconsistency for $fname\n";
+ print STDERR "Error: $field inconsistency for $name\n";
$main::errors++;
}
}
@@ -166,15 +167,13 @@ sub comment_create_package
sub makesum_plist
{
my ($self, $plist, $base, $stash, $infodir) = @_;
- my $fname = $infodir.'/'.$self->{name};
- $self->makesum_plist_filename($plist, $fname, $stash);
+ $self->makesum_plist_filename($plist, $infodir ,$self->{name}, $stash);
}
sub verify_checksum
{
my ($self, $base, $stash, $infodir) = @_;
- my $fname = $infodir.'/'.$self->{name};
- $self->verify_checksum_filename($fname, $stash);
+ $self->verify_checksum_filename($infodir, $self->{name}, $stash);
}
# override for CONTENTS: we cannot checksum this.
@@ -253,15 +252,13 @@ sub print_file
sub makesum_plist
{
my ($self, $plist, $base, $stash, $infodir) = @_;
- my $fname = $base.'/'.$self->fullname();
- $self->makesum_plist_filename($plist, $fname, $stash);
+ $self->makesum_plist_filename($plist, $base, $self->fullname(), $stash);
}
sub verify_checksum
{
my ($self, $base, $stash, $infodir) = @_;
- my $fname = $base.'/'.$self->fullname();
- $self->verify_checksum_filename($fname, $stash);
+ $self->verify_checksum_filename($base, $self->fullname(), $stash);
}
package OpenBSD::PackingElement::InfoFile;
@@ -271,10 +268,9 @@ sub makesum_plist
$self->SUPER::makesum_plist($plist, $base, $stash);
my $fname = $self->fullname();
for (my $i = 1; ; $i++) {
- my $n = "$base/$fname-$i";
- if (-e $n) {
+ if (-e "$base/$fname-$i") {
my $e = OpenBSD::PackingElement::File->add($plist, $self->{name}."-".$i);
- $e->compute_checksum($e, $n, $stash);
+ $e->compute_checksum($e, $base, "$fname-$i", $stash);
} else {
last;
}