In http://marc.info/?l=openbsd-ports&m=117587445905884&w=2 i submitted a patch to ease @sample handling after pkg_add -r. See below for the full rationale.
Marc liked the general idea but wanted to do some refactoring. So here's a reminder, improved in a few respects: - Do not create and advertise empty patches. - Do not use temporary files. Use pipe-open instead. - In verbose mode, after stating that the local version differs from the sample, also report whether or not the sample changed. The following patch is also available from http://www.studis.de/Software/pkg_add-update_sample-v1.patch Here is the full rationale, it's the same as last time: When a file installed by a @sample packing list directive was changed locally, manually updating it can be tedious after pkg_add -r. Even worse, after updating many packages using pkg_add -u, finding out which config files need updating is non-trivial. The following patch prepares a diff between the old and the new default versions. Just read this diff, apply it to your installed version, manually resolve any conflicts and you are done. Index: OpenBSD/Add.pm =================================================================== RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/Add.pm,v retrieving revision 1.81 diff -u -p -r1.81 Add.pm --- OpenBSD/Add.pm 25 Jun 2007 09:30:16 -0000 1.81 +++ OpenBSD/Add.pm 23 Sep 2007 17:25:58 -0000 @@ -509,15 +509,38 @@ sub install if (-e $filename) { if ($state->{verbose}) { print "The existing file $filename has NOT been changed\n"; + } + if (!$state->{quick}) { if (defined $orig->{md5}) { require OpenBSD::md5; my $md5 = OpenBSD::md5::fromfile($filename); if ($md5 eq $orig->{md5}) { - print "(but it seems to match the sample file $origname)\n"; + if ($state->{verbose}) { + print "(but it seems to match the sample file $origname)\n"; + } } else { - print "It does NOT match the sample file $origname\n"; - print "You may wish to update it manually\n"; + my $manual = $state->{verbose}; + if ($manual) { + print "It does NOT match the sample file $origname\n"; + } + if (defined $self->{patch}) { + if (@{$self->{patch}}) { + if (open PATCH, ">$filename.patch") { + print PATCH @{$self->{patch}}; + close PATCH; + $state->print('Consider patch -d / < ' + . $filename . ".patch\n"); + $manual = 0; + } + } elsif ($manual) { + print "The sample file did not change\n"; + $manual = 0; + } + } + if ($manual) { + print "You may wish to update it manually\n"; + } } } } Index: OpenBSD/Replace.pm =================================================================== RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/Replace.pm,v retrieving revision 1.42 diff -u -p -r1.42 Replace.pm --- OpenBSD/Replace.pm 18 Jun 2007 10:47:03 -0000 1.42 +++ OpenBSD/Replace.pm 23 Sep 2007 17:25:58 -0000 @@ -143,6 +143,19 @@ sub extract package OpenBSD::PackingElement::Sample; sub extract { + my ($self, $state) = @_; + return if $state->{quick}; + + my $destdir = $state->{destdir}; + my $filename = $destdir . $self->fullname; + $filename =~ s,^/,,; + my $orig = $self->{copyfrom}; + if (open DIFF, "diff -u -L $filename.orig -L $filename " . + $destdir . $orig->fullname . ' ' . + $orig->{tempname} . ' |') { + $self->{patch} = [<DIFF>]; + close DIFF; + } } package OpenBSD::PackingElement::Sampledir;
