rpms/anacron/devel anacron-2.3-range-rnd.patch, NONE, 1.1 anacron.spec, 1.62, 1.63 manAUX_Limit.patch, 1.2, 1.3

Marcela Mašláňová mmaslano at fedoraproject.org
Fri Mar 27 09:43:43 UTC 2009


Author: mmaslano

Update of /cvs/pkgs/rpms/anacron/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv27514

Modified Files:
	anacron.spec manAUX_Limit.patch 
Added Files:
	anacron-2.3-range-rnd.patch 
Log Message:
* Fri Mar 27 2009 Marcela Mašláňová <mmaslano at redhat.com> 2.3-73
- rewrite the range and random patches with checking log to one 
  more lucid with help of tmraz.


anacron-2.3-range-rnd.patch:

--- NEW FILE anacron-2.3-range-rnd.patch ---
diff -up anacron-2.3.new/main.c.range-rnd anacron-2.3.new/main.c
--- anacron-2.3.new/main.c.range-rnd	2009-03-24 10:12:23.000000000 +0100
+++ anacron-2.3.new/main.c	2009-03-24 12:01:24.000000000 +0100
@@ -24,6 +24,7 @@
 
 
 #include <time.h>
+#include <sys/time.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <signal.h>
@@ -31,6 +32,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <string.h>
+#include <stdlib.h>
 #include "global.h"
 #include "gregor.h"
 
@@ -56,6 +58,8 @@ env_rec *first_env_rec;
 static time_t start_sec;                       /* time anacron started */
 static volatile int got_sigalrm, got_sigchld, got_sigusr1;
 int running_jobs, running_mailers;              /* , number of */
+int range_start = -1;
+int range_stop = -1;
 
 static void
 print_version()
@@ -402,6 +406,7 @@ static void
 explain_intentions()
 {
     int j;
+    struct tm *t;
 
     j = 0;
     while (j < njobs)
@@ -412,8 +417,21 @@ explain_intentions()
 	}
 	else
 	{
-	    explain("Will run job `%s' in %d min.",
+	    time_t jobtime = start_sec + job_array[j]->delay * 60;
+
+	    t = localtime(&jobtime);
+	    if (range_start != -1 && range_stop != -1 && 
+        	(t->tm_hour < range_start || t->tm_hour >= range_stop))
+	    {
+		Debug(("The job `%s' falls out of the %02d:00-%02d:00 hours range, skipping.",
+			job_array[j]->ident, range_start, range_stop));
+		job_array[j]->drop_job = 1;
+	    }
+            else
+	    {
+		explain("Will run job `%s' in %d min.",
 		    job_array[j]->ident, job_array[j]->delay);
+	    }
 	}
 	j++;
     }
@@ -428,8 +446,17 @@ main(int argc, char *argv[])
 
     int cwd;
 
+    int dropped_jobs = 0;
+
     anacrontab = NULL;
     spooldir = NULL;
+    struct timeval tv;
+    struct timezone tz;
+
+    if (gettimeofday(&tv, &tz) != 0)
+        explain("Can't get exact time, failure.");
+
+    srandom(getpid()+tv.tv_usec);
 
     if((program_name = strrchr(argv[0], '/')) == NULL)
 	program_name = argv[0];
@@ -486,11 +513,16 @@ main(int argc, char *argv[])
     running_jobs = running_mailers = 0;
     for(j = 0; j < njobs; ++j)
     {
+	if (job_array[j]->drop_job == 1)
+	{
+	    ++dropped_jobs;
+	    continue;
+	}
 	xsleep(time_till(job_array[j]));
 	if (serialize) wait_jobs();
 	launch_job(job_array[j]);
     }
     wait_children();
-    explain("Normal exit (%d job%s run)", njobs, (njobs == 1 ? "" : "s"));
+    explain("Normal exit (%d job%s run)", njobs-dropped_jobs, (njobs == 1 ? "" : "s"));
     exit(0);
 }
