Jan-Henrik Haukeland wrote:
> >If you can change your patch to include patching of monit.pod from  
> >configure via a new monit.pod.in file and also keep the hardcoded / 
> >usr/local/etc as mentioned by Martin it would be great.
> 
> That is, monit.pod should be replaced by monit.pod.in in the CVS and  
> I also agree that as long as SYSCONFDIR defaults to /usr/local/etc it  
> is sufficient.

I have deviated from your suggestion to create "monit.pod.in", because you
said in an earlier message:

JHH:  Not necessarily since the man file could be built during creation of
JHH:  the dist. However, this is internal stuff and not something we want
JHH:  to expose in a dist.

Shipping "monit.pod.in" and letting configure (as run by the user)
replace @sysconfdir@ would just expose what you want to hide.

Implemented by the appended patches, the configure script the end user
is running will not use pod2man (and thus need Perl) but simply replace
@sysconfdir@ in "monit.1.in".
By the way, the same reasons for creating "monit.1.in" apply to
"doc/monit.html.in" (instead of "doc/monit.html"), something I overlooked
last week.

The patches against the current CVS version of monit work the following
way:

- patch-bi: "monit.pod" from CVS is patched to contain "@sysconfdir@" instead
  of the hardcoded path "/usr/local/etc"

- patch-bj: "monit.1.in" is created from "monit.pod" by make_man and
  included in the archive.

- patch-bk: make_dist calls make_man and also creates "monit.html.in"
  before the first run of configure through autogen.sh to avoid warning
  messages about missing files.

- patch-ac: In "Makefile.in" [EMAIL PROTECTED]@ will be defined for
  the pre-processor.

- patch-ad: In "file.c" the macro SYSCONFDIR is used instead of a
  hardcoded path.

- patch-ag: "configure.ac" is modified to replace @sysconfdir@ in
  "monit.1.in" and "monit.html.in".

make_man and make_dist specify /bin/bash as the shell interpreter. I
took the liberty to change this to /bin/sh since both scripts seem to be
simple enough not to need bash-specific features. NetBSD's /bin/sh
worked fine for both.

With the appended patches applied I was able to successfully build and
run monit on NetBSD/i386 3.1 and Debian Sarge.

ciao
     Klaus
$NetBSD$

"@" needs to be escaped, otherwise it would be treated as introducing a Perl
array identifier. E<64> is not usable because pod2html converts it to a
HTML character entity instead of @, so S<> hopefully works around that.

--- monit.pod.orig      2007-02-19 14:53:46.000000000 +0100
+++ monit.pod
@@ -195,7 +195,7 @@ usage, memory and load average.
 monit is configured and controlled via a control file called
 B<monitrc>. The default location for this file is ~/.monitrc. If
 this file does not exist, monit will try /etc/monitrc, then
-/usr/local/etc/monitrc and finally ./monitrc.
+S<@sysconfdir@>/monitrc and finally ./monitrc.
 
 A monit control file consists of a series of service entries and
 global option statements in a free-format, token-oriented syntax.
$NetBSD$

We need to generate monit.1.in (containing @sysconfdir@) instead of monit.1

--- make_man.orig       2002-06-27 19:55:00.000000000 +0200
+++ make_man
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/bin/sh
 
 d=`date  '+%B %-d. %Y'`
 
-# monit.1
+# monit.1.in
 pod2man -center "User Commands" --release "${d}" \
-                 --date="www.tildeslash.com" --lax monit.pod > monit.1
+                 --date="www.tildeslash.com" --lax monit.pod > monit.1.in
$NetBSD$

The script does not seem to use bash-only features, it works with NetBSD's
/bin/sh just fine. Whether this holds for Solaris /bin/sh remains to be
seen :-).

Introduce facility to specify GNU make under a different name than "make", eg.
"MAKE=gmake ./make_dist".

monit.1.in and monit.html.in need to be generated before the first run
of "configure". Otherwise the script complains about their absence.

--- make_dist.orig      2006-03-05 23:39:25.000000000 +0100
+++ make_dist
@@ -1,7 +1,8 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Build the monit.tar.gz package
 #
