ports/55959: New port: anacron

dz at 426.ch dz at 426.ch
Mon Aug 25 15:50:14 UTC 2003


>Number:         55959
>Category:       ports
>Synopsis:       New port: anacron
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 25 08:50:12 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Derik van Zuetphen
>Release:        FreeBSD 4.8-STABLE i386
>Organization:
>Environment:
System: FreeBSD trevize.a.426.ch 4.8-STABLE FreeBSD 4.8-STABLE #15: Thu Aug 21 15:08:11 CEST 2003 root at trevize.a.426.ch:/usr/src/sys/compile/TREVIZE i386


	
>Description:
	a periodic command scheduler
>How-To-Repeat:
	
>Fix:

	

--- anacron.shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	anacron
#	anacron/files
#	anacron/files/patch-aa
#	anacron/Makefile
#	anacron/pkg-descr
#	anacron/pkg-plist
#	anacron/distinfo
#	anacron/pkg-message
#
echo c - anacron
mkdir -p anacron > /dev/null 2>&1
echo c - anacron/files
mkdir -p anacron/files > /dev/null 2>&1
echo x - anacron/files/patch-aa
sed 's/^X//' >anacron/files/patch-aa << 'END-of-anacron/files/patch-aa'
Xdiff -uN ../anacron-2.3/Makefile ./Makefile
X--- ../anacron-2.3/Makefile	Fri Jun 23 00:26:11 2000
X+++ ./Makefile	Fri May  2 22:16:51 2003
X@@ -19,16 +19,16 @@
X #   `COPYING' that comes with the Anacron source distribution.
X 
X 
X-PREFIX = 
X-BINDIR = $(PREFIX)/usr/sbin
X-MANDIR = $(PREFIX)/usr/man
X+PREFIX = /usr/local
X+BINDIR = $(PREFIX)/sbin
X+MANDIR = $(PREFIX)/man
X CFLAGS = -Wall -pedantic -O2
X #CFLAGS = -Wall -O2 -g -DDEBUG
X 
X # If you change these, please update the man-pages too
X # Only absolute paths here, please
X SPOOLDIR = /var/spool/anacron
X-ANACRONTAB = /etc/anacrontab
X+ANACRONTAB = $(PREFIX)/etc/anacrontab
X 
X RELEASE = 2.3
X package_name = anacron-$(RELEASE)
X@@ -64,7 +64,7 @@
X 
X .PHONY: installdirs
X installdirs:
X-	$(INSTALL_DIR) $(BINDIR) $(PREFIX)$(SPOOLDIR) \
X+	$(INSTALL_DIR) $(BINDIR) $(SPOOLDIR) \
X 		$(MANDIR)/man5 $(MANDIR)/man8
X 
X .PHONY: install
X@@ -72,6 +72,7 @@
X 	$(INSTALL_PROGRAM) anacron $(BINDIR)/anacron
X 	$(INSTALL_DATA) anacrontab.5 $(MANDIR)/man5/anacrontab.5
X 	$(INSTALL_DATA) anacron.8 $(MANDIR)/man8/anacron.8
X+	$(INSTALL_DATA) anacrontab.sample $(PREFIX)/etc/anacrontab.sample
X 
X .PHONY: clean
X clean:
Xdiff -uN ../anacron-2.3/anacron.8 ./anacron.8
X--- ../anacron-2.3/anacron.8	Fri Jun 23 00:42:05 2000
X+++ ./anacron.8	Fri May  2 21:57:56 2003
X@@ -18,7 +18,7 @@
X usually controlled by \fBcron\fR.
X .PP
X When executed, Anacron reads a list of jobs from a configuration file, normally
X-.I /etc/anacrontab
X+.I /usr/local/etc/anacrontab
X (see \fBanacrontab(5)\fR).  This file
X contains the list of jobs that Anacron controls.  Each
X job entry specifies a period in days, 
X@@ -84,7 +84,7 @@
X .TP
X .B -n
X Run jobs now.  Ignore the delay specifications in the
X-.I /etc/anacrontab
X+.I /usr/local/etc/anacrontab
X file.  This options implies \fB-s\fR.
X .TP
X .B -d
X@@ -117,7 +117,7 @@
X for more information.
X .SH FILES
X .TP
X-.I /etc/anacrontab
X+.I /usr/local/etc/anacrontab
X Contains specifications of jobs.  See \fBanacrontab(5)\fR for a complete
X description.
X .TP
Xdiff -uN ../anacron-2.3/anacrontab.5 ./anacrontab.5
X--- ../anacron-2.3/anacrontab.5	Wed Jun 21 01:12:18 2000
X+++ ./anacrontab.5	Fri May  2 21:58:31 2003
X@@ -1,9 +1,9 @@
X .TH ANACRONTAB 5 1998-02-02 "Itai Tzur" "Anacron Users' Manual"
X .SH NAME
X-/etc/anacrontab \- configuration file for anacron
X+/usr/local/etc/anacrontab \- configuration file for anacron
X .SH DESCRIPTION
X The file
X-.I /etc/anacrontab
X+.I /usr/local/etc/anacrontab
X describes the jobs controlled by \fBanacron(8)\fR.  Its lines can be of
X three kinds:  job-description lines, environment
X assignments, or empty lines.
Xdiff -uN ../anacron-2.3/anacrontab.sample ./anacrontab.sample
X--- ../anacron-2.3/anacrontab.sample	Thu Jan  1 01:00:00 1970
X+++ ./anacrontab.sample	Sat May  3 20:14:43 2003
X@@ -0,0 +1,12 @@
X+
X+PATH=/bin:/sbin:/usr/bin:/usr/sbin
X+
X+# days		make sure the command is executed at least every 'days' days
X+# delay		delay in minutes, before a command starts
X+# id		unique id of a command
X+
X+# days	delay	id		command
X+1	5	daily		periodic daily
X+7	15	weekly		periodic weekly
X+30	60	monthly		periodic monthly
X+
Xdiff -uN ../anacron-2.3/matchrx.c ./matchrx.c
X--- ../anacron-2.3/matchrx.c	Wed Jun 21 01:12:18 2000
X+++ ./matchrx.c	Thu May  1 14:46:35 2003
X@@ -23,6 +23,7 @@
X 
X 
X #include <stdio.h>
X+#include <unistd.h>
X #include <regex.h>
X #include <stdarg.h>
X #include <stdlib.h>
Xdiff -uN ../anacron-2.3/readtab.c ./readtab.c
X--- ../anacron-2.3/readtab.c	Fri Jun 23 00:13:12 2000
X+++ ./readtab.c	Mon Aug 25 16:46:18 2003
X@@ -19,6 +19,11 @@
X  
X     The GNU General Public License can also be found in the file
X     `COPYING' that comes with the Anacron source distribution.
X+
X+    Changes:
X+
X+    May 2003 (Derik van Zuetphen)
X+	replaced obstack with malloc/realloc calls
X */
X 
X 
X@@ -29,7 +34,6 @@
X #include <errno.h>
X #include <stdio.h>
X #include <stdlib.h>
X-#include <obstack.h>
X #include <limits.h>
X #include <fnmatch.h>
X #include <unistd.h>
X@@ -37,8 +41,6 @@
X #include "global.h"
X #include "matchrx.h"
X 
X-static struct obstack input_o;   /* holds input line */
X-static struct obstack tab_o;    /* holds processed data read from anacrontab */
X static FILE *tab;
X job_rec **job_array;
X int njobs;                       /* number of jobs to run */
X@@ -47,9 +49,7 @@
X static job_rec *last_job_rec;    /* last job stored in memory, at the moment */
X static env_rec *last_env_rec;    /* last environment assignment stored */
X 
X-/* some definitions for the obstack macros */
X-#define obstack_chunk_alloc xmalloc
X-#define obstack_chunk_free free
X+#define MAXTABLINE	1000
X 
X static void *
X xmalloc (size_t size)
X@@ -63,6 +63,18 @@
X     return ptr;
X }
X 
X+static void *
X+xrealloc (void *mem, size_t size)
X+/* Just like standard realloc(), only never returns NULL. */
X+{
X+    void * ptr;
X+
X+    ptr = realloc(mem,size);
X+    if (ptr == NULL)
X+	die("Memory exhausted");
X+    return ptr;
X+}
X+
X static int
X conv2int(const char *s)
X /* Return the int or -1 on over/under-flow
X@@ -78,19 +90,20 @@
X }
X 
X static char *
X-read_tab_line ()
X+read_tab_line (char *line)
X /* Read one line and return a pointer to it.
X Return NULL if no more lines.
X  */
X {
X     int c;
X+    int i = 0;
X 
X     if (feof(tab)) return NULL;
X-    while ((c = getc(tab)) != EOF && c != '\n')
X-	obstack_1grow(&input_o, c);
X+    while (i < MAXTABLINE-1 && (c = getc(tab)) != EOF && c != '\n')
X+	line[i++] = c;
X     if (ferror(tab)) die_e("Error reading %s", anacrontab);
X-    obstack_1grow(&input_o, '\0');
X-    return obstack_finish(&input_o);
X+    line[i] = 0;
X+    return line;
X }
X 
X static int
X@@ -119,8 +132,8 @@
X 
X     var_len = strlen(env_var);
X     val_len = strlen(value);
X-    er = obstack_alloc(&tab_o, sizeof(env_rec));
X-    er->assign = obstack_alloc(&tab_o, var_len + 1 + val_len + 1);
X+    er = (env_rec*)xmalloc(sizeof(env_rec));
X+    er->assign = (char*)xmalloc(var_len + 1 + val_len + 1);
X     strcpy(er->assign, env_var);
X     er->assign[var_len] = '=';
X     strcpy(er->assign + var_len + 1, value);
X@@ -151,14 +164,14 @@
X 		 anacrontab, line_num);
X 	return;
X     }
X-    jr = obstack_alloc(&tab_o, sizeof(job_rec));
X+    jr = (job_rec*)xmalloc(sizeof(job_rec));
X     jr->period = period;
X     jr->delay = delay;
X     jr->tab_line = line_num;
X-    jr->ident = obstack_alloc(&tab_o, ident_len + 1);
X+    jr->ident = (char*)xmalloc(ident_len + 1);
X     strcpy(jr->ident, ident);
X     jr->arg_num = job_arg_num(ident);
X-    jr->command = obstack_alloc(&tab_o, command_len + 1);
X+    jr->command = (char*)xmalloc(command_len + 1);
X     strcpy(jr->command, command);
X     jr->job_pid = jr->mailer_pid = 0;
X     if (last_job_rec != NULL) last_job_rec->next = jr;
X@@ -222,7 +235,7 @@
X read_tab()
X /* Read the anacrontab file into memory */
X {
X-    char *tab_line;
X+    char tab_line[MAXTABLINE];
X 
X     first_job_rec = last_job_rec = NULL;
X     first_env_rec = last_env_rec = NULL;
X@@ -231,14 +244,10 @@
X     /* Open the anacrontab file */
X     tab = fopen(anacrontab, "r");
X     if (tab == NULL) die_e("Error opening %s", anacrontab);
X-    /* Initialize the obstacks */
X-    obstack_init(&input_o);
X-    obstack_init(&tab_o);
X-    while ((tab_line = read_tab_line()) != NULL)
X+    while ((read_tab_line(tab_line)) != NULL)
X     {
X 	line_num++;
X 	parse_tab_line(tab_line);
X-	obstack_free(&input_o, tab_line);
X     }
X     if (fclose(tab)) die_e("Error closing %s", anacrontab);
X }
X@@ -269,16 +278,17 @@
X 
X     j = first_job_rec;
X     njobs = 0;
X+    job_array = NULL;
X     while (j != NULL)
X     {
X 	if (j->arg_num != -1 && (update_only || consider_job(j)))
X 	{
X+	    job_array = (job_rec**)xrealloc(job_array, (njobs+1)*sizeof(j));
X+	    job_array[njobs] = j;
X 	    njobs++;
X-	    obstack_grow(&tab_o, &j, sizeof(j));
X 	}
X 	j = j->next;
X     }
X-    job_array = obstack_finish(&tab_o);
X 
X     /* sort the jobs */
X     qsort(job_array, njobs, sizeof(*job_array),
END-of-anacron/files/patch-aa
echo x - anacron/Makefile
sed 's/^X//' >anacron/Makefile << 'END-of-anacron/Makefile'
X# New ports collection makefile for:   anacron
X# Date created:        15 Jul 2003
X# Whom:                Derik van Zuetphen <dz at 426.ch>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	anacron
XPORTVERSION=	2.3
XCATEGORIES=	sysutils
XMASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
XMASTER_SITE_SUBDIR=	anacron
X
XMAINTAINER=	dz at 426.ch
XCOMMENT=	Schedules periodic jobs on systems that are not permanently up
X
XMAN8=		anacron.8
XMAN5=		anacrontab.5
XUSE_GMAKE=	yes
X
Xpost-install:
X	${CAT} pkg-message
X	${STRIP_CMD} ${PREFIX}/sbin/anacron
X
X.include <bsd.port.mk>
END-of-anacron/Makefile
echo x - anacron/pkg-descr
sed 's/^X//' >anacron/pkg-descr << 'END-of-anacron/pkg-descr'
XAnacron is a periodic command scheduler.  It executes commands at
Xintervals specified in days.  Unlike cron, it does not assume that the
Xsystem is running continuously.  It can therefore be used to control
Xthe execution of daily, weekly and monthly jobs (or anything with a
Xperiod of n days), on systems that don't run 24 hours a day.
X
XAnacron is not an attempt to make cron redundant.
X
XRequirements
X - A functioning syslog daemon.
X - A functioning /usr/lib/sendmail command.  (all MTAs should have that).
X
XWWW: http://sourceforge.net/projects/anacron
END-of-anacron/pkg-descr
echo x - anacron/pkg-plist
sed 's/^X//' >anacron/pkg-plist << 'END-of-anacron/pkg-plist'
Xsbin/anacron
Xetc/anacrontab.sample
END-of-anacron/pkg-plist
echo x - anacron/distinfo
sed 's/^X//' >anacron/distinfo << 'END-of-anacron/distinfo'
XMD5 (anacron-2.3.tar.gz) = 865cc1dfe1ed75c470d3e6de13763f03
END-of-anacron/distinfo
echo x - anacron/pkg-message
sed 's/^X//' >anacron/pkg-message << 'END-of-anacron/pkg-message'
X
XConfiguration hints:
X- Copy ${PREFIX}/etc/anacrontab.sample to ${PREFIX}/etc/anacrontab
X- Activate the 'periodic' commands in anacrontab
X- Deactivate the 'periodic' commands in /etc/crontab
X- Add 'anacron' to /etc/rc.local
X- Read anacron(8) and anacrontab(5)
X
END-of-anacron/pkg-message
exit
--- anacron.shar ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list