diff -up anacron-2.3.new/global.h.range-rnd anacron-2.3.new/global.h
--- anacron-2.3.new/global.h.range-rnd	2009-03-24 10:12:23.000000000 +0100
+++ anacron-2.3.new/global.h	2009-03-24 12:01:10.000000000 +0100
@@ -68,6 +68,7 @@ struct job_rec1 {
    int mail_header_size;
    pid_t job_pid;
    pid_t mailer_pid;
+   int drop_job;
 
    struct job_rec1 *next;
    env_rec *prev_env_rec;
@@ -100,6 +101,10 @@ extern int running_jobs,running_mailers;
 
 extern int complaints;
 
+/* time ranges for START_HOURS_RANGE */
+extern int range_start;
+extern int range_stop;
+
 /* Function prototypes */
 
 /* main.c */
diff -up anacron-2.3.new/log.c.range-rnd anacron-2.3.new/log.c
--- anacron-2.3.new/log.c.range-rnd	2009-03-24 10:12:23.000000000 +0100
+++ anacron-2.3.new/log.c	2009-03-24 12:01:56.000000000 +0100
@@ -43,6 +43,7 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <string.h>
+#include <stdlib.h>
 #include "global.h"
 
 static char truncated[] = " (truncated)";
diff -up anacron-2.3.new/readtab.c.range-rnd anacron-2.3.new/readtab.c
--- anacron-2.3.new/readtab.c.range-rnd	2009-03-24 10:12:23.000000000 +0100
+++ anacron-2.3.new/readtab.c	2009-03-24 11:51:08.000000000 +0100
@@ -48,6 +48,8 @@ static int line_num;             /* curr
 static job_rec *last_job_rec;    /* last job stored in memory, at the moment */
 static env_rec *last_env_rec;    /* last environment assignment stored */
 
+static int random_number = 0;
+
 /* some definitions for the obstack macros */
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
@@ -167,6 +169,7 @@ register_job(const char *periods, const 
     jr = obstack_alloc(&tab_o, sizeof(job_rec));
     jr->period = period;
     jr->named_period = 0;
+    delay += random_number;
     jr->delay = delay;
     jr->tab_line = line_num;
     jr->ident = obstack_alloc(&tab_o, ident_len + 1);
@@ -215,6 +218,7 @@ register_period_job(const char *periods,
 		 anacrontab, line_num);
     }
     jr->period = 0;
+    delay += random_number;
     jr->delay = delay;
     jr->tab_line = line_num;
     jr->ident = obstack_alloc(&tab_o, ident_len + 1);
@@ -242,6 +246,8 @@ parse_tab_line(char *line)
     char *delays;
     char *ident;
     char *command;
+    char *from;
+    char *to;
 
     /* an empty line? */
     r = match_rx("^[ \t]*($|#)", line, 0);
@@ -258,6 +264,25 @@ parse_tab_line(char *line)
     if (r == -1) goto reg_err;
     if (r)
     {
+        if (strncmp(env_var, "START_HOURS_RANGE", 17) == 0)
+        {
+            r = match_rx("^([[:digit:]]+)-([[:digit:]]+)$", value, 2, &from, &to);
+            if ((r == -1) || (from == NULL) || (to == NULL)) goto reg_invalid;
+            range_start = atoi(from);
+            range_stop = atoi(to);
+            Debug(("Jobs will start in the %02d:00-%02d:00 range.", range_start, range_stop));
+        }
+        if (strncmp(env_var, "RANDOM_DELAY", 12) == 0) {
+            r = match_rx("^([[:digit:]]+)$", value, 1);
+            if (r != -1) {
+                int i = random();
+                double x = 0;
+                x = (double) i / (double) RAND_MAX * (double) (atoi(value));
+                random_number = (int)x;
+                Debug(("Randomized delay set: %d", random_number));
+            }
+        else goto reg_invalid;
+        }
 	register_env(env_var, value);
 	return;
     }
@@ -284,6 +309,7 @@ parse_tab_line(char *line)
 	return;
     }
 
+ reg_invalid:
     complain("Invalid syntax in %s on line %d - skipping this line",
 	     anacrontab, line_num);
     return;


Index: anacron.spec
===================================================================
RCS file: /cvs/pkgs/rpms/anacron/devel/anacron.spec,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- anacron.spec	6 Mar 2009 08:14:57 -0000	1.62
+++ anacron.spec	27 Mar 2009 09:43:13 -0000	1.63
@@ -1,7 +1,7 @@
 Summary: A cron-like program that can run jobs lost during downtime
 Name: anacron
 Version: 2.3
-Release: 72%{?dist}
+Release: 73%{?dist}
 License: GPLv2+
 Group: System Environment/Base
 URL: http://packages.debian.org/stable/source/anacron
@@ -15,10 +15,10 @@
 Patch4: anacron-2.3-pic.patch
 Patch5: anacron-2.3-memleaking.patch
 Patch6: anacron-2.3-spooldir.patch
-Patch7: anacron-2.3-range.patch
-Patch8: anacron-2.3-random.patch
+#Patch7: anacron-2.3-range.patch
+#Patch8: anacron-2.3-random.patch
 Patch9: manAUX_Limit.patch
-Patch10: anacron-2.3-log_jobs_correct.patch
+Patch10: anacron-2.3-range-rnd.patch
 
 Requires: crontabs
 Requires: initscripts
