aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Koeller <lkoeller@FreeBSD.org>2004-01-12 19:56:23 +0000
committerLars Koeller <lkoeller@FreeBSD.org>2004-01-12 19:56:23 +0000
commit47e504a16df9306ab07795a197cef3e021d1f59e (patch)
tree8a43c2d199b80cdcf27cad1ce002f5fe4af01ed3
parentf0f8f19eec88fccc1a1879ca7b00670b7d051a35 (diff)
downloadports-47e504a16df9306ab07795a197cef3e021d1f59e.tar.gz
ports-47e504a16df9306ab07795a197cef3e021d1f59e.zip
Notes
-rw-r--r--sysutils/bacula-server/Makefile15
-rw-r--r--sysutils/bacula-server/files/patch-eom-nextvol278
-rw-r--r--sysutils/bacula-server/files/patch-weekofmonth62
-rw-r--r--sysutils/bacula-server/pkg-deinstall26
-rw-r--r--sysutils/bacula-server/pkg-install16
-rw-r--r--sysutils/bacula/Makefile15
-rw-r--r--sysutils/bacula/files/patch-eom-nextvol278
-rw-r--r--sysutils/bacula/files/patch-weekofmonth62
-rw-r--r--sysutils/bacula/pkg-deinstall26
-rw-r--r--sysutils/bacula/pkg-install16
10 files changed, 774 insertions, 20 deletions
diff --git a/sysutils/bacula-server/Makefile b/sysutils/bacula-server/Makefile
index 8c0265b0a41c..97e5e44e40e7 100644
--- a/sysutils/bacula-server/Makefile
+++ b/sysutils/bacula-server/Makefile
@@ -7,7 +7,7 @@
PORTNAME= bacula
PORTVERSION= 1.32f
-#PORTREVISION= 1
+PORTREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= bacula
@@ -81,17 +81,18 @@ pre-everything::
post-patch:
@${REINPLACE_CMD} -e 's|-pthread|${PTHREAD_CFLAGS}|g' ${WRKSRC}/configure
-pre-install:
-.if !defined(WITH_CLIENT_ONLY)
- @ ${SETENV} PKG_PREFIX=${PREFIX} \
- ${SH} ${PKGINSTALL} ${PORTNAME} PRE-INSTALL
-.endif
-
post-install:
.if defined(WITH_CLIENT_ONLY)
+ # Extend only /etc/services
+ @ ${SETENV} PKG_PREFIX=${PREFIX} \
+ ${SH} ${PKGINSTALL} ${PORTNAME}
# don't know how to make it better
${RM} -f ${PREFIX}/etc/rc.d/bacula.sh.sample
.else
+ # Extend /etc/services and install UID/GID
+ @ ${SETENV} PKG_PREFIX=${PREFIX} \
+ ${SH} ${PKGINSTALL} ${PORTNAME} POST-INSTALL
+ # Install config files and preserve existing ones
${INSTALL_SCRIPT} ${FILESDIR}/chio-bacula ${PREFIX}/sbin
if [ -f ${PREFIX}/etc/bacula-barcodes ]; then \
${INSTALL_DATA} ${FILESDIR}/bacula-barcodes ${PREFIX}/etc/bacula-barcodes.new ; \
diff --git a/sysutils/bacula-server/files/patch-eom-nextvol b/sysutils/bacula-server/files/patch-eom-nextvol
new file mode 100644
index 000000000000..85b6c0050619
--- /dev/null
+++ b/sysutils/bacula-server/files/patch-eom-nextvol
@@ -0,0 +1,278 @@
+
+This patch fixes two bugs.
+1. Reported by Phil: where when the end of a Volume was reached,
+ Bacula went into a loop requesting the next Volume then gave up.
+2. Reported by Lars: the order of the next Volume selected by Bacula
+ was not as expected.
+
+Apply the patch with:
+
+ cd <bacula-source>
+ patch -p0 <1.32f-2-eom-nextvol.patch
+ make
+ ...
+
+Index: ReleaseNotes
+===================================================================
+RCS file: /cvsroot/bacula/bacula/ReleaseNotes,v
+retrieving revision 1.52.2.9.2.7
+retrieving revision 1.52.2.9.2.8
+diff -u -b -r1.52.2.9.2.7 -r1.52.2.9.2.8
+--- ReleaseNotes 31 Dec 2003 09:10:55 -0000 1.52.2.9.2.7
++++ ReleaseNotes 5 Jan 2004 16:49:44 -0000 1.52.2.9.2.8
+@@ -1,7 +1,14 @@
+
+- Release Notes for Bacula 1.32f
++ Release Notes for Bacula 1.32g
+
+ Bacula code: Total files = 262 Total lines = 80,318 (*.h *.c *.in)
++
++Changes since 1.32f
++- Fix bug reported by Phil (could not duplicate here) where at the end
++ of a Volume, Bacula wanted a new Volume and got into a loop requesting
++ it, then gave up.
++- Modify selection of next Volume to select most currently appended Volume,
++ or if none oldest recycled Volume (problem reported by Lars).
+
+ Changes since 1.32e:
+ - Note, this change affects only the Win32 FD.
+Index: src/cats/sql_find.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/cats/sql_find.c,v
+retrieving revision 1.23.2.7.2.1
+retrieving revision 1.23.2.7.2.2
+diff -u -b -r1.23.2.7.2.1 -r1.23.2.7.2.2
+--- src/cats/sql_find.c 7 Dec 2003 15:01:42 -0000 1.23.2.7.2.1
++++ src/cats/sql_find.c 5 Jan 2004 16:49:45 -0000 1.23.2.7.2.2
+@@ -7,7 +7,7 @@
+ *
+ * Kern Sibbald, December 2000
+ *
+- * Version $Id: sql_find.c,v 1.23.2.7.2.1 2003/12/07 15:01:42 kerns Exp $
++ * Version $Id: sql_find.c,v 1.23.2.7.2.2 2004/01/05 16:49:45 kerns Exp $
+ */
+
+ /*
+@@ -218,6 +218,7 @@
+ {
+ SQL_ROW row;
+ int numrows;
++ char *order;
+
+ db_lock(mdb);
+ if (item == -1) { /* find oldest volume */
+@@ -232,12 +233,19 @@
+ item = 1;
+ } else {
+ /* Find next available volume */
++ if (strcmp(mr->VolStatus, "Recycled") == 0 ||
++ strcmp(mr->VolStatus, "Purged") == 0) {
++ order = "ORDER BY LastWritten ASC,MediaId"; /* take oldest */
++ } else {
++ order = "ORDER BY LastWritten DESC,MediaId"; /* take most recently written */
++ }
+ Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
+-"VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
+-"VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
+-"FirstWritten,LastWritten,VolStatus "
+-"FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' "
+-"ORDER BY LastWritten,MediaId", mr->PoolId, mr->MediaType, mr->VolStatus);
++ "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
++ "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
++ "FirstWritten,LastWritten,VolStatus "
++ "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' "
++ "%s LIMIT 1",
++ mr->PoolId, mr->MediaType, mr->VolStatus, order);
+ }
+ if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
+ db_unlock(mdb);
+Index: src/stored/mount.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/stored/mount.c,v
+retrieving revision 1.42.2.9.2.3
+retrieving revision 1.42.2.9.2.4
+diff -u -b -r1.42.2.9.2.3 -r1.42.2.9.2.4
+--- src/stored/mount.c 8 Dec 2003 20:53:47 -0000 1.42.2.9.2.3
++++ src/stored/mount.c 5 Jan 2004 16:49:45 -0000 1.42.2.9.2.4
+@@ -5,7 +5,7 @@
+ *
+ * Kern Sibbald, August MMII
+ *
+- * Version $Id: mount.c,v 1.42.2.9.2.3 2003/12/08 20:53:47 kerns Exp $
++ * Version $Id: mount.c,v 1.42.2.9.2.4 2004/01/05 16:49:45 kerns Exp $
+ */
+ /*
+ Copyright (C) 2000-2003 Kern Sibbald and John Walker
+@@ -30,7 +30,8 @@
+ #include "bacula.h" /* pull in global headers */
+ #include "stored.h" /* pull in Storage Deamon headers */
+
+-/* Forward referenced functions */
++/* Forward referenced routines */
++static void mark_volume_in_error(JCR *jcr, DEVICE *dev);
+
+
+ /*
+@@ -47,11 +48,17 @@
+ */
+ int mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, int release)
+ {
+- int retry = 0, autochanger;
+- bool ask, recycle;
++ int retry = 0;
++ bool ask = false, recycle, autochanger;
++ int vol_label_status;
+
+ Dmsg0(100, "Enter mount_next_volume()\n");
+
++ /*
++ * Attempt to mount the next volume. If something non-fatal goes
++ * wrong, we come back here to re-try (new op messages, re-read
++ * Volume, ...)
++ */
+ mount_next_vol:
+ if (retry++ > 5) {
+ Jmsg(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
+@@ -62,8 +69,8 @@
+ Jmsg(jcr, M_FATAL, 0, _("Job %d canceled.\n"), jcr->JobId);
+ return 0;
+ }
+- autochanger = 0;
+- recycle = ask = false;
++ autochanger = false; /* Assume no autochanger */
++ recycle = false;
+ if (release) {
+ Dmsg0(100, "mount_next_volume release=1\n");
+ release_volume(jcr, dev);
+@@ -97,15 +104,10 @@
+ * It assumes that the device is not already in use!
+ *
+ */
+-
+-
+ dev->state &= ~(ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
+
+- for ( ;; ) {
+- int vol_label_status;
+ autochanger = autoload_device(jcr, dev, 1, NULL);
+ Dmsg1(100, "autoload_dev returns %d\n", autochanger);
+-
+ /*
+ * If we autochanged to correct Volume or (we have not just
+ * released the Volume AND we can automount) we go ahead
+@@ -116,7 +118,7 @@
+ ask = false; /* don't ask SYSOP this time */
+ }
+ Dmsg2(100, "Ask=%d autochanger=%d\n", ask, autochanger);
+- release = 1; /* release next time if we "recurse" */
++ release = true; /* release next time if we "recurse" */
+
+ if (ask && !dir_ask_sysop_to_mount_next_volume(jcr, dev)) {
+ Dmsg0(100, "Error return ask_sysop ...\n");
+@@ -181,14 +183,15 @@
+ /* Check if this is a valid Volume in the pool */
+ pm_strcpy(&jcr->VolumeName, dev->VolHdr.VolName);
+ if (!dir_get_volume_info(jcr, GET_VOL_INFO_FOR_WRITE)) {
+- Mmsg(&jcr->errmsg, _("Director wanted Volume \"%s\".\n"
++ Jmsg(jcr, M_WARNING, 0, _("Director wanted Volume \"%s\".\n"
+ " Current Volume \"%s\" not acceptable because:\n"
+ " %s"),
+ VolCatInfo.VolCatName, dev->VolHdr.VolName,
+ jcr->dir_bsock->msg);
+ /* Restore desired volume name, note device info out of sync */
+ memcpy(&jcr->VolCatInfo, &VolCatInfo, sizeof(jcr->VolCatInfo));
+- goto mount_error;
++ ask = true;
++ goto mount_next_vol;
+ }
+ Dmsg1(100, "want new name=%s\n", jcr->VolumeName);
+ memcpy(&dev->VolCatInfo, &jcr->VolCatInfo, sizeof(dev->VolCatInfo));
+@@ -230,15 +233,11 @@
+ /* NOTE! Fall-through wanted. */
+ case VOL_NO_MEDIA:
+ default:
+-mount_error:
+ /* Send error message */
+ Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+ ask = true;
+- /* was - goto ask_again; */
+ goto mount_next_vol;
+ }
+- break;
+- }
+
+ /*
+ * See if we have a fresh tape or a tape with data.
+@@ -322,6 +321,10 @@
+ Jmsg(jcr, M_INFO, 0, _("Wrote label to prelabeled Volume \"%s\" on device %s\n"),
+ jcr->VolumeName, dev_name(dev));
+ }
++ /*
++ * End writing real Volume label (from pre-labeled tape), or recycling
++ * the volume.
++ */
+
+ } else {
+ /*
+@@ -335,11 +338,7 @@
+ if (!eod_dev(dev)) {
+ Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data %s. ERR=%s\n"),
+ dev_name(dev), strerror_dev(dev));
+- Jmsg(jcr, M_INFO, 0, _("Marking Volume \"%s\" in Error in Catalog.\n"),
+- jcr->VolumeName);
+- bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus));
+- Dmsg0(100, "dir_update_vol_info. Set Error.\n");
+- dir_update_volume_info(jcr, dev, 0);
++ mark_volume_in_error(jcr, dev);
+ goto mount_next_vol;
+ }
+ /* *****FIXME**** we should do some checking for files too */
+@@ -355,9 +354,7 @@
+ Jmsg(jcr, M_ERROR, 0, _("I canot write on this volume because:\n\
+ The number of files mismatch! Volume=%u Catalog=%u\n"),
+ dev_file(dev), dev->VolCatInfo.VolCatFiles);
+- bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus));
+- Dmsg0(100, "dir_update_vol_info. Set Error.\n");
+- dir_update_volume_info(jcr, dev, 0);
++ mark_volume_in_error(jcr, dev);
+ goto mount_next_vol;
+ }
+ }
+@@ -372,7 +369,19 @@
+ return 1;
+ }
+
++static void mark_volume_in_error(JCR *jcr, DEVICE *dev)
++{
++ Jmsg(jcr, M_INFO, 0, _("Marking Volume \"%s\" in Error in Catalog.\n"),
++ jcr->VolumeName);
++ bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus));
++ Dmsg0(100, "dir_update_vol_info. Set Error.\n");
++ dir_update_volume_info(jcr, dev, 0);
++}
+
++/*
++ * If we are reading, we come here at the end of the tape
++ * and see if there are more volumes to be mounted.
++ */
+ int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
+ {
+ Dmsg2(90, "NumVolumes=%d CurVolume=%d\n", jcr->NumVolumes, jcr->CurVolume);
+@@ -399,7 +408,6 @@
+ */
+ void release_volume(JCR *jcr, DEVICE *dev)
+ {
+-
+ if (jcr->WroteVol) {
+ Jmsg0(jcr, M_ERROR, 0, "Hey!!!!! WroteVol non-zero !!!!!\n");
+ }
+@@ -411,7 +419,8 @@
+ memset(&dev->VolCatInfo, 0, sizeof(dev->VolCatInfo));
+ memset(&jcr->VolCatInfo, 0, sizeof(jcr->VolCatInfo));
+ memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
+- dev->state &= ~ST_LABEL; /* label not yet read */
++ /* Force re-read of label */
++ dev->state &= ~(ST_LABEL|ST_READ|ST_APPEND);
+ jcr->VolumeName[0] = 0;
+
+ if ((dev->state & ST_OPENED) &&
diff --git a/sysutils/bacula-server/files/patch-weekofmonth b/sysutils/bacula-server/files/patch-weekofmonth
new file mode 100644
index 000000000000..e9cfe667655b
--- /dev/null
+++ b/sysutils/bacula-server/files/patch-weekofmonth
@@ -0,0 +1,62 @@
+
+This patch fixes an incorrect calculation of the week
+of the month reported by Volker Sauer. It should work on either
+1.32e or 1.32f.
+
+Apply the patch with:
+
+ cd <bacula-source>
+ patch -p0 <1.32f-weekofmonth.patch
+ make
+ ...
+
+Index: src/dird/scheduler.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/scheduler.c,v
+retrieving revision 1.13.6.1
+diff -u -b -r1.13.6.1 scheduler.c
+--- src/dird/scheduler.c 21 Dec 2003 15:17:42 -0000 1.13.6.1
++++ src/dird/scheduler.c 6 Jan 2004 09:43:31 -0000
+@@ -205,7 +205,7 @@
+ mday = tm.tm_mday - 1;
+ wday = tm.tm_wday;
+ month = tm.tm_mon;
+- wom = tm_wom(tm.tm_mday, tm.tm_wday); /* get week of month */
++ wom = mday / 7;
+ woy = tm_woy(now); /* get week of year */
+
+ /* Loop through all jobs */
+@@ -237,7 +237,7 @@
+ if (bit_is_set(next_hour, run->hour)) {
+ tm.tm_hour++;
+ if (tm.tm_hour > 23) {
+- tm.tm_hour = 0;
++ continue; /* next day */
+ }
+ runtime = mktime(&tm);
+ add_job(job, run, now, runtime);
+Index: src/dird/ua_output.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/ua_output.c,v
+retrieving revision 1.25.2.11.2.3
+diff -u -b -r1.25.2.11.2.3 ua_output.c
+--- src/dird/ua_output.c 21 Dec 2003 15:17:42 -0000 1.25.2.11.2.3
++++ src/dird/ua_output.c 6 Jan 2004 09:43:32 -0000
+@@ -454,7 +454,7 @@
+ mday = tm.tm_mday - 1;
+ wday = tm.tm_wday;
+ month = tm.tm_mon;
+- wom = tm_wom(tm.tm_mday, tm.tm_wday);
++ wom = mday / 7;
+ woy = tm_woy(now);
+
+ /* Break down tomorrow into components */
+@@ -463,7 +463,7 @@
+ tmday = tm.tm_mday - 1;
+ twday = tm.tm_wday;
+ tmonth = tm.tm_mon;
+- twom = tm_wom(tm.tm_mday, tm.tm_wday);
++ twom = tmday / 7;
+ twoy = tm_woy(tomorrow);
+
+ if (run == NULL) {
diff --git a/sysutils/bacula-server/pkg-deinstall b/sysutils/bacula-server/pkg-deinstall
new file mode 100644
index 000000000000..28189213142e
--- /dev/null
+++ b/sysutils/bacula-server/pkg-deinstall
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+PATH=/bin:/usr/bin:/usr/sbin
+TMPFILE=/tmp/services-$RANDOM-$$
+if [ -z "${BACULA_DIR}" ]; then
+ BACULA_DIR=/var/db/bacula
+fi
+
+case "$2" in
+"DEINSTALL")
+ # Delete entries in /etc/services
+ sed -e '/# Bacula port start/,/# Bacule port end/{' \
+ -e 'd' \
+ -e '}' /etc/services > $TMPFILE
+ mv -f $TMPFILE /etc/services
+
+ # Note how to delete UID/GID
+ USER=bacula
+ GROUP=${USER}
+ if pw usershow "${USER}" 2>/dev/null 1>&2; then
+ echo "To delete Bacula user permanently, use 'pw userdel ${USER}'"
+ echo "To delete Bacula group permanently, use 'pw groupdel ${GROUP}'"
+ echo "Check if ${BACULA_DIR} is empty and delete it to permanently remove the port"
+ fi
+ ;;
+esac
diff --git a/sysutils/bacula-server/pkg-install b/sysutils/bacula-server/pkg-install
index 5dccbf6c32b7..460b57fbfd6a 100644
--- a/sysutils/bacula-server/pkg-install
+++ b/sysutils/bacula-server/pkg-install
@@ -1,12 +1,23 @@
#!/bin/sh
-PATH=/bin:/usr/sbin
+PATH=/bin:/usr/bin:/usr/sbin
if [ -z "${BACULA_DIR}" ]; then
BACULA_DIR=/var/db/bacula
fi
+# Always add lines in /etc/services
+grep -q "bacula-dir" /etc/services
+if [ "$?" != "0" ]; then
+ echo "# Bacula port start
+bacula-dir 9101/tcp #Bacula director daemon
+bacula-fd 9102/tcp #Bacula file daemon
+bacula-sd 9103/tcp #Bacula storage daemon
+# Bacule port end" >> /etc/services
+fi
+
case $2 in
-PRE-INSTALL)
+POST-INSTALL)
+ # Install UID/GID
USER=bacula
GROUP=${USER}
UID=910
@@ -42,7 +53,6 @@ PRE-INSTALL)
exit 1
fi
fi
-
chown -R ${USER}:${GROUP} ${BACULA_DIR}
;;
esac
diff --git a/sysutils/bacula/Makefile b/sysutils/bacula/Makefile
index 8c0265b0a41c..97e5e44e40e7 100644
--- a/sysutils/bacula/Makefile
+++ b/sysutils/bacula/Makefile
@@ -7,7 +7,7 @@
PORTNAME= bacula
PORTVERSION= 1.32f
-#PORTREVISION= 1
+PORTREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= bacula
@@ -81,17 +81,18 @@ pre-everything::
post-patch:
@${REINPLACE_CMD} -e 's|-pthread|${PTHREAD_CFLAGS}|g' ${WRKSRC}/configure
-pre-install:
-.if !defined(WITH_CLIENT_ONLY)
- @ ${SETENV} PKG_PREFIX=${PREFIX} \
- ${SH} ${PKGINSTALL} ${PORTNAME} PRE-INSTALL
-.endif
-
post-install:
.if defined(WITH_CLIENT_ONLY)
+ # Extend only /etc/services
+ @ ${SETENV} PKG_PREFIX=${PREFIX} \
+ ${SH} ${PKGINSTALL} ${PORTNAME}
# don't know how to make it better
${RM} -f ${PREFIX}/etc/rc.d/bacula.sh.sample
.else
+ # Extend /etc/services and install UID/GID
+ @ ${SETENV} PKG_PREFIX=${PREFIX} \
+ ${SH} ${PKGINSTALL} ${PORTNAME} POST-INSTALL
+ # Install config files and preserve existing ones
${INSTALL_SCRIPT} ${FILESDIR}/chio-bacula ${PREFIX}/sbin
if [ -f ${PREFIX}/etc/bacula-barcodes ]; then \
${INSTALL_DATA} ${FILESDIR}/bacula-barcodes ${PREFIX}/etc/bacula-barcodes.new ; \
diff --git a/sysutils/bacula/files/patch-eom-nextvol b/sysutils/bacula/files/patch-eom-nextvol
new file mode 100644
index 000000000000..85b6c0050619
--- /dev/null
+++ b/sysutils/bacula/files/patch-eom-nextvol
@@ -0,0 +1,278 @@
+
+This patch fixes two bugs.
+1. Reported by Phil: where when the end of a Volume was reached,
+ Bacula went into a loop requesting the next Volume then gave up.
+2. Reported by Lars: the order of the next Volume selected by Bacula
+ was not as expected.
+
+Apply the patch with:
+
+ cd <bacula-source>
+ patch -p0 <1.32f-2-eom-nextvol.patch
+ make
+ ...
+
+Index: ReleaseNotes
+===================================================================
+RCS file: /cvsroot/bacula/bacula/ReleaseNotes,v
+retrieving revision 1.52.2.9.2.7
+retrieving revision 1.52.2.9.2.8
+diff -u -b -r1.52.2.9.2.7 -r1.52.2.9.2.8
+--- ReleaseNotes 31 Dec 2003 09:10:55 -0000 1.52.2.9.2.7
++++ ReleaseNotes 5 Jan 2004 16:49:44 -0000 1.52.2.9.2.8
+@@ -1,7 +1,14 @@
+
+- Release Notes for Bacula 1.32f
++ Release Notes for Bacula 1.32g
+
+ Bacula code: Total files = 262 Total lines = 80,318 (*.h *.c *.in)
++
++Changes since 1.32f
++- Fix bug reported by Phil (could not duplicate here) where at the end
++ of a Volume, Bacula wanted a new Volume and got into a loop requesting
++ it, then gave up.
++- Modify selection of next Volume to select most currently appended Volume,
++ or if none oldest recycled Volume (problem reported by Lars).
+
+ Changes since 1.32e:
+ - Note, this change affects only the Win32 FD.
+Index: src/cats/sql_find.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/cats/sql_find.c,v
+retrieving revision 1.23.2.7.2.1
+retrieving revision 1.23.2.7.2.2
+diff -u -b -r1.23.2.7.2.1 -r1.23.2.7.2.2
+--- src/cats/sql_find.c 7 Dec 2003 15:01:42 -0000 1.23.2.7.2.1
++++ src/cats/sql_find.c 5 Jan 2004 16:49:45 -0000 1.23.2.7.2.2
+@@ -7,7 +7,7 @@
+ *
+ * Kern Sibbald, December 2000
+ *
+- * Version $Id: sql_find.c,v 1.23.2.7.2.1 2003/12/07 15:01:42 kerns Exp $
++ * Version $Id: sql_find.c,v 1.23.2.7.2.2 2004/01/05 16:49:45 kerns Exp $
+ */
+
+ /*
+@@ -218,6 +218,7 @@
+ {
+ SQL_ROW row;
+ int numrows;
++ char *order;
+
+ db_lock(mdb);
+ if (item == -1) { /* find oldest volume */
+@@ -232,12 +233,19 @@
+ item = 1;
+ } else {
+ /* Find next available volume */
++ if (strcmp(mr->VolStatus, "Recycled") == 0 ||
++ strcmp(mr->VolStatus, "Purged") == 0) {
++ order = "ORDER BY LastWritten ASC,MediaId"; /* take oldest */
++ } else {
++ order = "ORDER BY LastWritten DESC,MediaId"; /* take most recently written */
++ }
+ Mmsg(&mdb->cmd, "SELECT MediaId,VolumeName,VolJobs,VolFiles,VolBlocks,"
+-"VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
+-"VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
+-"FirstWritten,LastWritten,VolStatus "
+-"FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' "
+-"ORDER BY LastWritten,MediaId", mr->PoolId, mr->MediaType, mr->VolStatus);
++ "VolBytes,VolMounts,VolErrors,VolWrites,MaxVolBytes,VolCapacityBytes,"
++ "VolRetention,VolUseDuration,MaxVolJobs,MaxVolFiles,Recycle,Slot,"
++ "FirstWritten,LastWritten,VolStatus "
++ "FROM Media WHERE PoolId=%u AND MediaType='%s' AND VolStatus='%s' "
++ "%s LIMIT 1",
++ mr->PoolId, mr->MediaType, mr->VolStatus, order);
+ }
+ if (!QUERY_DB(jcr, mdb, mdb->cmd)) {
+ db_unlock(mdb);
+Index: src/stored/mount.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/stored/mount.c,v
+retrieving revision 1.42.2.9.2.3
+retrieving revision 1.42.2.9.2.4
+diff -u -b -r1.42.2.9.2.3 -r1.42.2.9.2.4
+--- src/stored/mount.c 8 Dec 2003 20:53:47 -0000 1.42.2.9.2.3
++++ src/stored/mount.c 5 Jan 2004 16:49:45 -0000 1.42.2.9.2.4
+@@ -5,7 +5,7 @@
+ *
+ * Kern Sibbald, August MMII
+ *
+- * Version $Id: mount.c,v 1.42.2.9.2.3 2003/12/08 20:53:47 kerns Exp $
++ * Version $Id: mount.c,v 1.42.2.9.2.4 2004/01/05 16:49:45 kerns Exp $
+ */
+ /*
+ Copyright (C) 2000-2003 Kern Sibbald and John Walker
+@@ -30,7 +30,8 @@
+ #include "bacula.h" /* pull in global headers */
+ #include "stored.h" /* pull in Storage Deamon headers */
+
+-/* Forward referenced functions */
++/* Forward referenced routines */
++static void mark_volume_in_error(JCR *jcr, DEVICE *dev);
+
+
+ /*
+@@ -47,11 +48,17 @@
+ */
+ int mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, int release)
+ {
+- int retry = 0, autochanger;
+- bool ask, recycle;
++ int retry = 0;
++ bool ask = false, recycle, autochanger;
++ int vol_label_status;
+
+ Dmsg0(100, "Enter mount_next_volume()\n");
+
++ /*
++ * Attempt to mount the next volume. If something non-fatal goes
++ * wrong, we come back here to re-try (new op messages, re-read
++ * Volume, ...)
++ */
+ mount_next_vol:
+ if (retry++ > 5) {
+ Jmsg(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
+@@ -62,8 +69,8 @@
+ Jmsg(jcr, M_FATAL, 0, _("Job %d canceled.\n"), jcr->JobId);
+ return 0;
+ }
+- autochanger = 0;
+- recycle = ask = false;
++ autochanger = false; /* Assume no autochanger */
++ recycle = false;
+ if (release) {
+ Dmsg0(100, "mount_next_volume release=1\n");
+ release_volume(jcr, dev);
+@@ -97,15 +104,10 @@
+ * It assumes that the device is not already in use!
+ *
+ */
+-
+-
+ dev->state &= ~(ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
+
+- for ( ;; ) {
+- int vol_label_status;
+ autochanger = autoload_device(jcr, dev, 1, NULL);
+ Dmsg1(100, "autoload_dev returns %d\n", autochanger);
+-
+ /*
+ * If we autochanged to correct Volume or (we have not just
+ * released the Volume AND we can automount) we go ahead
+@@ -116,7 +118,7 @@
+ ask = false; /* don't ask SYSOP this time */
+ }
+ Dmsg2(100, "Ask=%d autochanger=%d\n", ask, autochanger);
+- release = 1; /* release next time if we "recurse" */
++ release = true; /* release next time if we "recurse" */
+
+ if (ask && !dir_ask_sysop_to_mount_next_volume(jcr, dev)) {
+ Dmsg0(100, "Error return ask_sysop ...\n");
+@@ -181,14 +183,15 @@
+ /* Check if this is a valid Volume in the pool */
+ pm_strcpy(&jcr->VolumeName, dev->VolHdr.VolName);
+ if (!dir_get_volume_info(jcr, GET_VOL_INFO_FOR_WRITE)) {
+- Mmsg(&jcr->errmsg, _("Director wanted Volume \"%s\".\n"
++ Jmsg(jcr, M_WARNING, 0, _("Director wanted Volume \"%s\".\n"
+ " Current Volume \"%s\" not acceptable because:\n"
+ " %s"),
+ VolCatInfo.VolCatName, dev->VolHdr.VolName,
+ jcr->dir_bsock->msg);
+ /* Restore desired volume name, note device info out of sync */
+ memcpy(&jcr->VolCatInfo, &VolCatInfo, sizeof(jcr->VolCatInfo));
+- goto mount_error;
++ ask = true;
++ goto mount_next_vol;
+ }
+ Dmsg1(100, "want new name=%s\n", jcr->VolumeName);
+ memcpy(&dev->VolCatInfo, &jcr->VolCatInfo, sizeof(dev->VolCatInfo));
+@@ -230,15 +233,11 @@
+ /* NOTE! Fall-through wanted. */
+ case VOL_NO_MEDIA:
+ default:
+-mount_error:
+ /* Send error message */
+ Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+ ask = true;
+- /* was - goto ask_again; */
+ goto mount_next_vol;
+ }
+- break;
+- }
+
+ /*
+ * See if we have a fresh tape or a tape with data.
+@@ -322,6 +321,10 @@
+ Jmsg(jcr, M_INFO, 0, _("Wrote label to prelabeled Volume \"%s\" on device %s\n"),
+ jcr->VolumeName, dev_name(dev));
+ }
++ /*
++ * End writing real Volume label (from pre-labeled tape), or recycling
++ * the volume.
++ */
+
+ } else {
+ /*
+@@ -335,11 +338,7 @@
+ if (!eod_dev(dev)) {
+ Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data %s. ERR=%s\n"),
+ dev_name(dev), strerror_dev(dev));
+- Jmsg(jcr, M_INFO, 0, _("Marking Volume \"%s\" in Error in Catalog.\n"),
+- jcr->VolumeName);
+- bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus));
+- Dmsg0(100, "dir_update_vol_info. Set Error.\n");
+- dir_update_volume_info(jcr, dev, 0);
++ mark_volume_in_error(jcr, dev);
+ goto mount_next_vol;
+ }
+ /* *****FIXME**** we should do some checking for files too */
+@@ -355,9 +354,7 @@
+ Jmsg(jcr, M_ERROR, 0, _("I canot write on this volume because:\n\
+ The number of files mismatch! Volume=%u Catalog=%u\n"),
+ dev_file(dev), dev->VolCatInfo.VolCatFiles);
+- bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus));
+- Dmsg0(100, "dir_update_vol_info. Set Error.\n");
+- dir_update_volume_info(jcr, dev, 0);
++ mark_volume_in_error(jcr, dev);
+ goto mount_next_vol;
+ }
+ }
+@@ -372,7 +369,19 @@
+ return 1;
+ }
+
++static void mark_volume_in_error(JCR *jcr, DEVICE *dev)
++{
++ Jmsg(jcr, M_INFO, 0, _("Marking Volume \"%s\" in Error in Catalog.\n"),
++ jcr->VolumeName);
++ bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus));
++ Dmsg0(100, "dir_update_vol_info. Set Error.\n");
++ dir_update_volume_info(jcr, dev, 0);
++}
+
++/*
++ * If we are reading, we come here at the end of the tape
++ * and see if there are more volumes to be mounted.
++ */
+ int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
+ {
+ Dmsg2(90, "NumVolumes=%d CurVolume=%d\n", jcr->NumVolumes, jcr->CurVolume);
+@@ -399,7 +408,6 @@
+ */
+ void release_volume(JCR *jcr, DEVICE *dev)
+ {
+-
+ if (jcr->WroteVol) {
+ Jmsg0(jcr, M_ERROR, 0, "Hey!!!!! WroteVol non-zero !!!!!\n");
+ }
+@@ -411,7 +419,8 @@
+ memset(&dev->VolCatInfo, 0, sizeof(dev->VolCatInfo));
+ memset(&jcr->VolCatInfo, 0, sizeof(jcr->VolCatInfo));
+ memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
+- dev->state &= ~ST_LABEL; /* label not yet read */
++ /* Force re-read of label */
++ dev->state &= ~(ST_LABEL|ST_READ|ST_APPEND);
+ jcr->VolumeName[0] = 0;
+
+ if ((dev->state & ST_OPENED) &&
diff --git a/sysutils/bacula/files/patch-weekofmonth b/sysutils/bacula/files/patch-weekofmonth
new file mode 100644
index 000000000000..e9cfe667655b
--- /dev/null
+++ b/sysutils/bacula/files/patch-weekofmonth
@@ -0,0 +1,62 @@
+
+This patch fixes an incorrect calculation of the week
+of the month reported by Volker Sauer. It should work on either
+1.32e or 1.32f.
+
+Apply the patch with:
+
+ cd <bacula-source>
+ patch -p0 <1.32f-weekofmonth.patch
+ make
+ ...
+
+Index: src/dird/scheduler.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/scheduler.c,v
+retrieving revision 1.13.6.1
+diff -u -b -r1.13.6.1 scheduler.c
+--- src/dird/scheduler.c 21 Dec 2003 15:17:42 -0000 1.13.6.1
++++ src/dird/scheduler.c 6 Jan 2004 09:43:31 -0000
+@@ -205,7 +205,7 @@
+ mday = tm.tm_mday - 1;
+ wday = tm.tm_wday;
+ month = tm.tm_mon;
+- wom = tm_wom(tm.tm_mday, tm.tm_wday); /* get week of month */
++ wom = mday / 7;
+ woy = tm_woy(now); /* get week of year */
+
+ /* Loop through all jobs */
+@@ -237,7 +237,7 @@
+ if (bit_is_set(next_hour, run->hour)) {
+ tm.tm_hour++;
+ if (tm.tm_hour > 23) {
+- tm.tm_hour = 0;
++ continue; /* next day */
+ }
+ runtime = mktime(&tm);
+ add_job(job, run, now, runtime);
+Index: src/dird/ua_output.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/dird/ua_output.c,v
+retrieving revision 1.25.2.11.2.3
+diff -u -b -r1.25.2.11.2.3 ua_output.c
+--- src/dird/ua_output.c 21 Dec 2003 15:17:42 -0000 1.25.2.11.2.3
++++ src/dird/ua_output.c 6 Jan 2004 09:43:32 -0000
+@@ -454,7 +454,7 @@
+ mday = tm.tm_mday - 1;
+ wday = tm.tm_wday;
+ month = tm.tm_mon;
+- wom = tm_wom(tm.tm_mday, tm.tm_wday);
++ wom = mday / 7;
+ woy = tm_woy(now);
+
+ /* Break down tomorrow into components */
+@@ -463,7 +463,7 @@
+ tmday = tm.tm_mday - 1;
+ twday = tm.tm_wday;
+ tmonth = tm.tm_mon;
+- twom = tm_wom(tm.tm_mday, tm.tm_wday);
++ twom = tmday / 7;
+ twoy = tm_woy(tomorrow);
+
+ if (run == NULL) {
diff --git a/sysutils/bacula/pkg-deinstall b/sysutils/bacula/pkg-deinstall
new file mode 100644
index 000000000000..28189213142e
--- /dev/null
+++ b/sysutils/bacula/pkg-deinstall
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+PATH=/bin:/usr/bin:/usr/sbin
+TMPFILE=/tmp/services-$RANDOM-$$
+if [ -z "${BACULA_DIR}" ]; then
+ BACULA_DIR=/var/db/bacula
+fi
+
+case "$2" in
+"DEINSTALL")
+ # Delete entries in /etc/services
+ sed -e '/# Bacula port start/,/# Bacule port end/{' \
+ -e 'd' \
+ -e '}' /etc/services > $TMPFILE
+ mv -f $TMPFILE /etc/services
+
+ # Note how to delete UID/GID
+ USER=bacula
+ GROUP=${USER}
+ if pw usershow "${USER}" 2>/dev/null 1>&2; then
+ echo "To delete Bacula user permanently, use 'pw userdel ${USER}'"
+ echo "To delete Bacula group permanently, use 'pw groupdel ${GROUP}'"
+ echo "Check if ${BACULA_DIR} is empty and delete it to permanently remove the port"
+ fi
+ ;;
+esac
diff --git a/sysutils/bacula/pkg-install b/sysutils/bacula/pkg-install
index 5dccbf6c32b7..460b57fbfd6a 100644
--- a/sysutils/bacula/pkg-install
+++ b/sysutils/bacula/pkg-install
@@ -1,12 +1,23 @@
#!/bin/sh
-PATH=/bin:/usr/sbin
+PATH=/bin:/usr/bin:/usr/sbin
if [ -z "${BACULA_DIR}" ]; then
BACULA_DIR=/var/db/bacula
fi
+# Always add lines in /etc/services
+grep -q "bacula-dir" /etc/services
+if [ "$?" != "0" ]; then
+ echo "# Bacula port start
+bacula-dir 9101/tcp #Bacula director daemon
+bacula-fd 9102/tcp #Bacula file daemon
+bacula-sd 9103/tcp #Bacula storage daemon
+# Bacule port end" >> /etc/services
+fi
+
case $2 in
-PRE-INSTALL)
+POST-INSTALL)
+ # Install UID/GID
USER=bacula
GROUP=${USER}
UID=910
@@ -42,7 +53,6 @@ PRE-INSTALL)
exit 1
fi
fi
-
chown -R ${USER}:${GROUP} ${BACULA_DIR}
;;
esac