Version: 2.3-13.1 Tags: patch Hi, the attached patch adds support for a /etc/anacrontab.local in the package. Note that you must be root to modify it. Still, I think it is a good place to put your "defrost the fridge reminders" so that they don't interfere with upgrades to the configuration file /etc/anacrontab.
Regards, Javi (Vicho)
--- a/global.h Sun May 04 19:22:24 2008 +0200 +++ b/global.h Sun May 04 20:34:50 2008 +0200 @@ -77,7 +77,8 @@ extern pid_t primary_pid; extern char *program_name; -extern char *anacrontab; +extern char **anacrontabs; +extern int anacrontab_count; extern char *spooldir; extern int old_umask; extern sigset_t old_sigmask; --- a/main.c Sun May 04 19:22:24 2008 +0200 +++ b/main.c Sun May 04 20:34:50 2008 +0200 @@ -25,6 +25,7 @@ #include <time.h> #include <stdio.h> +#include <stdlib.h> #include <unistd.h> #include <signal.h> #include <fcntl.h> @@ -39,7 +40,8 @@ int year, month, day_of_month; /* date anacron started */ char *program_name; -char *anacrontab; +char **anacrontabs; +int anacrontab_count; char *spooldir; int serialize, force, update_only, now, no_daemon, quiet, testing_only; /* command-line options */ @@ -124,7 +126,9 @@ quiet = 1; break; case 't': - anacrontab = strdup(optarg); + anacrontab_count++; + anacrontabs = (char **)realloc(anacrontabs, anacrontab_count*sizeof(char *)); + anacrontabs[anacrontab_count-1] = strdup(optarg); break; case 'T': testing_only = 1; @@ -428,7 +432,8 @@ int cwd; - anacrontab = NULL; + anacrontabs = NULL; + anacrontab_count = 0; spooldir = NULL; if((program_name = strrchr(argv[0], '/')) == NULL) @@ -438,8 +443,11 @@ parse_opts(argc, argv); - if (anacrontab == NULL) - anacrontab = strdup(ANACRONTAB); + if (anacrontabs == NULL) { + anacrontab_count = 1; + anacrontabs = (char **) malloc(sizeof(char *)); + *anacrontabs = strdup(ANACRONTAB); + } if (spooldir == NULL) spooldir = strdup(SPOOLDIR); --- a/readtab.c Sun May 04 19:22:24 2008 +0200 +++ b/readtab.c Sun May 04 20:34:50 2008 +0200 @@ -41,6 +41,7 @@ static struct obstack input_o; /* holds input line */ static struct obstack tab_o; /* holds processed data read from anacrontab */ static FILE *tab; +static char *anacrontab; job_rec **job_array; int njobs; /* number of jobs to run */ static int jobs_read; /* number of jobs read */ @@ -297,27 +298,33 @@ /* Read the anacrontab file into memory */ { char *tab_line; + int i; first_job_rec = last_job_rec = NULL; first_env_rec = last_env_rec = NULL; jobs_read = 0; line_num = 0; - /* Open the anacrontab file */ - fchdir (cwd); - tab = fopen(anacrontab, "r"); - if (chdir(spooldir)) die_e("Can't chdir to %s", SPOOLDIR); + for (i = 0; i < anacrontab_count; i++) + { + anacrontab = anacrontabs[i]; + explain("Parsing anacrontab file: %s", anacrontab); + /* Open the anacrontab file */ + fchdir (cwd); + tab = fopen(anacrontab, "r"); + if (chdir(spooldir)) die_e("Can't chdir to %s", SPOOLDIR); - if (tab == NULL) die_e("Error opening %s", anacrontab); - /* Initialize the obstacks */ - obstack_init(&input_o); - obstack_init(&tab_o); - while ((tab_line = read_tab_line()) != NULL) - { - line_num++; - parse_tab_line(tab_line); - obstack_free(&input_o, tab_line); + if (tab == NULL) die_e("Error opening %s", anacrontab); + /* Initialize the obstacks */ + obstack_init(&input_o); + obstack_init(&tab_o); + while ((tab_line = read_tab_line()) != NULL) + { + line_num++; + parse_tab_line(tab_line); + obstack_free(&input_o, tab_line); + } + if (fclose(tab)) die_e("Error closing %s", anacrontab); } - if (fclose(tab)) die_e("Error closing %s", anacrontab); } static int --- a/debian/init.d Sun May 04 20:52:02 2008 +0200 +++ b/debian/init.d Mon May 05 15:24:25 2008 +0200 @@ -32,7 +32,12 @@ # on_ac_power doesn't exist, on_ac_power returns 0 (ac power being used) # or on_ac_power returns 255 (undefined, desktop machine without APM) - start-stop-daemon --start --exec /usr/sbin/anacron -- -s + if [ -f /etc/anacrontab.local ]; then + ANACRONTABS="-t /etc/anacrontab -t /etc/anacrontab.local" + else + ANACRONTABS= + fi + start-stop-daemon --start --exec /usr/sbin/anacron -- -s $ANACRONTABS log_end_msg 0 ;; restart|force-reload) --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/anacrontab.local Thu May 22 20:54:44 2008 +0200 @@ -0,0 +1,6 @@ +# /etc/anacrontab.local: user-specific configuration file for anacron + +# See anacron(8) and anacrontab(5) for details. +# periodicity delay job_name cmd +#66 22 jidanni.fridge echo defrost the fridge + --- a/debian/rules Thu May 22 20:41:50 2008 +0200 +++ b/debian/rules Thu May 22 20:54:44 2008 +0200 @@ -32,6 +32,7 @@ $(MAKE) install PREFIX=debian/anacron MANDIR=debian/anacron/usr/share/man install -m 644 debian/anacrontab debian/anacron/etc/ + install -m 644 debian/anacrontab.local debian/anacron/etc/ install debian/0anacron.daily debian/anacron/etc/cron.daily/0anacron install debian/0anacron.weekly debian/anacron/etc/cron.weekly/0anacron install debian/0anacron.monthly debian/anacron/etc/cron.monthly/0anacron