summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2014-01-07 10:38:13 +0000
committerMarc Espie <espie@cvs.openbsd.org>2014-01-07 10:38:13 +0000
commita2d0c5c5088d2f80ab8853e8671ebd29df0bfd6b (patch)
tree6e9ff4e748a1f77e4f79706df797f5998ff6fe08
parenta90e7bb0d56e6d6ac7801f5663ee2e6f7185d242 (diff)
if HISTORY_DIR is defined, create a new "permanent" file during build.
this file records the sha256 of all elements in the archive, and keeps track of changes (quite simply: sha256 that were already present end up at the end of the file). Start recording these *now*, so that we have enough info to shuffle packages later.
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgCreate.pm64
1 files changed, 63 insertions, 1 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
index d6f956ad84f..91b2198e39b 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.84 2014/01/07 01:30:28 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.85 2014/01/07 10:38:12 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
@@ -234,6 +234,7 @@ sub pretend_to_archive
$self->comment_create_package;
}
+sub record_digest {}
sub archive {}
sub comment_create_package {}
sub grab_manpages {}
@@ -497,6 +498,13 @@ sub comment_create_package
package OpenBSD::PackingElement::FileBase;
+sub record_digest
+{
+ my ($self, $list) = @_;
+ if (defined $self->{d}) {
+ push(@$list, $self->{d}->stringize);
+ }
+}
sub archive
{
my ($self, $state) = @_;
@@ -1496,6 +1504,56 @@ sub tweak_libraries
}
}
+sub save_history
+{
+ my ($self, $plist, $dir) = @_;
+
+ unless (-d $dir) {
+ require File::Path;
+
+ File::Path::make_path($dir);
+ }
+
+ my $name = $plist->fullpkgpath;
+ $name =~ s,/,.,g;
+ my $fname = "$dir/$name";
+
+ # grab the old stuff:
+ # - order
+ # - and presence
+ my @old;
+ my (%known, %found);
+ if (open(my $f, '<', $fname)) {
+ while (<$f>) {
+ chomp;
+ push(@old, $_);
+ $known{$_} = 1;
+ }
+ close($f);
+ }
+ my @new;
+ $plist->record_digest(\@new);
+ open(my $f, ">", "$fname.new") or return;
+
+ # split list
+ # - first, unknown stuff
+ for my $i (@new) {
+ if ($known{$i}) {
+ $found{$i} = 1;
+ } else {
+ print $f "$i\n";
+ }
+ }
+ # - then known stuff, preserve the order
+ for my $i (@old) {
+ if ($found{$i}) {
+ print $f "$i\n";
+ }
+ }
+ close($f);
+ rename("$fname.new", $fname);
+}
+
sub parse_and_run
{
my ($self, $cmd) = @_;
@@ -1566,6 +1624,10 @@ sub parse_and_run
} else {
$plist = $self->make_plist_with_sum($state, $plist);
}
+ if ($state->defines('HISTORY_DIR')) {
+ $self->save_history($plist,
+ $state->defines('HISTORY_DIR'));
+ }
$self->show_bad_symlinks($state);
$state->end_status;
}