[tmcode commit] r306 - in spine/branches/spine_2_2-devel: . docs lib/Spine publisher tests

0 views
Skip to first unread message

oss...@gmail.com

unread,
Nov 20, 2009, 9:46:42 AM11/20/09
to tmcode...@googlegroups.com
Author: richard
Date: Fri Nov 20 06:46:41 2009
New Revision: 306

Log:


Modified:
spine/branches/spine_2_2-devel/docs/ (props changed)
spine/branches/spine_2_2-devel/docs/README-EXAMPLE_CONFIG
spine/branches/spine_2_2-devel/lib/Spine/Data.pm
spine/branches/spine_2_2-devel/publisher/ (props changed)
spine/branches/spine_2_2-devel/publisher/spine-publisher
spine/branches/spine_2_2-devel/publisher/spine-publisher.conf.dist
spine/branches/spine_2_2-devel/publisher/spine-publisher.init
spine/branches/spine_2_2-devel/spine.spec (contents, props changed)
spine/branches/spine_2_2-devel/tests/ (props changed)
spine/branches/spine_2_2-devel/tests/Makefile (props changed)

Modified: spine/branches/spine_2_2-devel/docs/README-EXAMPLE_CONFIG
==============================================================================
--- spine/branches/spine_2_2-devel/docs/README-EXAMPLE_CONFIG Fri Nov 20 06:37:46 2009 (r305)
+++ spine/branches/spine_2_2-devel/docs/README-EXAMPLE_CONFIG Fri Nov 20 06:46:41 2009 (r306)
@@ -91,7 +91,7 @@
directories are directly translated to the permissions on the resulting file.
Once you've done that, spine can be used like this:

- spine --dryrun --croot /path/to/example_spine_config --host <hostname>
+ spine-mgmt --dryrun --croot /path/to/example_spine_config --host <hostname>

Note that the hostname MUST resolve using DNS.


