summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@1ts.org>2011-11-25 01:54:33 -0500
committerGravatar Karl Ramm <kcr@1ts.org>2011-11-25 01:55:12 -0500
commit5aec58b8494a6bc47727623dad2353ac7fc27299 (patch)
treeb3c01ac66ded9280e8bbcf28dd1c5087477b3503
parentf276622ace757977fec43633e43577350e0cf6fe (diff)
New version propagation to replace keyword substitution, part 1
-rw-r--r--Makefile.in14
-rwxr-xr-xdebian/rules2
-rwxr-xr-xget_vers.sh14
-rwxr-xr-xnew_vers.sh11
-rw-r--r--server/Makefile.in10
-rwxr-xr-xserver/new_vers.sh9
-rw-r--r--server/version.c29
-rw-r--r--zhm/Makefile.in1
-rw-r--r--zhm/zhm.c87
9 files changed, 88 insertions, 89 deletions
diff --git a/Makefile.in b/Makefile.in
index 94e9cac..3ad4444 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -21,6 +21,16 @@ SUBDIRS=lib clients server zhm zwgc
build:
$(MAKE) all
+h/zephyr_version.h: always
+ sh -x ${srcdir}/new_vers.sh $(top_srcdir)
+
+clean: clean_version
+
+clean_version:
+ $(RM) h/zephyr_version.h
+
+all: h/zephyr_version.h
+
all check clean:
for i in ${SUBDIRS}; do (cd $$i; ${MAKE} $@) || exit 1; done
@@ -47,5 +57,7 @@ install:
${INSTALL} -m 644 h/zephyr/zephyr_err.h ${DESTDIR}${includedir}/zephyr
for i in ${SUBDIRS}; do (cd $$i; ${MAKE} $@) || exit 1; done
-.PHONY: all check install clean
+always:
+
+.PHONY: all check install clean clean_version always
diff --git a/debian/rules b/debian/rules
index 140262a..42e0bb3 100755
--- a/debian/rules
+++ b/debian/rules
@@ -78,7 +78,7 @@ build-stamp:
# Add here commands to compile the package.
set -e; \
for dir in $(VARIETALS) ; do \
- $(MAKE) -C $$dir/lib all $(CHECK); $(MAKE) -C $$dir/server; \
+ $(MAKE) -C $$dir h/zephyr_version.h; $(MAKE) -C $$dir/lib all $(CHECK); $(MAKE) -C $$dir/server; \
done
$(MAKE) -C no-krb all $(CHECK)
diff --git a/get_vers.sh b/get_vers.sh
new file mode 100755
index 0000000..86de08c
--- /dev/null
+++ b/get_vers.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+top_srcdir=${1:-`pwd`}
+
+if test -f ${top_srcdir}/VERSION; then
+ VERSION=`cat ${top_srcdir}/VERSION`
+elif test -d ${top_srcdir}/.git; then
+ VERSION=`(cd $top_srcdir; git describe)`
+fi
+
+if test -z "$VERSION"; then
+ VERSION='FROM SPACE'
+
+echo $VERSION
diff --git a/new_vers.sh b/new_vers.sh
new file mode 100755
index 0000000..af0f403
--- /dev/null
+++ b/new_vers.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+top_srcdir=${1:-`pwd`}
+
+u=${USER-the_zephyr_builder}
+h=`hostname`
+t=`date`
+v=`sh ${top_srcdir}/get_vers.sh ${top_srcdir}`
+
+umask 002
+/bin/echo "#define ZEPHYR_VERSION_STRING \"${v} (${t}) ${u}@${h}\"" > h/zephyr_version.h
diff --git a/server/Makefile.in b/server/Makefile.in
index 319c390..7d244be 100644
--- a/server/Makefile.in
+++ b/server/Makefile.in
@@ -43,11 +43,6 @@ zsrv_err.h: zsrv_err.c
zsrv_err.c: zsrv_err.et
compile_et ${srcdir}/zsrv_err.et
-version.o: version.h
-
-version.h: always
- sh ${srcdir}/new_vers.sh
-
.c.o:
${CC} -c ${ALL_CFLAGS} $<
@@ -65,12 +60,11 @@ clean:
${LIBTOOL} --mode=clean rm -f zephyrd
rm -f ${OBJS} zsrv_err.[ch]
-always:
-
${OBJS}: zserver.h zsrv_err.h timer.h zsrv_conf.h zstring.h access.h acl.h
${OBJS}: ${top_srcdir}/h/internal.h ${top_srcdir}/h/sysdep.h
${OBJS}: ${BUILDTOP}/h/config.h ${BUILDTOP}/h/zephyr/zephyr.h
${OBJS}: ${BUILDTOP}/h/zephyr/zephyr_err.h
+version.o: ${BUILDTOP}/h/zephyr_version.h
-.PHONY: all check install clean always
+.PHONY: all check install clean
diff --git a/server/new_vers.sh b/server/new_vers.sh
deleted file mode 100755
index 035b3ff..0000000
--- a/server/new_vers.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-#
-
-u=${USER-the_zephyr_builder}
-h=`hostname`
-t=`date`
-
-umask 002
-/bin/echo "#define ZSERVER_VERSION_STRING \"(${t}) ${u}@${h}\"" >version.h
diff --git a/server/version.c b/server/version.c
index 3f4db17..e572bbf 100644
--- a/server/version.c
+++ b/server/version.c
@@ -15,19 +15,17 @@
#include <sys/utsname.h>
#include "zserver.h"
-#include "version.h"
+#include <zephyr_version.h>
-const char zephyr_version[] = "Zephyr system version 2.0";
+const char zephyr_version[] = "Zephyr system version" ZEPHYR_VERSION_STRING;
#ifdef DEBUG
-const char version[] = "Zephyr server (DEBUG) $Revision$";
+const char version[] = "Zephyr Server (DEBUG) " ZEPHYR_VERSION_STRING;
#else
-const char version[] = "Zephyr server $Revision$";
+const char version[] = "Zephyr Server " ZEPHYR_VERSION_STRING;
#endif
#if !defined (lint) && !defined (SABER)
-static const char rcsid_version_c[] =
- "$Id$";
static const char copyright[] =
"Copyright (c) 1987,1988,1989,1990 Massachusetts Institute of Technology.\n";
#endif
@@ -39,20 +37,15 @@ get_version(void)
struct utsname un;
if (vers_buf[0] == '\0') {
-#ifdef DEBUG
- sprintf(vers_buf,"Zephyr Server (DEBUG) $Revision$: %s",
- ZSERVER_VERSION_STRING);
-#else
- sprintf(vers_buf,"Zephyr Server $Revision$: %s",
- ZSERVER_VERSION_STRING);
-#endif /* DEBUG */
+ strcpy(vers_buf, version);
- (void) strcat(vers_buf, "/");
+ (void) strcat(vers_buf, "/");
- uname(&un);
- (void) strcat(vers_buf, un.machine);
- (void) strcat(vers_buf, "-");
- (void) strcat(vers_buf, un.sysname);
+ uname(&un);
+ (void) strcat(vers_buf, un.machine);
+ (void) strcat(vers_buf, "-");
+ (void) strcat(vers_buf, un.sysname);
}
+
return(vers_buf);
}
diff --git a/zhm/Makefile.in b/zhm/Makefile.in
index 47c5f1b..801575d 100644
--- a/zhm/Makefile.in
+++ b/zhm/Makefile.in
@@ -51,6 +51,7 @@ clean:
${OBJS}: zhm.h timer.h ${top_srcdir}/h/internal.h ${top_srcdir}/h/sysdep.h
${OBJS}: ${BUILDTOP}/h/config.h ${BUILDTOP}/h/zephyr/zephyr.h
${OBJS}: ${BUILDTOP}/h/zephyr/zephyr_err.h
+zhm.o: ${BUILDTOP}/h/zephyr_version.h
.PHONY: all check install clean
diff --git a/zhm/zhm.c b/zhm/zhm.c
index fb6e7c3..c2f1daf 100644
--- a/zhm/zhm.c
+++ b/zhm/zhm.c
@@ -11,6 +11,7 @@
*/
#include "zhm.h"
+#include <zephyr_version.h>
static const char rcsid_hm_c[] = "$Id$";
@@ -506,6 +507,19 @@ detach(void)
static char version[BUFSIZ];
+static char *
+stats_malloc(size_t size)
+{
+ char *p = malloc(size);
+
+ if (p == NULL) {
+ printf("Out of memory.\n"); /*XXXXXXXXXXX ? */
+ exit(-5);
+ }
+
+ return p;
+}
+
static void
send_stats(ZNotice_t *notice,
struct sockaddr_in *sin)
@@ -516,6 +530,7 @@ send_stats(ZNotice_t *notice,
char *list[20];
int len, i, nitems = 10;
unsigned long size;
+ extern int Zauthtype; /* XXX this may be changing in the future */
newnotice = *notice;
@@ -525,76 +540,44 @@ send_stats(ZNotice_t *notice,
}
newnotice.z_kind = HMACK;
- list[0] = (char *) malloc(NS_MAXDNAME);
- if (list[0] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+ list[0] = stats_malloc(NS_MAXDNAME);
strcpy(list[0], cur_serv);
- list[1] = (char *) malloc(64);
- if (list[1] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+
+ list[1] = stats_malloc(64);
sprintf(list[1], "%d", queue_len());
- list[2] = (char *) malloc(64);
- if (list[2] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+
+ list[2] = stats_malloc(64);
sprintf(list[2], "%d", nclt);
- list[3] = (char *) malloc(64);
- if (list[3] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+
+ list[3] = stats_malloc(64);
sprintf(list[3], "%d", nserv);
- list[4] = (char *) malloc(64);
- if (list[4] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+
+ list[4] = stats_malloc(64);
sprintf(list[4], "%d", nservchang);
- list[5] = (char *) malloc(64);
- if (list[5] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
- strncpy(list[5], rcsid_hm_c, 64);
- list[5][63] = '\0';
- list[6] = (char *) malloc(64);
- if (list[6] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+ list[5] = stats_malloc(256);
+ snprintf(list[5], 256, "%s (%d)", ZEPHYR_VERSION_STRING, Zauthtype);
+ list[5][255] = '\0';
+
+ list[6] = stats_malloc(64);
if (no_server)
sprintf(list[6], "yes");
else
sprintf(list[6], "no");
- list[7] = (char *) malloc(64);
- if (list[7] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+
+ list[7] = stats_malloc(64);
sprintf(list[7], "%ld", time((time_t *)0) - starttime);
+
#ifdef adjust_size
size = (unsigned long)sbrk(0);
adjust_size (size);
#else
size = -1;
#endif
- list[8] = (char *)malloc(64);
- if (list[8] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+ list[8] = stats_malloc(64);
sprintf(list[8], "%ld", size);
- list[9] = (char *)malloc(32);
- if (list[9] == NULL) {
- printf("Out of memory.\n");
- exit(-5);
- }
+
+ list[9] = stats_malloc(32);
strncpy(list[9], MACHINE_TYPE, 32);
list[9][31] = '\0';