+: ${MAKE:=make}
 
 clean_up() 
 {
@@ -32,6 +33,11 @@ CONFIGURE_OBJS="Makefile config.cache co
 # Man-file objects
 MAN_OBJS="*.1"
 
+./make_man     # man files
+# Create the monit man html file in doc
+pod2html monit.pod > doc/monit.html.in
+rm -f pod2*
+
 # Create the Makefile
 ./autogen.sh
 
@@ -40,22 +46,18 @@ MAN_OBJS="*.1"
 # -------------------------
 #rm -f doc/api-docs/*
 #perl -pi.bak -e 's/[EMAIL PROTECTED]@/'$VERSION'/' doxygen.cfg
-#make doc
+#${MAKE} doc
 #mv doxygen.cfg.bak doxygen.cfg
 
 # Cleanup before build
 rm -f *.tar.gz
-make devclean
+${MAKE} devclean
 clean_up
 
 # Copy the specfile to allow direct rpmbuild -ta
 cp contrib/packages/redhat/monit.spec ./
 perl -pi -e 's/^Version: .*/Version: '$VERSION'/' monit.spec
 
-# Create the monit man html file in doc
-pod2html monit.pod > doc/monit.html
-rm -f pod2*
-
 # Copy the the examples file to doc.
 lynx -dump -force-html -nolist web/doc/examples.php > doc/examples.html
 chmod 644 doc/examples.html
@@ -69,9 +71,8 @@ chmod 755 install-sh
 # -------------
 # Build package
 # -------------
-./make_man     # man files
 ./autogen.sh   # configure, config.h.in
-make distclean # Keep only the relevant files
+${MAKE} distclean # Keep only the relevant files
 
 # Build the dist file using current version in filename
 cd ..
$NetBSD$

C source files must be told where the "sysconfdir" is.

doc/monit.html.in will be included in the archive instead of doc/monit.html,
so we have to remove monit.html.

--- Makefile.in.orig    2007-01-11 17:07:10.000000000 +0100
+++ Makefile.in
@@ -61,7 +61,7 @@ PROG          = monit
 
 INCDIR         = -I. -I./device -I./http -I./process -I./protocols
 LIB            = @LEXLIB@ @LIBS@
-DEFINES                = [EMAIL PROTECTED]@
+DEFINES                = [EMAIL PROTECTED]@ -DSYSCONFDIR="\"@[EMAIL 
PROTECTED]""
 
 # ------------------------------------------------------------------- #
 
@@ -129,12 +129,12 @@ $(PROG) : $(GRAMMAR) $(OBJECTS) 
        $(CC) $(LINKFLAGS) $(OBJECTS) $(LIB) -o $(PROG) 
 
 clean::
-       $(RM) *~ \#* $(PROG) core $(OBJECTS) $(GRAMMAR) tokens.h
+       $(RM) *.orig *~ \#* $(PROG) core $(OBJECTS) $(GRAMMAR) tokens.h
 
 # remove configure files
 distclean:: clean
        $(RM) config.cache config.log config.status Makefile config.h \
-       autom4te*
+       autom4te* $(MAN_OBJS) doc/monit.html
 
 devclean:: clean distclean
        $(RM) configure config.h.in aclocal.m4
$NetBSD$

Pre-processor macro SYSCONFDIR will be defined on the command line.
SYSCONFDIR has to be a string enclosed by "" to enable string literal
concatenation.

--- file.c.orig 2007-01-03 10:31:01.000000000 +0100
+++ file.c
@@ -145,9 +145,9 @@ time_t File_getTimestamp(char *object, m
 
 /**
  * Search the system for the monit control file. Try first ~/.monitrc,
- * if that fails try /etc/monitrc, then /usr/local/etc/monitrc and
- * finally ./monitrc.  Exit the application if the control file was
- * not found.
+ * if that fails try /etc/monitrc, then SYSCONFDIR/monitrc (default:
+ * /usr/local/etc/monitrc) and finally ./monitrc.
+ * Exit the application if the control file was not found.
  * @return The location of monits control file (monitrc)
  */
 char *File_findControlFile() {
@@ -164,7 +164,7 @@ char *File_findControlFile() {
     return (rcfile);
   }
   memset(rcfile, 0, STRLEN);
-  snprintf(rcfile, STRLEN, "/usr/local/etc/%s", MONITRC);
+  snprintf(rcfile, STRLEN, SYSCONFDIR "/%s", MONITRC);
   if(File_exist(rcfile)) {
     return (rcfile);
   }
@@ -174,7 +174,7 @@ char *File_findControlFile() {
     return (rcfile);
   }
   LogError("%s: Cannot find the control file at "
-      "~/.%s, /etc/%s, /usr/local/etc/%s or at ./%s \n",
+      "~/.%s, /etc/%s, " SYSCONFDIR "/%s or at ./%s \n",
       prog, MONITRC, MONITRC, MONITRC, MONITRC);
   exit(1);
   
$NetBSD$

Substitute variables in monit.1.in and monit.html.in

--- configure.ac.orig   2007-03-16 12:04:45.000000000 +0100
+++ configure.ac
@@ -698,7 +698,7 @@ fi
 # ------------------------------------------------------------------------
 
 AC_CONFIG_HEADER([config.h])
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile monit.1 doc/monit.html])
 AC_OUTPUT
 
 echo ""
_______________________________________________
monit-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monit-dev

Reply via email to