Hello community, here is the log from the commit of package perl-Config-Crontab checked in at Sun Aug 5 17:36:15 CEST 2007. -------- --- perl-Config-Crontab/perl-Config-Crontab.changes 2006-10-20 18:49:46.000000000 +0200 +++ /mounts/work_src_done/STABLE/perl-Config-Crontab/perl-Config-Crontab.changes 2007-08-05 17:04:22.041356000 +0200 @@ -1,0 +2,7 @@ +Sun Aug 5 17:01:22 CEST 2007 - mrueckert@suse.de + +- update to version 1.21: + minor bugfix mainly for weird behavior of "crontab -l" on debian +- minor spec file cleanup + +------------------------------------------------------------------- Old: ---- Config-Crontab-1.20.tar.bz2 New: ---- Config-Crontab-1.21.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Config-Crontab.spec ++++++ --- /var/tmp/diff_new_pack.f15361/_old 2007-08-05 17:36:08.000000000 +0200 +++ /var/tmp/diff_new_pack.f15361/_new 2007-08-05 17:36:08.000000000 +0200 @@ -1,7 +1,7 @@ # -# spec file for package perl-Config-Crontab (Version 1.20) +# spec file for package perl-Config-Crontab (Version 1.21) # -# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine # package are under the same license as the package itself. # @@ -13,11 +13,11 @@ Name: perl-Config-Crontab %define module_name Config-Crontab Summary: Read/Write Vixie compatible crontab files -Version: 1.20 +Version: 1.21 Release: 1 Requires: perl = %{perl_version} Autoreqprov: on -License: Artistic License, GNU General Public License (GPL) - all versions +License: Artistic License, GPL v2 or later Group: Development/Libraries/Perl URL: http://search.cpan.org/~scottw/ # http://search.cpan.org/CPAN/authors/id/S/SC/SCOTTW/Config-Crontab-1.20.tar.g... @@ -52,11 +52,12 @@ %build CFLAGS="$RPM_OPT_FLAGS" perl Makefile.PL make + +%check make test %install -rm -rf $RPM_BUILD_ROOT -make DESTDIR=$RPM_BUILD_ROOT install_vendor +%perl_make_install %perl_process_packlist %clean @@ -71,7 +72,11 @@ %{perl_vendorlib}/Config/Crontab.pm /var/adm/perl-modules/%{name} -%changelog -n perl-Config-Crontab +%changelog +* Sun Aug 05 2007 - mrueckert@suse.de +- update to version 1.21: + minor bugfix mainly for weird behavior of "crontab -l" on debian +- minor spec file cleanup * Fri Oct 20 2006 - mrueckert@suse.de - update to version 1.20: added remove_tab to remove crontab files. ++++++ Config-Crontab-1.20.tar.bz2 -> Config-Crontab-1.21.tar.bz2 ++++++ diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Config-Crontab-1.20/Changes new/Config-Crontab-1.21/Changes --- old/Config-Crontab-1.20/Changes 2005-06-11 00:26:23.000000000 +0200 +++ new/Config-Crontab-1.21/Changes 2007-07-18 21:56:43.000000000 +0200 @@ -1,5 +1,18 @@ Revision history for Perl extension Config::Crontab. +Release 1.21 +---------------------------- +revision 1.3 +date: 2007/07/18 19:55:59; author: scott; state: Exp; lines: +40 -3 +- note about debian linux's 'crontab' command + +Release 1.20 +---------------------------- +revision 1.2 (new CVS repository) +date: 2006/04/18 22:08:38; author: scott; state: Exp; lines: +53 -3 +- fix write('') to unset file() +- add remove_tab() method to remove the crontab + Release 1.10 ---------------------------- revision 1.37 diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Config-Crontab-1.20/Crontab.pm new/Config-Crontab-1.21/Crontab.pm --- old/Config-Crontab-1.20/Crontab.pm 2006-04-19 00:04:57.000000000 +0200 +++ new/Config-Crontab-1.21/Crontab.pm 2007-07-18 21:47:44.000000000 +0200 @@ -35,7 +35,7 @@ use Fcntl; use File::Temp qw(:POSIX); -$VERSION = '1.20'; +$VERSION = '1.21'; sub init { my $self = shift; @@ -3132,6 +3132,35 @@ =item * +Thanks to alert reader "Kirk" (no lastname given), we learn that some +versions of Debian linux's "crontab -l" does not strip the internal +crontab(1) comments (e.g., "DO NOT EDIT THIS FILE" and subsequent +meta-data) at the start of user crontabs. + +This means that if you use Config::Crontab to edit a user's crontab +file, those three headers will be added to the Config::Crontab object, +and written back out again, and crontab(1) will add its own comments, +effectively adding 3 comment lines each time you edit the crontab. + +You may use this little heuristic as a starting point for stripping +those comments: + + my $ct = new Config::Crontab; + $ct->read; + + ## make "crontab -l | crontab -" idempotent for Debian + for my $line ( grep { defined } ($ct->select(-type => 'comment'))[0..2] ) { + if( $line->data =~ qr(^# (?:DO NOT EDIT|[\(]\S+ installed|[\(]Cron version)) ) { + $ct->remove($line); + } + } + + ... + + $ct->write; + +=item * + As of version 1.05, BConfig::Crontab supports the user field (with optional ':group' and '/E<lt>login-classE<gt>') via the B<-system> initialization parameter, B<system> B<Event> method, or B<user> @@ -3217,12 +3246,20 @@ =back +=head1 SEE ALSO + +cron(8), crontab(1), crontab(5) + =head1 AUTHOR Scott Wiersdorf, E<lt>scott@perlcode.orgE<gt> -=head1 SEE ALSO +=head1 COPYRIGHT AND LICENSE -cron(8), crontab(1), crontab(5) +Copyright (C) 2007 by Scott Wiersdorf + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself, either Perl version 5.8.6 or, +at your option, any later version of Perl 5 you may have available. =cut diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Config-Crontab-1.20/eg/crontab.cgi new/Config-Crontab-1.21/eg/crontab.cgi --- old/Config-Crontab-1.20/eg/crontab.cgi 2006-04-18 23:38:22.000000000 +0200 +++ new/Config-Crontab-1.21/eg/crontab.cgi 1970-01-01 01:00:00.000000000 +0100 @@ -1,464 +0,0 @@ -#!/usr/bin/perl -w -use strict; - -## Scott Wiersdorf -## Created: Mon May 19 11:55:06 MDT 2003 -## $Id: crontab.cgi,v 1.1 2006/04/18 21:38:22 scott Exp $ - -## a simple CGI for crontab editing -## -## most useful under Apache's suEXEC wrapper ;o) -## -## This program is a demonstration of the capabilities of the -## Config::Crontab module. The bulk of this program is CGI logic (tip -## o' the hat to Lincoln Stein), but look for the Config::Crontab::* -## calls and objects named $ct, $block, $newblock, and $obj. These are -## all Config::Crontab::* objects (and the reason for this demo -## program's creation). -## - -## -## WARNING * ACHTUNG * AVISO ## -## -## This program may modify your crontab file. This program is provided -## AS IS under the terms of the Perl Artistic License to illustrate -## some possible uses of Config::Crontab. -## -## This program inherently is a security problem because it provides -## no authentication mechanism. You should enable your web server's -## authentication to prevent unauthorized access to this script. -## -## The author assumes no liability for damages of any kind caused by -## (mis)?use of this program. Please see paragraph 10 of the Artistic -## License distributed with Perl. Have a nice day! -## - -## to do: -## -## - enable/disable blocks and lines within a block - -use CGI; -use Config::Crontab; - -######################### -## user-servicable parts: -######################### -my $file = ''; ## set this to a pathname of a file (it needn't - ## exist) if you want to practice with a temporary - ## crontab file instead of your real one -my $DEBUG = 0; ## a little extra information in your error_log - -####################################### -## no user-servicable parts below here: -####################################### -my $q = new CGI; -my $self = $q->url; -my $info; ## used for passing messages to main form - -print $q->header; - -ACTION: { - - ############################################################# - ############################################################# - ## ## - ## General Block Operations: these don't require 'blockno' ## - ## ## - ############################################################# - ############################################################# - - ############################################## - ## Cancel Block Operation ## - ############################################## - if( $q->param('Block Cancel') || $q->param('Cancel') ) { - $info = "Action cancelled"; - last ACTION; - } - - - ############################################## - ## Complete Block Operation ## - ############################################## - elsif( $q->param('Block Done') ) { - $info = "Action completed"; - last ACTION; - } - - ############################################## - ## New Raw Block ## - ############################################## - elsif( $q->param('Block Raw New') ) { - ## display edit page and exit - print $q->start_html("New crontab block for " . getpwuid($<)), - $q->strong('Add a new crontab entry:'), $q->p, "\n\n"; - print "<ul>" . $info . "</ul>" if $info; - print $q->start_form; - print $q->textarea( -name => 'blocktext', - -default => '', - -rows => 10, - -columns => 50 ); - print $q->p, "\n"; - print $q->submit('Block New Commit', 'Commit'), $q->reset, $q->submit('Block Cancel', 'Cancel'); - print $q->end_form; - print $q->end_html; - exit; - } - - ########################################## - ## New Block Commit ## - ########################################## - elsif( $q->param('Block New Commit') ) { - my $ct = new Config::Crontab( -file => $file ); $ct->read; - my $bt = $q->param('blocktext'); $bt =~ s/\r\n/\n/g; - my $newblock = new Config::Crontab::Block( -data => $bt ); - $ct->last($newblock); - $ct->write; - $info = "New block added"; - last ACTION; - } - - ############################################## - ## New Block ## - ############################################## - elsif( $q->param('Block New') ) { - my $ct = new Config::Crontab( -file => $file ); $ct->read; - $ct->first(new Config::Crontab::Block(-data => '## new cron event') ); - $ct->write; - - $q->param('blockno', 0); - $q->param('Block Edit', 1); - } - - ## add new non-blockno operations here - - ######################################################### - ######################################################### - ## ## - ## Block Operations: these require 'blockno' to be set ## - ## ## - ######################################################### - ######################################################### - unless( defined $q->param('blockno') ) { - print STDERR "No block found. Jumping to end of ACTION\n" if $DEBUG; - last ACTION; - } - - ## parse the crontab file - my $ct = new Config::Crontab( -file => $file ); $ct->read; - my $block = ($ct->blocks)[$q->param('blockno')]; - unless( ref($block) ) { - $info = "Couldn't find block!"; - print STDERR "Block " . $q->param('blockno') . " missing\n" if $DEBUG; - last ACTION; - } - - ############################################## - ## Raw Block Edit ## - ############################################## - if( $q->param('Block Raw Edit') ) { - print $q->start_html("Edit crontab block for " . getpwuid($<)), - $q->strong('Edit this block:'), $q->p, "\n\n"; - print "<ul>" . $info . "</ul>" if $info; - print $q->start_form; - print $q->hidden('blockno', $q->param('blockno')); - print $q->textarea( -name => 'blocktext', - -default => $block->dump, - -rows => 10, - -columns => 50 ); - print $q->p, "\n"; - print $q->submit('Block Commit', 'Commit'), - $q->reset, - $q->submit('Block Cancel', 'Cancel'); - print $q->end_form; - print $q->end_html; - exit; - } - - ############################################## - ## Commit Block ## - ############################################## - elsif( $q->param('Block Commit') ) { - unless( defined $q->param('blocktext') && $q->param('blocktext') ) { - $info = "No blocktext"; - print STDERR "Commit: $info\n" if $DEBUG; - last ACTION; - } - - my $bt = $q->param('blocktext'); $bt =~ s/\r\n/\n/g; - my $newblock = new Config::Crontab::Block( -data => $bt ); - $ct->replace( $block, $newblock ); - $ct->write; - $info = "New block written"; - last ACTION; - } - - ############################################## - ## Delete Block ## - ############################################## - elsif( $q->param('Block Delete') ) { - $ct->remove($block); - $ct->write; - $info = "Block deleted!"; - last ACTION; - } - - ############################################## - ## Move Block ## - ############################################## - elsif( $q->param('Block Up') || $q->param('Block Down') || - $q->param('Block First') || $q->param('Block Last') ) { - - if( $q->param('Block Up') ) { $ct->up($block) } - elsif( $q->param('Block Down') ) { $ct->down($block) } - elsif( $q->param('Block First') ) { $ct->first($block) } - elsif( $q->param('Block Last') ) { $ct->last($block) } - - $ct->write; - $info = "Block moved"; - last ACTION; - } - - ############################################## - ## Edit Block ## - ## ## - ## This section is a "substate" since it ## - ## loops within itself until 'Done' is ## - ## pressed. ## - ## ## - ############################################## - if( $q->param('Block Edit') ) { - - BLOCK_EDIT: { - - ###################################### - ## all sections below require 'blockno' - ###################################### - my $block = ($ct->blocks)[$q->param('blockno')]; - unless( ref($block) ) { - $info = "Couldn't find block"; - print STDERR "$info (" . $q->param('blockno') . ")\n" if $DEBUG; - last ACTION; - } - - ###################################### - ## 'objno' not required - ###################################### - - if( $q->param('New Line') ) { - if( $q->param('newobjtype') eq 'Comment' ) { - $block->last(new Config::Crontab::Comment(-data => '## comment')); - } elsif( $q->param('newobjtype') eq 'Environment' ) { - $block->last(new Config::Crontab::Env(-data => 'NAME=value')); - } elsif( $q->param('newobjtype') eq 'Event' ) { - $block->last(new Config::Crontab::Event(-data => '0 0 * * 1 /bin/true')); - } else { - $info = "Unknown object type"; - print STDERR "Edit (new line): $info (" . $q->param('newobjtype') . ")\n" if $DEBUG; - last ACTION; - } - $ct->write; - $info = "New " . $q->param('newobjtype') . " created"; - last BLOCK_EDIT; - } - - ###################################### - ## the following sections require 'objno' - ###################################### - last BLOCK_EDIT unless defined $q->param('objno'); - - my $line = ($block->lines)[$q->param('objno')]; - - if( $q->param('Delete Line') ) { - $block->remove($line); - $info = "Line deleted"; - } - elsif( $q->param('Commit Line') ) { - my $obj; - if( $q->param('objtype') eq 'comment' ) { - $obj = new Config::Crontab::Comment( -data => $q->param('comment') ); - } elsif( $q->param('objtype') eq 'env' ) { - $obj = new Config::Crontab::Env( -name => $q->param('envname'), - -value => $q->param('envvalue') ); - } elsif( $q->param('objtype') eq 'event' ) { - $obj = new Config::Crontab::Event( -datetime => $q->param('datetime'), - -command => $q->param('command') ); - } - else { - $info = "Invalid object type: " . $q->param('objtype'); - print STDERR "$info\n" if $DEBUG; - last ACTION; - } - $block->replace($line, $obj); - $info = "Line changes saved"; - } - elsif( $q->param('Revert Line') ) { - $info = "Line reverted"; - } - elsif( $q->param('First Line') ) { - $block->first($line); - $info = "Line moved to first"; - } - elsif( $q->param('Last Line') ) { - $block->last($line); - $info = "Line moved to last"; - } - elsif( $q->param('Up Line') ) { - $block->up($line); - $info = "Line moved up"; - } - elsif( $q->param('Down Line') ) { - $block->down($line); - $info = "Line moved down"; - } - else { last BLOCK_EDIT; } - $ct->write; - last BLOCK_EDIT; - } - - ## this will trigger if user deletes last line in a block, or the - ## block was emptied by someone else before we got here (no locking) - last ACTION unless $block->lines; - - ## display edit block page and exit - print $q->start_html("Edit crontab block for " . getpwuid($<)), - $q->strong('Edit this block:'), "<br>\n"; - print "Date: " . scalar(localtime) . "<br>\n"; - print "<ul>" . $info . "</ul>" if $info; - - print $q->start_form; - $q->param('Block Edit', 0); - print $q->hidden('Block Edit'); - print $q->submit('Block Done', 'Done'), $q->reset; - print "<br>Be sure to 'Commit' your changes before hitting 'Done'<br>\n"; - print $q->end_form; - - print qq!<table border="1"><tr valign="top">\n!; - print qq!<td>!, $q->start_form; - print $q->submit("New Line", "Add"), $q->br; - print $q->hidden('blockno'); - $q->param('Block Edit', 1); - print $q->hidden('Block Edit'); - - print $q->radio_group(-name => 'newobjtype', - -values => ['Comment','Environment','Event'], - -default => 'Event'); - print "\n"; - print $q->end_form, qq!</td></tr></table>\n!; - - print qq!<table border="1">\n!; - print qq!<tr><td>Delete</td><td>Commit</td><td>Undo</td><td>First</td><td>Up</td><td>Down</td><td>Last</td></tr>\n!; - my $cols = 10; - my $i = 0; - for my $obj ( $block->lines ) { - print $q->start_form; - print qq!<tr valign="top">\n!; - print q!<td width="! . int(100*(1/$cols)) . q!%">!, - $q->submit("Delete Line", 'X'), "</td>\n"; - print q!<td width="! . int(100*(1/$cols)) . q!%">!, - $q->submit("Commit Line", 'O'), "</td>\n"; - print q!<td width="! . int(100*(1/$cols)) . q!%">!, - $q->submit("Revert Line", 'U'), "</td>\n"; - print q!<td width="! . int(100*(1/$cols)) . q!%">!, - $q->submit("First Line", '|<'), "</td>\n"; - print q!<td width="! . int(100*(1/$cols)) . q!%">!, - $q->submit("Up Line", '<'), "</td>\n"; - print q!<td width="! . int(100*(1/$cols)) . q!%">!, - $q->submit("Down Line", '>'), "</td>\n"; - print q!<td width="! . int(100*(1/$cols)) . q!%">!, - $q->submit("Last Line", '>|'), "</td>\n"; - $q->param('Block Edit', 1); - print $q->hidden('Block Edit'), "\n"; - $q->param('objno', $i++); - print $q->hidden(-name => 'objno'), "\n"; - print $q->hidden('blockno'), "\n"; - - if( UNIVERSAL::isa($obj, 'Config::Crontab::Comment') ) { - print qq!<td colspan="3" width="! . int(100*(3/$cols)) . q!%">!; - $q->param('comment', $obj->dump); - print "Comment:<br>", $q->textfield(-name => "comment", - -size => 25), "\n"; - print $q->hidden('objtype', 'comment'), "\n"; - print "</td>"; - } - - elsif( UNIVERSAL::isa($obj, 'Config::Crontab::Env') ) { - print qq!<td>!; - $q->param('envname', $obj->name); - print "Name:<br>", $q->textfield(-name => "envname", - -size => 12), "\n"; - print "</td><td>=</td><td>"; - $q->param('envvalue', $obj->value); - print "Value:<br>", $q->textfield(-name => "envvalue", - -value => $obj->value), "\n"; - print $q->hidden('objtype', 'env'), "\n"; - print "</td>"; - } - - elsif( UNIVERSAL::isa($obj, 'Config::Crontab::Event') ) { - print qq!<td colspan="1" width="! . int(100*(1/$cols)) . q!%">!; - $q->param('datetime', $obj->datetime); - print "Scheduled:<br>", $q->textfield(-name => "datetime", - -size => 12), "\n"; - print qq!</td><td colspan="2" width="! . int(100*(2/$cols)) . q!%">!; - $q->param('command', $obj->command); - print "Command:<br>", $q->textfield(-name => "command"), "\n"; - print $q->hidden('objtype', 'event'), "\n"; - print "</td>"; - } - print "</tr>\n\n"; - print $q->end_form; - } - - print "</table>\n"; - print $q->start_form; - $q->param('Block Edit',0); - print $q->hidden('Block Edit'); - print $q->submit('Block Done', 'Done'), $q->reset; - print "<br>Be sure to 'Commit' your changes before hitting 'Done'<br>\n"; - print $q->end_form; - print $q->end_html; - - exit; - } -} - -print $q->start_html("Crontab for " . getpwuid($<)), - $q->strong('Edit your crontab:'), "<br>\n\n"; -print "Date: " . scalar(localtime) . "<br>\n"; -print "<ul><em>" . $info . "</em></ul>" if $info; - -print $q->start_form; -print $q->submit("Block New", "New"), $q->submit("Block Raw New", "Raw New"), $q->submit("Cancel"), "\n"; -print $q->end_form; -print "<hr>\n"; - -my $ct = new Config::Crontab( -file => $file); $ct->read; -my $i = 0; -for my $block ( $ct->blocks ) { - print $q->start_form; - $q->param('blockno', $i++); - print $q->hidden( -name=>'blockno' ); - print qq!<table border="1">\n!; - print qq!<tr><td>Delete</td><td>Edit</td><td>Raw<br>Edit</td><td>First</td><td>Up</td><td>Down</td><td>Last</td></tr>\n!; - print qq!<tr valign="middle">\n!; - print "<td>", $q->submit("Block Delete", "X"), "</td>\n"; - print "<td>", $q->submit("Block Edit", "E"), "</td>\n"; - print "<td>", $q->submit("Block Raw Edit", "R"), "</td>\n"; - print "<td>", $q->submit("Block First", "|<"), "</td>\n"; - print "<td>", $q->submit("Block Up", "<"), "</td>\n"; - print "<td>", $q->submit("Block Down", ">"), "</td>\n"; - print "<td>", $q->submit("Block Last", ">|"), "</td>\n"; - print "<td><pre>\n"; - print $block->dump; - print "</pre></td>\n"; - print "</tr></table>\n"; - - print $q->end_form; - print "<hr>\n"; - print "\n\n"; -} -print $q->start_form; -print $q->submit("Block New", "New"), $q->submit("Block Raw New", "Raw New"), $q->submit("Cancel"), "\n"; -print $q->end_form; -print $q->end_html; -exit; diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Config-Crontab-1.20/example/crontab.cgi new/Config-Crontab-1.21/example/crontab.cgi --- old/Config-Crontab-1.20/example/crontab.cgi 1970-01-01 01:00:00.000000000 +0100 +++ new/Config-Crontab-1.21/example/crontab.cgi 2007-07-18 21:53:31.000000000 +0200 @@ -0,0 +1,464 @@ +#!/usr/bin/perl -w +use strict; + +## Scott Wiersdorf +## Created: Mon May 19 11:55:06 MDT 2003 +## $Id: crontab.cgi,v 1.1 2007/07/18 19:53:31 scott Exp $ + +## a simple CGI for crontab editing +## +## most useful under Apache's suEXEC wrapper ;o) +## +## This program is a demonstration of the capabilities of the +## Config::Crontab module. The bulk of this program is CGI logic (tip +## o' the hat to Lincoln Stein), but look for the Config::Crontab::* +## calls and objects named $ct, $block, $newblock, and $obj. These are +## all Config::Crontab::* objects (and the reason for this demo +## program's creation). +## + +## +## WARNING * ACHTUNG * AVISO ## +## +## This program may modify your crontab file. This program is provided +## AS IS under the terms of the Perl Artistic License to illustrate +## some possible uses of Config::Crontab. +## +## This program inherently is a security problem because it provides +## no authentication mechanism. You should enable your web server's +## authentication to prevent unauthorized access to this script. +## +## The author assumes no liability for damages of any kind caused by +## (mis)?use of this program. Please see paragraph 10 of the Artistic +## License distributed with Perl. Have a nice day! +## + +## to do: +## +## - enable/disable blocks and lines within a block + +use CGI; +use Config::Crontab; + +######################### +## user-servicable parts: +######################### +my $file = ''; ## set this to a pathname of a file (it needn't + ## exist) if you want to practice with a temporary + ## crontab file instead of your real one +my $DEBUG = 0; ## a little extra information in your error_log + +####################################### +## no user-servicable parts below here: +####################################### +my $q = new CGI; +my $self = $q->url; +my $info; ## used for passing messages to main form + +print $q->header; + +ACTION: { + + ############################################################# + ############################################################# + ## ## + ## General Block Operations: these don't require 'blockno' ## + ## ## + ############################################################# + ############################################################# + + ############################################## + ## Cancel Block Operation ## + ############################################## + if( $q->param('Block Cancel') || $q->param('Cancel') ) { + $info = "Action cancelled"; + last ACTION; + } + + + ############################################## + ## Complete Block Operation ## + ############################################## + elsif( $q->param('Block Done') ) { + $info = "Action completed"; + last ACTION; + } + + ############################################## + ## New Raw Block ## + ############################################## + elsif( $q->param('Block Raw New') ) { + ## display edit page and exit + print $q->start_html("New crontab block for " . getpwuid($<)), + $q->strong('Add a new crontab entry:'), $q->p, "\n\n"; + print "<ul>" . $info . "</ul>" if $info; + print $q->start_form; + print $q->textarea( -name => 'blocktext', + -default => '', + -rows => 10, + -columns => 50 ); + print $q->p, "\n"; + print $q->submit('Block New Commit', 'Commit'), $q->reset, $q->submit('Block Cancel', 'Cancel'); + print $q->end_form; + print $q->end_html; + exit; + } + + ########################################## + ## New Block Commit ## + ########################################## + elsif( $q->param('Block New Commit') ) { + my $ct = new Config::Crontab( -file => $file ); $ct->read; + my $bt = $q->param('blocktext'); $bt =~ s/\r\n/\n/g; + my $newblock = new Config::Crontab::Block( -data => $bt ); + $ct->last($newblock); + $ct->write; + $info = "New block added"; + last ACTION; + } + + ############################################## + ## New Block ## + ############################################## + elsif( $q->param('Block New') ) { + my $ct = new Config::Crontab( -file => $file ); $ct->read; + $ct->first(new Config::Crontab::Block(-data => '## new cron event') ); + $ct->write; + + $q->param('blockno', 0); + $q->param('Block Edit', 1); + } + + ## add new non-blockno operations here + + ######################################################### + ######################################################### + ## ## + ## Block Operations: these require 'blockno' to be set ## + ## ## + ######################################################### + ######################################################### + unless( defined $q->param('blockno') ) { + print STDERR "No block found. Jumping to end of ACTION\n" if $DEBUG; + last ACTION; + } + + ## parse the crontab file + my $ct = new Config::Crontab( -file => $file ); $ct->read; + my $block = ($ct->blocks)[$q->param('blockno')]; + unless( ref($block) ) { + $info = "Couldn't find block!"; + print STDERR "Block " . $q->param('blockno') . " missing\n" if $DEBUG; + last ACTION; + } + + ############################################## + ## Raw Block Edit ## + ############################################## + if( $q->param('Block Raw Edit') ) { + print $q->start_html("Edit crontab block for " . getpwuid($<)), + $q->strong('Edit this block:'), $q->p, "\n\n"; + print "<ul>" . $info . "</ul>" if $info; + print $q->start_form; + print $q->hidden('blockno', $q->param('blockno')); + print $q->textarea( -name => 'blocktext', + -default => $block->dump, + -rows => 10, + -columns => 50 ); + print $q->p, "\n"; + print $q->submit('Block Commit', 'Commit'), + $q->reset, + $q->submit('Block Cancel', 'Cancel'); + print $q->end_form; + print $q->end_html; + exit; + } + + ############################################## + ## Commit Block ## + ############################################## + elsif( $q->param('Block Commit') ) { + unless( defined $q->param('blocktext') && $q->param('blocktext') ) { + $info = "No blocktext"; + print STDERR "Commit: $info\n" if $DEBUG; + last ACTION; + } + + my $bt = $q->param('blocktext'); $bt =~ s/\r\n/\n/g; + my $newblock = new Config::Crontab::Block( -data => $bt ); + $ct->replace( $block, $newblock ); + $ct->write; + $info = "New block written"; + last ACTION; + } + + ############################################## + ## Delete Block ## + ############################################## + elsif( $q->param('Block Delete') ) { + $ct->remove($block); + $ct->write; + $info = "Block deleted!"; + last ACTION; + } + + ############################################## + ## Move Block ## + ############################################## + elsif( $q->param('Block Up') || $q->param('Block Down') || + $q->param('Block First') || $q->param('Block Last') ) { + + if( $q->param('Block Up') ) { $ct->up($block) } + elsif( $q->param('Block Down') ) { $ct->down($block) } + elsif( $q->param('Block First') ) { $ct->first($block) } + elsif( $q->param('Block Last') ) { $ct->last($block) } + + $ct->write; + $info = "Block moved"; + last ACTION; + } + + ############################################## + ## Edit Block ## + ## ## + ## This section is a "substate" since it ## + ## loops within itself until 'Done' is ## + ## pressed. ## + ## ## + ############################################## + if( $q->param('Block Edit') ) { + + BLOCK_EDIT: { + + ###################################### + ## all sections below require 'blockno' + ###################################### + my $block = ($ct->blocks)[$q->param('blockno')]; + unless( ref($block) ) { + $info = "Couldn't find block"; + print STDERR "$info (" . $q->param('blockno') . ")\n" if $DEBUG; + last ACTION; + } + + ###################################### + ## 'objno' not required + ###################################### + + if( $q->param('New Line') ) { + if( $q->param('newobjtype') eq 'Comment' ) { + $block->last(new Config::Crontab::Comment(-data => '## comment')); + } elsif( $q->param('newobjtype') eq 'Environment' ) { + $block->last(new Config::Crontab::Env(-data => 'NAME=value')); + } elsif( $q->param('newobjtype') eq 'Event' ) { + $block->last(new Config::Crontab::Event(-data => '0 0 * * 1 /bin/true')); + } else { + $info = "Unknown object type"; + print STDERR "Edit (new line): $info (" . $q->param('newobjtype') . ")\n" if $DEBUG; + last ACTION; + } + $ct->write; + $info = "New " . $q->param('newobjtype') . " created"; + last BLOCK_EDIT; + } + + ###################################### + ## the following sections require 'objno' + ###################################### + last BLOCK_EDIT unless defined $q->param('objno'); + + my $line = ($block->lines)[$q->param('objno')]; + + if( $q->param('Delete Line') ) { + $block->remove($line); + $info = "Line deleted"; + } + elsif( $q->param('Commit Line') ) { + my $obj; + if( $q->param('objtype') eq 'comment' ) { + $obj = new Config::Crontab::Comment( -data => $q->param('comment') ); + } elsif( $q->param('objtype') eq 'env' ) { + $obj = new Config::Crontab::Env( -name => $q->param('envname'), + -value => $q->param('envvalue') ); + } elsif( $q->param('objtype') eq 'event' ) { + $obj = new Config::Crontab::Event( -datetime => $q->param('datetime'), + -command => $q->param('command') ); + } + else { + $info = "Invalid object type: " . $q->param('objtype'); + print STDERR "$info\n" if $DEBUG; + last ACTION; + } + $block->replace($line, $obj); + $info = "Line changes saved"; + } + elsif( $q->param('Revert Line') ) { + $info = "Line reverted"; + } + elsif( $q->param('First Line') ) { + $block->first($line); + $info = "Line moved to first"; + } + elsif( $q->param('Last Line') ) { + $block->last($line); + $info = "Line moved to last"; + } + elsif( $q->param('Up Line') ) { + $block->up($line); + $info = "Line moved up"; + } + elsif( $q->param('Down Line') ) { + $block->down($line); + $info = "Line moved down"; + } + else { last BLOCK_EDIT; } + $ct->write; + last BLOCK_EDIT; + } + + ## this will trigger if user deletes last line in a block, or the + ## block was emptied by someone else before we got here (no locking) + last ACTION unless $block->lines; + + ## display edit block page and exit + print $q->start_html("Edit crontab block for " . getpwuid($<)), + $q->strong('Edit this block:'), "<br>\n"; + print "Date: " . scalar(localtime) . "<br>\n"; + print "<ul>" . $info . "</ul>" if $info; + + print $q->start_form; + $q->param('Block Edit', 0); + print $q->hidden('Block Edit'); + print $q->submit('Block Done', 'Done'), $q->reset; + print "<br>Be sure to 'Commit' your changes before hitting 'Done'<br>\n"; + print $q->end_form; + + print qq!<table border="1"><tr valign="top">\n!; + print qq!<td>!, $q->start_form; + print $q->submit("New Line", "Add"), $q->br; + print $q->hidden('blockno'); + $q->param('Block Edit', 1); + print $q->hidden('Block Edit'); + + print $q->radio_group(-name => 'newobjtype', + -values => ['Comment','Environment','Event'], + -default => 'Event'); + print "\n"; + print $q->end_form, qq!</td></tr></table>\n!; + + print qq!<table border="1">\n!; + print qq!<tr><td>Delete</td><td>Commit</td><td>Undo</td><td>First</td><td>Up</td><td>Down</td><td>Last</td></tr>\n!; + my $cols = 10; + my $i = 0; + for my $obj ( $block->lines ) { + print $q->start_form; + print qq!<tr valign="top">\n!; + print q!<td width="! . int(100*(1/$cols)) . q!%">!, + $q->submit("Delete Line", 'X'), "</td>\n"; + print q!<td width="! . int(100*(1/$cols)) . q!%">!, + $q->submit("Commit Line", 'O'), "</td>\n"; + print q!<td width="! . int(100*(1/$cols)) . q!%">!, + $q->submit("Revert Line", 'U'), "</td>\n"; + print q!<td width="! . int(100*(1/$cols)) . q!%">!, + $q->submit("First Line", '|<'), "</td>\n"; + print q!<td width="! . int(100*(1/$cols)) . q!%">!, + $q->submit("Up Line", '<'), "</td>\n"; + print q!<td width="! . int(100*(1/$cols)) . q!%">!, + $q->submit("Down Line", '>'), "</td>\n"; + print q!<td width="! . int(100*(1/$cols)) . q!%">!, + $q->submit("Last Line", '>|'), "</td>\n"; + $q->param('Block Edit', 1); + print $q->hidden('Block Edit'), "\n"; + $q->param('objno', $i++); + print $q->hidden(-name => 'objno'), "\n"; + print $q->hidden('blockno'), "\n"; + + if( UNIVERSAL::isa($obj, 'Config::Crontab::Comment') ) { + print qq!<td colspan="3" width="! . int(100*(3/$cols)) . q!%">!; + $q->param('comment', $obj->dump); + print "Comment:<br>", $q->textfield(-name => "comment", + -size => 25), "\n"; + print $q->hidden('objtype', 'comment'), "\n"; + print "</td>"; + } + + elsif( UNIVERSAL::isa($obj, 'Config::Crontab::Env') ) { + print qq!<td>!; + $q->param('envname', $obj->name); + print "Name:<br>", $q->textfield(-name => "envname", + -size => 12), "\n"; + print "</td><td>=</td><td>"; + $q->param('envvalue', $obj->value); + print "Value:<br>", $q->textfield(-name => "envvalue", + -value => $obj->value), "\n"; + print $q->hidden('objtype', 'env'), "\n"; + print "</td>"; + } + + elsif( UNIVERSAL::isa($obj, 'Config::Crontab::Event') ) { + print qq!<td colspan="1" width="! . int(100*(1/$cols)) . q!%">!; + $q->param('datetime', $obj->datetime); + print "Scheduled:<br>", $q->textfield(-name => "datetime", + -size => 12), "\n"; + print qq!</td><td colspan="2" width="! . int(100*(2/$cols)) . q!%">!; + $q->param('command', $obj->command); + print "Command:<br>", $q->textfield(-name => "command"), "\n"; + print $q->hidden('objtype', 'event'), "\n"; + print "</td>"; + } + print "</tr>\n\n"; + print $q->end_form; + } + + print "</table>\n"; + print $q->start_form; + $q->param('Block Edit',0); + print $q->hidden('Block Edit'); + print $q->submit('Block Done', 'Done'), $q->reset; + print "<br>Be sure to 'Commit' your changes before hitting 'Done'<br>\n"; + print $q->end_form; + print $q->end_html; + + exit; + } +} + +print $q->start_html("Crontab for " . getpwuid($<)), + $q->strong('Edit your crontab:'), "<br>\n\n"; +print "Date: " . scalar(localtime) . "<br>\n"; +print "<ul><em>" . $info . "</em></ul>" if $info; + +print $q->start_form; +print $q->submit("Block New", "New"), $q->submit("Block Raw New", "Raw New"), $q->submit("Cancel"), "\n"; +print $q->end_form; +print "<hr>\n"; + +my $ct = new Config::Crontab( -file => $file); $ct->read; +my $i = 0; +for my $block ( $ct->blocks ) { + print $q->start_form; + $q->param('blockno', $i++); + print $q->hidden( -name=>'blockno' ); + print qq!<table border="1">\n!; + print qq!<tr><td>Delete</td><td>Edit</td><td>Raw<br>Edit</td><td>First</td><td>Up</td><td>Down</td><td>Last</td></tr>\n!; + print qq!<tr valign="middle">\n!; + print "<td>", $q->submit("Block Delete", "X"), "</td>\n"; + print "<td>", $q->submit("Block Edit", "E"), "</td>\n"; + print "<td>", $q->submit("Block Raw Edit", "R"), "</td>\n"; + print "<td>", $q->submit("Block First", "|<"), "</td>\n"; + print "<td>", $q->submit("Block Up", "<"), "</td>\n"; + print "<td>", $q->submit("Block Down", ">"), "</td>\n"; + print "<td>", $q->submit("Block Last", ">|"), "</td>\n"; + print "<td><pre>\n"; + print $block->dump; + print "</pre></td>\n"; + print "</tr></table>\n"; + + print $q->end_form; + print "<hr>\n"; + print "\n\n"; +} +print $q->start_form; +print $q->submit("Block New", "New"), $q->submit("Block Raw New", "Raw New"), $q->submit("Cancel"), "\n"; +print $q->end_form; +print $q->end_html; +exit; diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Config-Crontab-1.20/MANIFEST new/Config-Crontab-1.21/MANIFEST --- old/Config-Crontab-1.20/MANIFEST 2006-04-19 00:01:43.000000000 +0200 +++ new/Config-Crontab-1.21/MANIFEST 2007-07-18 21:53:40.000000000 +0200 @@ -3,7 +3,7 @@ Makefile.PL MANIFEST README -eg/crontab.cgi +example/crontab.cgi t/01_comment.t t/02_env.t t/03_event.t diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Config-Crontab-1.20/META.yml new/Config-Crontab-1.21/META.yml --- old/Config-Crontab-1.20/META.yml 2006-04-19 00:09:21.000000000 +0200 +++ new/Config-Crontab-1.21/META.yml 2007-07-18 21:57:21.000000000 +0200 @@ -1,7 +1,7 @@ # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Config-Crontab -version: 1.20 +version: 1.21 version_from: Crontab.pm installdirs: site requires: diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/Config-Crontab-1.20/README new/Config-Crontab-1.21/README --- old/Config-Crontab-1.20/README 2006-04-19 00:02:05.000000000 +0200 +++ new/Config-Crontab-1.21/README 2006-05-25 18:09:23.000000000 +0200 @@ -1,4 +1,4 @@ -Config/Crontab version 1.20 +Config/Crontab version 1.21 =========================== Config::Crontab reads and writes (and pretty-prints) your crontab(5) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Remember to have fun... --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org