summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2003-11-04 18:11:43 +0000
committerMarc Espie <espie@cvs.openbsd.org>2003-11-04 18:11:43 +0000
commit18dbb3dddbbf4b3f96032198b1119331543cf37a (patch)
tree22b10ef5d429f974d832af6bc796f6d1f539c7ef /usr.sbin/pkg_add
parent2ed1b7f1d3cfa89b1dc0d79159bf5091f71e8da0 (diff)
make pkg_create aware of duplicate files in plist, which are a bad thing.
okay sturm@
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r--usr.sbin/pkg_add/pkg_create23
1 files changed, 22 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create
index 2c55daf99e2..03a7a0e4fb4 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.3 2003/10/31 17:43:20 espie Exp $
+# $OpenBSD: pkg_create,v 1.4 2003/11/04 18:11:42 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -99,6 +99,26 @@ sub makesum
}
}
+sub avert_duplicates
+{
+ my ($self) = @_;
+ my $allfiles = {};
+ my $duplicates = 0;
+ for my $item (@{$self->{items}}) {
+ if ($item->IsFile()) {
+ my $n = $item->fullname();
+ if (defined $allfiles->{$n}) {
+ print STDERR "Error in packing-list: duplicate file $n\n";
+ $duplicates++;
+ }
+ $allfiles->{$n} = 1;
+ }
+ }
+ if ($duplicates) {
+ exit(1);
+ }
+}
+
package main;
our ($opt_p, $opt_f, $opt_c, $opt_d, $opt_v, $opt_i, $opt_k, $opt_r, $opt_D,
@@ -183,6 +203,7 @@ $plist->fromfile($dir.CONTENTS) or die "Can't open packing list";
my $base = $opt_S || '/';
$plist->makesum($base);
+$plist->avert_duplicates();
my @cmd = $plist->archive_cmd($dir, $base);
if (defined $opt_i) {