Modified: spine/branches/spine_2_2-devel/lib/Spine/Data.pm
==============================================================================
--- spine/branches/spine_2_2-devel/lib/Spine/Data.pm Fri Nov 20 06:37:46 2009 (r305)
+++ spine/branches/spine_2_2-devel/lib/Spine/Data.pm Fri Nov 20 06:46:41 2009 (r306)
@@ -702,7 +702,7 @@
#
# This is ok as long as we're in a key template instance but it's not ok
# if we're in an overlay template instance. Ain't life grand?
- if ($in_template and not defined($Spine::Plugin::Template::KEYTT)) {
+ if ($in_template and not defined($Spine::Plugin::Templates::KEYTT)) {
$self->error("We've got an overlay template that's trying to call "
. "Spine::Data::set($key). This is bad.");
die (Template::Exception->new('Spine::Data::set()',

Modified: spine/branches/spine_2_2-devel/publisher/spine-publisher
==============================================================================
--- spine/branches/spine_2_2-devel/publisher/spine-publisher Fri Nov 20 06:37:46 2009 (r305)
+++ spine/branches/spine_2_2-devel/publisher/spine-publisher Fri Nov 20 06:46:41 2009 (r306)
@@ -1,5 +1,4 @@
#!/usr/bin/perl
-
# -*- mode: cperl; cperl-continued-brace-offset: -4; indent-tabs-mode: nil; -*-
# vim:shiftwidth=2:tabstop=8:expandtab:textwidth=78:softtabstop=4:ai:

@@ -39,7 +38,7 @@

use Fcntl;
use Getopt::Long qw(:config bundling);
-use POSIX qw(setsid setuid setgid :sys_wait_h);
+use POSIX qw(setsid setuid setgid mkfifo :sys_wait_h);
use Sys::Syslog qw(:standard :macros);

use Config::Simple;
@@ -73,24 +72,20 @@

# Set log level to max verbosity if debug mode, otherwise use the
# configured value.
-
setlogmask(gen_logmask($c->getval('main.loglevel')));
setlogmask(gen_logmask(7)) if (exists $opts{debug});

# In queue mode, we only modify the work queue and exit.
-
if (exists $opts{queue})
{
add_to_queue($opts{queue});
exit 0;
}

-
my $svn = svn_init();

# Properties only mode applies properties to the directory specified
# on the command line.
-
if (exists $opts{restoreprops})
{
plog(LOG_CRIT, "Specified directory does not exist \"$opts{restoreprops}\"", 1)
@@ -100,8 +95,10 @@
exit 0;
}

-# Daemonize.
+# Handle fifo creation and validation of ownership/perms.
+check_or_create_fifo();

+# Daemonize.
%SIG = daemon_set_sighandlers();
daemon_init($c->getval('main.pidfile'), $c->getval('main.user'),
$c->getval('main.group') );
@@ -109,8 +106,8 @@
my $repo_url = rm_trail_slash ( $c->getval('svn.repo_url') );
my $working_dir = rm_trail_slash ( $c->getval('svn.working_dir') );

-# Clean up the working directory and do a full SVN checkout.

+# Clean up the working directory and do a full SVN checkout.
plog(LOG_INFO, "Deleting contents of working directory $working_dir");
rmtree($working_dir);

@@ -121,11 +118,13 @@
if ($@) { plog(LOG_CRIT, "Failed initial svn checkout: $@", EXIT_DIE) }
plog(LOG_INFO, "Completed initial svn checkout at revision $co_rev");

+
# Main program loop.
plog(LOG_INFO, "Accepting requests");

while (not $s->daemon_check_exit)
{
+
open(FIFO, "<" . $c->getval('main.fifo')) ||
die "ERROR: Could not open named pipe";

@@ -227,11 +226,17 @@
my $rev = shift;
my $fifo = $c->getval('main.fifo');

- unless ( -e $fifo )
+ unless (-p $fifo)
{
plog(LOG_CRIT, "Invalid fifo specified", 1);
}

+ unless (-w $fifo)
+ {
+ plog(LOG_CRIT, "Fifo [$fifo] is not writable", 1);
+ }
+
+
sysopen(QUEUE_FIFO, $fifo, O_RDWR|O_APPEND|O_NONBLOCK);
print QUEUE_FIFO $rev . "\n";
close(QUEUE_FIFO);
@@ -263,6 +268,58 @@
}


+sub check_or_create_fifo
+{
+ my $fifo = $c->getval('main.fifo');
+ my $fifo_perms = $c->getval('main.fifo_perms', '0666');
+ my $fifo_uid = $c->getval('main.fifo_uid', 0);
+ my $fifo_gid = $c->getval('main.fifo_gid', 0);
+
+ my $perms = $fifo_perms;
+
+ # Generate a critical error if a file is already present where we expect
+ # our fifo to exist.
+ if ((-e $fifo) and (not -p $fifo))
+ {
+ plog(LOG_CRIT, "Fifo $fifo exists but is not a valid named pipe", 1);
+ }
+
+ # Check if our fifo permissions, uid and gid match the configuration
+ # and report if they do not.
+ if (-p $fifo)
+ {
+ my @stat = stat($fifo);
+ my $cur_perms = sprintf "%04o", $stat[2] & 07777;
+
+ if ($perms != $cur_perms)
+ {
+ plog(LOG_NOTICE, "Fifo permissions do not match config. " .
+ "This will need to be corrected manually.");
+ }
+
+ if (($fifo_uid != $stat[4]) or ($fifo_gid != $stat[5]))
+ {
+ plog(LOG_NOTICE, "Fifo uid/gid do not match config. " .
+ "This will need to be corrected manually.");
+ }
+ }
+
+ # Attempt to create a fifo.
+ if (not -p $fifo)
+ {
+ if (mkfifo($fifo, oct($perms)))
+ {
+ plog(LOG_INFO, "Created fifo $fifo with perms $perms");
+ chmod oct($perms), $fifo;
+ chown $fifo_uid, $fifo_gid, $fifo;
+ }
+ else
+ {
+ plog(LOG_CRIT, "Failed to create fifo $fifo", 1);
+ }
+ }
+}
+

sub bin2dec
{
@@ -282,7 +339,7 @@
sub rm_trail_slash
{
my $string = shift;
- $string =~ s#/+$##g;
+ $string =~ s|/+$||g;
return $string;
}

@@ -689,8 +746,8 @@
-c, --configfile <file>
Full path to the spine-publisher configuration file. Specifying
this on the command line overrides looking in the default
- locations, which are /etc/spine-publisher.conf and the current
- working directory.
+ locations, which are /etc/spine-mgmt/spine-publisher.conf,
+ /etc/spine-publisher.conf, and the current working directory.

-f, --foreground
Remain in the foreground, do not daemonize. Generally only used
@@ -839,6 +896,8 @@
$configfile = $self->{configfile};
}

+ elsif (-f "/etc/spine-mgmt/spine-publisher.conf")
+ { $configfile = "/etc/spine-mgmt/spine-publisher.conf" }
elsif (-f "/etc/spine-publisher.conf")
{ $configfile = "/etc/spine-publisher.conf" }
elsif (-f "spine-publisher.conf")
@@ -859,6 +918,7 @@
{
my $self = shift;
my $key = shift;
+ my $def_value = shift;

my $value = $self->{conf}->param($key);
$value = $self->_interpolate_string($value);
@@ -867,10 +927,14 @@
# we need to exit as to avoid generating potentially broken
# configballs.

- if (not defined $value)
+ if ((not defined $value) and (not defined $def_value))
{
$self->{plog}->(LOG_ERR,
- "Requested undefined config value: $key -- exiting.", 1);
+ "Required config value [$key] is missing -- exiting.", 1);
+ }
+ elsif ((not defined $value) and (defined $def_value))
+ {
+ $value = $def_value;
}

return $value;

Modified: spine/branches/spine_2_2-devel/publisher/spine-publisher.conf.dist
==============================================================================
--- spine/branches/spine_2_2-devel/publisher/spine-publisher.conf.dist Fri Nov 20 06:37:46 2009 (r305)
+++ spine/branches/spine_2_2-devel/publisher/spine-publisher.conf.dist Fri Nov 20 06:46:41 2009 (r306)
@@ -18,6 +18,9 @@

# Path to named pipe
fifo = /var/run/spine-publisher.fifo
+fifo_uid = 0
+fifo_gid = 0
+fifo_perms = 0666

# User and group with which to run. This is mostly symbolic, as you
# generally need to run as root to be able to properly manipulate

Modified: spine/branches/spine_2_2-devel/publisher/spine-publisher.init
==============================================================================
--- spine/branches/spine_2_2-devel/publisher/spine-publisher.init Fri Nov 20 06:37:46 2009 (r305)
+++ spine/branches/spine_2_2-devel/publisher/spine-publisher.init Fri Nov 20 06:46:41 2009 (r306)
@@ -6,7 +6,7 @@
# description: Spine Configball Publisher
#
# processname: spine-publisher
-# config: /etc/spine-publisher.conf
+# config: /etc/spine-mgmt/spine-publisher.conf
# pidfile: /var/run/spine-publisher.pid

# source function library
@@ -16,7 +16,7 @@
prog="spine-publisher"
SPINE_PUB="/usr/bin/spine-publisher"
PIDFILE="/var/run/spine-publisher.pid"
-OPTIONS="-c /etc/spine-publisher.conf"
+OPTIONS="-c /etc/spine-mgmt/spine-publisher.conf"

start()
{

Modified: spine/branches/spine_2_2-devel/spine.spec
==============================================================================
--- spine/branches/spine_2_2-devel/spine.spec Fri Nov 20 06:37:46 2009 (r305)
+++ spine/branches/spine_2_2-devel/spine.spec Fri Nov 20 06:46:41 2009 (r306)
@@ -1,12 +1,10 @@
# $Id$
# vim:ts=8:noet

-%define spine_ver 2.0
-%define spine_rel rc22
+%define spine_ver 2.1.0
+%define spine_rel 1
%define spine_prefix /usr
-%define spine_lib_prefix %{spine_prefix}/lib/spine
-%define File_Temp_ver 0.16
-%define Sys_Syslog_ver 0.18
+%define spine_lib_prefix %{spine_prefix}/lib/spine-mgmt

Name: spine
Summary: Ticketmaster Configuration System
@@ -18,33 +16,38 @@
Source: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildArch: noarch
+Requires: rsync
Requires: dialog >= 0.9
Requires: lshw
+%if "%{dist}" == ".el3" || "%{dist}" == ".el4"
+Requires: kernel-utils
+%else
+Requires: dmidecode
+%endif
Requires: perl(Digest::MD5) >= 2.20
Requires: perl(Net::DNS) >= 0.49
Requires: perl(Template) >= 2.14
Requires: perl(Text::Diff) >= 0.35
Requires: perl(NetAddr::IP) >= 3.24
-Requires: perl(File::Touch) >= 0.01
-Requires: perl(File::Temp) >= 0.14
Requires: perl(YAML::Syck)
Requires: perl(JSON::Syck)
Requires: perl(XML::Simple) >= 2.12
-# Provided by ourself, currently.
-Requires: perl(File::Temp) >= %{File_Temp_ver}
-Requires: perl(Sys::Syslog) >= %{Sys_Syslog_ver}
+Requires: perl(File::Temp) >= 0.16
+Requires: perl(Sys::Syslog)

%description
Ticketmaster Configuration System

%ifarch noarch
-%package fsball-publisher
+%package publisher
Summary: Ticketmaster configuration system's publishing system
Group: Ticketmaster
BuildArch: noarch
-Requires: python >= 2.2.3-5
+Requires: perl(SVN::Client)
+Requires: perl(Config::Simple)
+Obsoletes: spine-fsball-publisher

-%description fsball-publisher
+%description publisher
Ticketmaster configuration system's publishing system
%endif

@@ -66,33 +69,31 @@
%files
%defattr(-,root,root)
%attr(0755,root,root) %{spine_prefix}/bin/ui
-%attr(0755,root,root) %{spine_prefix}/bin/spine-config
+%attr(0755,root,root) %{spine_prefix}/bin/spine-mgmt
%attr(0755,root,root) %{spine_prefix}/bin/quick_template
%dir %{spine_lib_prefix}
-%dir %{spine_lib_prefix}/Spine
-%dir %{spine_lib_prefix}/Spine/ConfigSource
-%dir %{spine_lib_prefix}/Spine/Plugin
-%{spine_lib_prefix}/Spine/*.pm
-%{spine_lib_prefix}/Spine/ConfigSource/*.pm
-%{spine_lib_prefix}/Spine/Plugin/*.pm
-%config(noreplace) /etc/spine-config.conf
+%{spine_lib_prefix}/Spine/*
+%config(noreplace) /etc/spine-mgmt/spine-mgmt.conf
#
# This makes RPM 4.4 angry
#
-#%{_localstatedir}/spine
-%attr(0755,root,root) %{_localstatedir}/spine
+#%{_localstatedir}/spine-mgmt
+%attr(0755,root,root) %{_localstatedir}/spine-mgmt

%ifarch noarch
-%files fsball-publisher
+%files publisher
%defattr(-,root,root)
-%{spine_prefix}/bin/spine-cramfs-publish.py
-%{spine_prefix}/bin/spine-cramfs-publish.pyo
-%{spine_prefix}/bin/spine-cramfs-publish.pyc
-%config(noreplace) /etc/cramfs-publisher.conf
-
+%{spine_prefix}/bin/spine-publisher
+%{_sysconfdir}/init.d/spine-publisher
+%config(noreplace) %{_sysconfdir}/spine-mgmt/spine-publisher.conf
%endif

%changelog
+* Wed Nov 02 2009 Jeff Schroeder <jeffsc...@computer.org> 2.1.0-1
+- Change to the faster pure perl configball publisher.
+- Update the spec file to not barf on Fedora.
+- Minor formating cleanups.
+
* Wed Oct 03 2007 Phil Dibowitz <phil.d...@ticketmaster.com> 2.0-rc22
- Add support for parsing lshw output
- Add --action and --actiongroup support
Reply all
Reply to author
Forward
0 new messages