From 7413f2d2dae1765ed562a78aa1e0d80a63578a1f Mon Sep 17 00:00:00 2001 From: espie Date: Tue, 10 Aug 2004 21:01:01 +0000 Subject: [PATCH] better diagnostic logic: first output all PLISTs in a tmp dir, then compare with original set, and report all differences. Then check that original can be moved to orig, and do the move. That way, make plist on a set of unchanged lists will be silent, and can be used irregardless of the presence of P*.orig files. --- infrastructure/install/make-plist | 59 ++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/infrastructure/install/make-plist b/infrastructure/install/make-plist index 57ca8e6b14d..ecccc30496f 100755 --- a/infrastructure/install/make-plist +++ b/infrastructure/install/make-plist @@ -1,5 +1,5 @@ #! /usr/bin/perl -# $OpenBSD: make-plist,v 1.55 2004/08/10 08:45:21 espie Exp $ +# $OpenBSD: make-plist,v 1.56 2004/08/10 21:01:01 espie Exp $ # Copyright (c) 2004 Marc Espie # # Permission to use, copy, modify, and distribute this software for any @@ -24,6 +24,7 @@ use File::Spec; use File::Find; use File::Compare; use File::Basename; +use File::Temp; my $base; @@ -765,13 +766,6 @@ while (my ($k, $v) = each %$foundcomments) { print "Not accounted for: \@comment $k\n"; } -for my $plist (@l) { - my $orig = $plist->{original}; - if (defined $orig) { - die $orig->{filename}.".orig present" - if -e $orig->{filename}.".orig"; - } -} { local ($), $>); @@ -782,22 +776,53 @@ for my $plist (@l) { if (defined $ENV{'OWNER'}) { $> = $ENV{'OWNER'}; } + + my $dir = File::Temp::tempdir ( CLEANUP => 1); + $dir.='/'; + # write out everything for my $plist (@l) { if (!$plist->{nonempty}) { - print $plist->{filename}, " is empty\n"; next; } + $plist->tofile($dir.basename($plist->{filename})); + } + + for my $plist (@l) { my $orig = $plist->{original}; - if (defined $orig) { - rename($orig->{filename}, $orig->{filename}.".orig"); - } - $plist->tofile($plist->{filename}); - if (defined $orig) { - if (compare($plist->{filename}, $orig->{filename}.".orig") == 0) { - print $plist->{filename}, " unchanged, removing ", $orig->{filename}.".orig\n"; - unlink($orig->{filename}.".orig"); + if ($plist->{nonempty}) { + if (defined $orig) { + if (compare($dir.basename($plist->{filename}), $orig->{filename}) != 0) { + print $plist->{filename}, " changed\n"; + $plist->{changed} = 1; + } + } else { + print $plist->{filename}, " is new\n"; + $plist->{changed} = 1; + } + } else { + if (defined $orig) { + print $plist->{filename}, " empty\n"; + $plist->{changed} = 1; } } } + + for my $plist (@l) { + my $orig = $plist->{original}; + if (defined $orig) { + die $orig->{filename}.".orig present" + if -e $orig->{filename}.".orig"; + } + } + for my $plist (@l) { + my $orig = $plist->{original}; + if ($plist->{changed}) { + + if (defined $orig) { + rename($orig->{filename}, $orig->{filename}.".orig"); + } + $plist->tofile($plist->{filename}); + } + } }