From 57715745b593bdfb18f85d81c38c8fb0a9c0d832 Mon Sep 17 00:00:00 2001 From: Philipp Storz Date: Mon, 14 Sep 2015 15:17:35 +0200 Subject: [PATCH] Get OBS Build Info into Variables --- autoconf/bareos/os.m4 | 18 +++++++++++++++++- autoconf/configure.in | 9 +++++++++ src/filed/dir_cmd.c | 16 ++++++++++++++-- src/include/host.h.in | 5 +++++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/autoconf/bareos/os.m4 b/autoconf/bareos/os.m4 index 7c9d1cd8e27..48b6a59c627 100644 --- a/autoconf/bareos/os.m4 +++ b/autoconf/bareos/os.m4 @@ -50,7 +50,6 @@ else $1_FALSE= fi]) - AC_DEFUN([BA_CHECK_OPSYS], [ AC_CYGWIN @@ -336,3 +335,20 @@ else fi AC_MSG_RESULT(done) ]) + +AC_DEFUN([BA_CHECK_OBS_DISTNAME], [ +AC_MSG_CHECKING(for OBS OS Distribution) +if test "x$OBS_DISTRIBUTION" != "x" +then + echo "obsdistname set to $OBS_DISTRIBUTION" +else + if test -e /.build.log; then + OBS_PROJECT=`grep 'Building bareos for project' /.build.log | cut -d' ' -f10 | sed "s#'##g"` + OBS_DISTRIBUTION=`grep 'Building bareos for project' /.build.log | cut -d' ' -f12 | sed "s#'##g"` + OBS_ARCH=`grep 'Building bareos for project' /.build.log | cut -d' ' -f14 | sed "s#'##g"` + OBS_SRCMD5=`grep 'Building bareos for project' /.build.log | cut -d' ' -f16 | sed "s#'##g"` + AC_DEFINE(IS_BUILD_ON_OBS, 1, [Define to 1 if things are build using the Open Build Service (OBS)]) + fi +fi +AC_MSG_RESULT(done) +]) diff --git a/autoconf/configure.in b/autoconf/configure.in index d85ce4293a7..6ae9136b811 100644 --- a/autoconf/configure.in +++ b/autoconf/configure.in @@ -244,6 +244,15 @@ dnl Bareos OPSys Distribution determination (see aclocal.m4) dnl ---------------------------------------------------------- BA_CHECK_OPSYS_DISTNAME +dnl ----------------------------------------------------------- +dnl Bareos OPSys Distribution determination (see aclocal.m4) +dnl ---------------------------------------------------------- +BA_CHECK_OBS_DISTNAME +AC_SUBST(OBS_PROJECT) +AC_SUBST(OBS_DISTRIBUTION) +AC_SUBST(OBS_ARCH) +AC_SUBST(OBS_SRCMD5) + dnl -------------------------------------------------- dnl Suppport for gettext (translations) dnl By default, $datarootdir is ${prefix}/share diff --git a/src/filed/dir_cmd.c b/src/filed/dir_cmd.c index 113cb2978a3..c5283291fa7 100644 --- a/src/filed/dir_cmd.c +++ b/src/filed/dir_cmd.c @@ -227,7 +227,11 @@ static char OKstore[] = static char OKstoreend[] = "2000 OK storage end\n"; static char OKjob[] = +#if !defined(IS_BUILD_ON_OBS) "2000 OK Job %s (%s) %s,%s,%s"; +#else + "2000 OK Job %s (%s) %s,%s,%s,%s,%s"; +#endif static char OKsetdebugv0[] = "2000 OK setdebug=%d trace=%d hangup=%d tracefile=%s\n"; static char OKsetdebugv1[] = @@ -776,6 +780,7 @@ static bool job_cmd(JCR *jcr) BSOCK *dir = jcr->dir_bsock; POOL_MEM sd_auth_key(PM_MESSAGE); sd_auth_key.check_size(dir->msglen); + const char *os_version; if (sscanf(dir->msg, jobcmd, &jcr->JobId, jcr->Job, &jcr->VolSessionId, &jcr->VolSessionTime, @@ -790,10 +795,17 @@ static bool job_cmd(JCR *jcr) Mmsg(jcr->errmsg, "JobId=%d Job=%s", jcr->JobId, jcr->Job); new_plugins(jcr); /* instantiate plugins for this jcr */ generate_plugin_event(jcr, bEventJobStart, (void *)jcr->errmsg); + #ifdef HAVE_WIN32 - return dir->fsend(OKjob, VERSION, LSMDATE, win_os, DISTNAME, DISTVER); + os_version = win_os; +#else + os_version = HOST_OS; +#endif + +#if !defined(IS_BUILD_ON_OBS) + return dir->fsend(OKjob, VERSION, LSMDATE, os_version, DISTNAME, DISTVER); #else - return dir->fsend(OKjob, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER); + return dir->fsend(OKjob, VERSION, LSMDATE, os_version, DISTNAME, DISTVER, OBS_DISTRIBUTION, OBS_ARCH); #endif } diff --git a/src/include/host.h.in b/src/include/host.h.in index 492726e9fbc..3154323761a 100644 --- a/src/include/host.h.in +++ b/src/include/host.h.in @@ -33,3 +33,8 @@ #define SD_DEFAULT_PORT "@sd_port@" #define DIR_DEFAULT_PORT "@dir_port@" #define NDMP_DEFAULT_PORT "10000" + +#define OBS_PROJECT "@OBS_PROJECT@" +#define OBS_DISTRIBUTION "@OBS_DISTRIBUTION@" +#define OBS_ARCH "@OBS_ARCH@" +#define OBS_SRCMD5 "@OBS_SRCMD5@"