From b4623aff1da0bf87aa947b3be427a4b31468fab3 Mon Sep 17 00:00:00 2001 From: espie Date: Mon, 7 Jun 2010 15:27:52 +0000 Subject: [PATCH] reorg a bit to always pass logger to init_cores, and always print out directory signatures --- infrastructure/build/DPB/Core.pm | 11 +++++----- infrastructure/build/DPB/Logger.pm | 20 ++++++++++++++---- infrastructure/build/DPB/Signature.pm | 30 +++++++++++++++++++++++++-- infrastructure/build/dpb3 | 3 ++- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/infrastructure/build/DPB/Core.pm b/infrastructure/build/DPB/Core.pm index 962de8f3128..81abe975f7d 100644 --- a/infrastructure/build/DPB/Core.pm +++ b/infrastructure/build/DPB/Core.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Core.pm,v 1.12 2010/05/04 09:45:41 espie Exp $ +# $OpenBSD: Core.pm,v 1.13 2010/06/07 15:27:52 espie Exp $ # # Copyright (c) 2010 Marc Espie # @@ -171,14 +171,10 @@ sub reap_kid return $kid; } -my $inited = 0; sub reap { my ($class, $all) = @_; my $reaped = 0; - if (!$inited) { - DPB::Core::Factory->init_cores; - } $class->handle_events; $reaped++ while $class->reap_kid(waitpid(-1, WNOHANG)) > 0; return $reaped; @@ -358,6 +354,7 @@ sub new sub finalize { my ($self, $core) = @_; + $self->{signature}->print_out($core, $self->{logger}); if ($self->{signature}->matches($core, $self->{logger})) { for my $i (1 .. $core->prop->{jobs}) { ref($core)->new($core->hostname, $core->prop)->mark_ready; @@ -384,9 +381,13 @@ sub new } } +my $inited = 0; + sub init_cores { my ($self, $logger, $startup) = @_; + return if $inited; + for my $core (values %$init) { my $job = DPB::Job::Init->new($logger); if (!defined $core->prop->{jobs}) { diff --git a/infrastructure/build/DPB/Logger.pm b/infrastructure/build/DPB/Logger.pm index fff7a2ae3ff..6aec24d0106 100644 --- a/infrastructure/build/DPB/Logger.pm +++ b/infrastructure/build/DPB/Logger.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Logger.pm,v 1.3 2010/05/04 09:45:41 espie Exp $ +# $OpenBSD: Logger.pm,v 1.4 2010/06/07 15:27:52 espie Exp $ # # Copyright (c) 2010 Marc Espie # @@ -36,12 +36,24 @@ sub logfile return $log; } +sub _open +{ + my ($self, $mode, $name) = @_; + my $log = $self->logfile($name); + open my $fh, $mode, $log or die "Can't write to $log: $!\n"; + return $fh; +} + sub open { my ($self, $name) = @_; - my $log = $self->logfile($name); - open my $fh, ">>", $log or die "Can't write to $log: $!\n"; - return $fh; + return $self->_open('>>', $name); +} + +sub create +{ + my ($self, $name) = @_; + return $self->_open('>', $name); } sub log_pkgpath diff --git a/infrastructure/build/DPB/Signature.pm b/infrastructure/build/DPB/Signature.pm index f0a0433aff3..dfd9b66796a 100644 --- a/infrastructure/build/DPB/Signature.pm +++ b/infrastructure/build/DPB/Signature.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Signature.pm,v 1.8 2010/05/06 15:50:13 espie Exp $ +# $OpenBSD: Signature.pm,v 1.9 2010/06/07 15:27:52 espie Exp $ # # Copyright (c) 2010 Marc Espie # @@ -57,6 +57,21 @@ sub compare1 return $r; } +sub print_out +{ + my ($self, $dir, $fh) = @_; + for my $k (sort keys %$self) { + next if $k eq 'la'; + next if !defined $self->{$k}; + print $fh "\t", $self->{$k}->to_string, "\n"; + } + if (defined $self->{la}) { + for my $v (sort keys %{$self->{la}}) { + print $fh "\t$dir/$v.la\n"; + } + } +} + sub compare { my ($s1, $s2, $h1, $h2) = @_; @@ -144,10 +159,21 @@ sub matches my $log = $logger->open('signature'); print $log "$r\n"; return 0; - clsoe $log; + close $log; } else { return 1; } } } + +sub print_out +{ + my ($self, $core, $logger) = @_; + my $log = $logger->create($core->hostname.".sig"); + for my $dir (OpenBSD::Paths->library_dirs) { + print $log "$dir: \n"; + $self->{$dir}->print_out("$dir/lib", $log); + } +} + 1; diff --git a/infrastructure/build/dpb3 b/infrastructure/build/dpb3 index e7e1f80ff5e..7dd52592ee4 100755 --- a/infrastructure/build/dpb3 +++ b/infrastructure/build/dpb3 @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: dpb3,v 1.16 2010/05/22 08:42:21 espie Exp $ +# $OpenBSD: dpb3,v 1.17 2010/06/07 15:27:52 espie Exp $ # # Copyright (c) 2010 Marc Espie # @@ -181,6 +181,7 @@ if (@build_files > 0) { $heuristics->finished_parsing; } +DPB::Core::Factory->init_cores($logger); my $builder = DPB::PortBuilder->new( $opt_c, $opt_s, $opt_u, $opt_U, $fullrepo, $logger, $ports, $make, $heuristics);