@@ -51,8 +51,8 @@
 %patch4 -p1 -b .pic
 %patch5 -p1 -b .memleaking
 %patch6 -p1 -b .spool
-%patch7 -p1 -b .range
-%patch8 -p1 -b .random
+#%patch7 -p1 -b .range
+#%patch8 -p1 -b .random
 %patch9 -p1
 %patch10 -p1 -b .fix
 
@@ -92,6 +92,10 @@
 %attr(755,root,root) /etc/cron.hourly/0anacron
 
 %changelog
+* Fri Mar 27 2009 Marcela Mašláňová <mmaslano at redhat.com> 2.3-73
+- rewrite the range and random patches with checking log to one 
+  more lucid with help of tmraz.
+
 * Fri Mar  6 2009 Marcela Mašláňová <mmaslano at redhat.com> 2.3-72
 - 488916 fix typo in bash script again.
 

manAUX_Limit.patch:

Index: manAUX_Limit.patch
===================================================================
RCS file: /cvs/pkgs/rpms/anacron/devel/manAUX_Limit.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- manAUX_Limit.patch	10 Feb 2009 09:58:12 -0000	1.2
+++ manAUX_Limit.patch	27 Mar 2009 09:43:13 -0000	1.3
@@ -1,9 +1,36 @@
-diff -up anacron-2.3/anacrontab.5.mmm anacron-2.3/anacrontab.5
---- anacron-2.3/anacrontab.5.mmm	2009-02-10 10:42:17.000000000 +0100
-+++ anacron-2.3/anacrontab.5	2009-02-10 10:51:26.000000000 +0100
+diff -up anacron-2.3/anacron.8.aux anacron-2.3/anacron.8
+--- anacron-2.3/anacron.8.aux	2009-03-24 14:16:39.000000000 +0100
++++ anacron-2.3/anacron.8	2009-03-24 14:22:41.000000000 +0100
+@@ -1,4 +1,4 @@
+-.TH ANACRON 8 2004-07-11 "Pascal Hakim" "Anacron Users' Manual"
++.TH ANACRON 8 2009-03-24 "Marcela Mašláňová" "Anacron Users' Manual"
+ .SH NAME
+ anacron \- runs commands periodically
+ .SH SYNOPSIS
+@@ -66,8 +66,8 @@ exists. If the LOGNAME environment varia
+ field.
+ .PP
+ Informative messages about what Anacron is doing are sent to \fBsyslogd(8)\fR
+-under facility \fBcron\fR, priority \fBnotice\fR.  Error messages are sent at
+-priority \fBerror\fR.
++or \fBrsyslogd(8)\fR under facility \fBcron\fR, priority \fBnotice\fR.  Error 
++messages are sent at priority \fBerror\fR.
+ .PP
+ "Active" jobs (i.e. jobs that Anacron already decided
+ to run and now wait for their delay to pass, and jobs that are currently
+@@ -163,4 +163,5 @@ The current implementation is a complete
+ The code base was maintained by Sean 'Shaleh' Perry <shaleh@(debian.org|valinux.com)>.
+ .PP
+ Since 2004, it is maintained by Pascal Hakim <pasc@(debian.org|redellipse.net)>.
+-
++.PP
++For Fedora is anacron maintained by Marcela Mašláňová <mmaslano at redhat.com>.
+diff -up anacron-2.3/anacrontab.5.aux anacron-2.3/anacrontab.5
+--- anacron-2.3/anacrontab.5.aux	2009-03-24 14:16:39.000000000 +0100
++++ anacron-2.3/anacrontab.5	2009-03-24 14:23:39.000000000 +0100
 @@ -1,4 +1,4 @@
 -.TH ANACRONTAB 5 2004-07-11 "Pascal Hakim" "Anacron Users' Manual"
-+.TH ANACRONTAB 5 2009-02-02 "Marcela Mašláňová" "Anacron Users' Manual"
++.TH ANACRONTAB 5 2009-03-24 "Marcela Mašláňová" "Anacron Users' Manual"
  .SH NAME
  /etc/anacrontab \- configuration file for anacron
  .SH DESCRIPTION
@@ -61,3 +88,9 @@
  .SH "SEE ALSO"
  .B anacron(8)
  .PP
+@@ -58,3 +83,5 @@ file.
+ Itai Tzur <itzur at actcom.co.il>
+ .PP
+ Currently maintained by Pascal Hakim <pasc@(debian.org|redellipse.net)>.
++.PP
++For Fedora maintained by Marcela Mašláňová <mmaslano at redhat.com>.




More information about the fedora-extras-commits mailing list