- move cf-serverd to cfengine, required for bootstrap
- Parse /etc/os-release for product and version Add patch 0001-Check-etc-os-release-for-distribution-information.patch OBS-URL: https://build.opensuse.org/package/show/systemsmanagement/cfengine?expand=0&rev=86
This commit is contained in:
parent
ecb8b74fe3
commit
76f1d50926
188
0001-Check-etc-os-release-for-distribution-information.patch
Normal file
188
0001-Check-etc-os-release-for-distribution-information.patch
Normal file
@ -0,0 +1,188 @@
|
||||
From 5edafd6237e80109f5d1ca8410ff9772dbc41635 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= <kkaempf@suse.de>
|
||||
Date: Fri, 4 Apr 2014 21:20:48 +0200
|
||||
Subject: [PATCH] Check /etc/os-release for distribution information
|
||||
|
||||
Vendor specific <vendor>-release files are deprecated in favor of
|
||||
generic /etc/os-release files.
|
||||
|
||||
This patch extracts product and version information from /etc/os-release
|
||||
and creates respective classes.
|
||||
---
|
||||
libenv/sysinfo.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 146 insertions(+)
|
||||
|
||||
diff --git a/libenv/sysinfo.c b/libenv/sysinfo.c
|
||||
index 9c89c57cbf5e..901791220855 100644
|
||||
--- a/libenv/sysinfo.c
|
||||
+++ b/libenv/sysinfo.c
|
||||
@@ -114,6 +114,7 @@ static time_t GetBootTimeFromUptimeCommand(time_t); // Last resort
|
||||
void CalculateDomainName(const char *nodename, const char *dnsname, char *fqname, char *uqname, char *domain);
|
||||
|
||||
#ifdef __linux__
|
||||
+static int Linux_Os_Release(EvalContext *ctx);
|
||||
static int Linux_Fedora_Version(EvalContext *ctx);
|
||||
static int Linux_Redhat_Version(EvalContext *ctx);
|
||||
static void Linux_Oracle_VM_Server_Version(EvalContext *ctx);
|
||||
@@ -931,6 +932,11 @@ static void OSClasses(EvalContext *ctx)
|
||||
/* Mandrake/Mandriva, Fedora and Oracle VM Server supply /etc/redhat-release, so
|
||||
we test for those distributions first */
|
||||
|
||||
+ if (stat("/etc/os-release", &statbuf) != -1)
|
||||
+ {
|
||||
+ Linux_Os_Release(ctx);
|
||||
+ }
|
||||
+
|
||||
if (stat("/etc/mandriva-release", &statbuf) != -1)
|
||||
{
|
||||
Linux_Mandriva_Version(ctx);
|
||||
@@ -1213,6 +1219,146 @@ static void OSClasses(EvalContext *ctx)
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifdef __linux__
|
||||
+
|
||||
+static int Linux_Os_Release(EvalContext *ctx)
|
||||
+{
|
||||
+#define OS_REL_FILENAME "/etc/os-release"
|
||||
+
|
||||
+ char classbuf[CF_MAXVARSIZE];
|
||||
+
|
||||
+ Log(LOG_LEVEL_VERBOSE, "This appears to have an os-release.");
|
||||
+
|
||||
+ FILE *fp = fopen(OS_REL_FILENAME, "r");
|
||||
+ if (fp == NULL)
|
||||
+ {
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ char vbuf[CF_BUFSIZE], strid[CF_MAXVARSIZE], strversion[CF_MAXVARSIZE];
|
||||
+
|
||||
+ int major = -1, minor = -1;
|
||||
+ char *strmajor = NULL, *strminor = NULL;
|
||||
+ while (fgets(vbuf, sizeof(vbuf), fp) != NULL)
|
||||
+ {
|
||||
+ char *nptr, *vptr; /* name, value ptrs */
|
||||
+
|
||||
+ nptr = strrchr(vbuf, '=');
|
||||
+ if (nptr == NULL)
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
+ vptr = nptr;
|
||||
+ /* search left of '=' for non-blank char */
|
||||
+ while (isspace(*(nptr-1)))
|
||||
+ {
|
||||
+ nptr--;
|
||||
+ }
|
||||
+ *nptr = '\0';
|
||||
+ /* search right of '=' for non-blank char */
|
||||
+ do
|
||||
+ {
|
||||
+ vptr++;
|
||||
+ }
|
||||
+ while (isspace(*vptr));
|
||||
+ /* value could be enclosed in " */
|
||||
+ if (*vptr == '"')
|
||||
+ {
|
||||
+ char *eos;
|
||||
+ eos = ++vptr;
|
||||
+ /* find closing " and remove it */
|
||||
+ while (*eos && *eos != '"')
|
||||
+ {
|
||||
+ eos++;
|
||||
+ }
|
||||
+ *eos = '\0';
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ char *eos = vptr + strlen(vptr);
|
||||
+ while (eos > vptr && isspace(*(eos-1)))
|
||||
+ {
|
||||
+ eos--;
|
||||
+ }
|
||||
+ *eos = '\0';
|
||||
+ }
|
||||
+ Log(LOG_LEVEL_VERBOSE, "Discovered nptr >%s<, vptr >%s<", vbuf, vptr);
|
||||
+ if (strcmp(vbuf, "ID") == 0)
|
||||
+ {
|
||||
+ strlcpy(strid, vptr, sizeof(strid));
|
||||
+ Log(LOG_LEVEL_VERBOSE, "Discovered ID '%s'", strid);
|
||||
+ }
|
||||
+
|
||||
+ if (strcmp(vbuf, "VERSION_ID") == 0)
|
||||
+ {
|
||||
+ strlcpy(strversion, vptr, sizeof(strversion));
|
||||
+ switch (sscanf(strversion, "%d.%d", &major, &minor))
|
||||
+ {
|
||||
+ case 1:
|
||||
+ strmajor = strversion;
|
||||
+ minor = -1;
|
||||
+ strminor = NULL;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ strmajor = strversion;
|
||||
+ strminor = strchr(strversion, '.');
|
||||
+ *strminor++ = '\0';
|
||||
+ break;
|
||||
+ default:
|
||||
+ UnexpectedError("Non-numeric VERSION_ID in /etc/os-release");
|
||||
+ strmajor = strminor = NULL;
|
||||
+ break;
|
||||
+ }
|
||||
+ Log(LOG_LEVEL_VERBOSE, "Discovered VERSION_ID '%s', strmajor '%s', strminor '%s'", strversion, strmajor, strminor);
|
||||
+ }
|
||||
+ }
|
||||
+ if (ferror(fp))
|
||||
+ {
|
||||
+ UnexpectedError("Failed to read line from stream");
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ assert(feof(fp));
|
||||
+ }
|
||||
+
|
||||
+ fclose(fp);
|
||||
+
|
||||
+ EvalContextClassPutHard(ctx, strid, "inventory,attribute_name=none,source=agent");
|
||||
+ int i;
|
||||
+ char *cptr;
|
||||
+ for (i = 0; i < strlen(strid); i++)
|
||||
+ {
|
||||
+ classbuf[i] = toupper(strid[i]);
|
||||
+ }
|
||||
+ if (strcmp(classbuf, "OPENSUSE") == 0)
|
||||
+ {
|
||||
+ strcpy(classbuf, "openSUSE");
|
||||
+ }
|
||||
+ cptr = classbuf + i;
|
||||
+
|
||||
+ Log(LOG_LEVEL_VERBOSE, "Discovered %s version %s.%s", classbuf, strmajor, strminor?strminor:"");
|
||||
+ EvalContextClassPutHard(ctx, classbuf, "inventory,attribute_name=none,source=agent");
|
||||
+ if (strmajor != NULL)
|
||||
+ {
|
||||
+ *cptr++ = '_';
|
||||
+ strcpy(cptr, strmajor);
|
||||
+ cptr += strlen(strmajor);
|
||||
+ Log(LOG_LEVEL_VERBOSE, "Classbuf >%s<", classbuf);
|
||||
+ SetFlavour(ctx, classbuf);
|
||||
+ if (strminor != NULL)
|
||||
+ {
|
||||
+ *cptr++ = '_';
|
||||
+ strcpy(cptr, strminor);
|
||||
+ Log(LOG_LEVEL_VERBOSE, "Classbuf >%s<", classbuf);
|
||||
+ EvalContextClassPutHard(ctx, classbuf, "inventory,attribute_name=none,source=agent");
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ Log(LOG_LEVEL_VERBOSE, "Could not find a numeric OS release in %s", OS_REL_FILENAME);
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void Linux_Oracle_VM_Server_Version(EvalContext *ctx)
|
||||
{
|
||||
char relstring[CF_MAXVARSIZE];
|
||||
--
|
||||
1.8.4.5
|
||||
|
@ -1,3 +1,14 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Apr 4 19:36:47 UTC 2014 - kkaempf@suse.com
|
||||
|
||||
- move cf-serverd to cfengine, required for bootstrap
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Apr 4 19:30:04 UTC 2014 - kkaempf@suse.com
|
||||
|
||||
- Parse /etc/os-release for product and version
|
||||
Add patch 0001-Check-etc-os-release-for-distribution-information.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Apr 3 13:10:56 UTC 2014 - kkaempf@suse.com
|
||||
|
||||
|
@ -75,6 +75,9 @@ Patch2: remove-am_subst_notmake.patch
|
||||
# kkaempf@suse.de
|
||||
Patch3: drop-revision.patch
|
||||
|
||||
# parse /etc/os-release for product and version information, kkaempf@suse.de
|
||||
Patch4: 0001-Check-etc-os-release-for-distribution-information.patch
|
||||
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
BuildRequires: bison
|
||||
BuildRequires: db-devel
|
||||
@ -199,6 +202,7 @@ This package contains the files of the cfengine server.
|
||||
%patch2 -p1
|
||||
%endif
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
|
||||
##### rpmlint
|
||||
#### wrong-file-end-of-line-encoding
|
||||
@ -260,7 +264,7 @@ rm -rf %{buildroot}/%{_docdir}/%{name}/examples
|
||||
%{__install} -d %{buildroot}/{usr/sbin,%{workdir}/{bin,inputs,reports}}
|
||||
|
||||
# create dirs needed for better organizing dirs and files
|
||||
%{__install} -d %{buildroot}/%{basedir}/{backup,failsafe,config}
|
||||
%{__install} -d %{buildroot}/%{basedir}/{backup,failsafe,config,plugins}
|
||||
#%%{__install} -d %{buildroot}/%%{basedir}/config/{development,production}
|
||||
|
||||
# install cron file
|
||||
@ -287,7 +291,7 @@ sed -i\
|
||||
|
||||
# create symlinks for sbin_PROGRAMS
|
||||
# because: cf-promises needs to be installed in /var/cfengine/work/bin for pre-validation of full configuration
|
||||
for i in cf-agent cf-execd cf-key cf-monitord cf-promises cf-runagent cf-serverd; do
|
||||
for i in cf-agent cf-execd cf-key cf-monitord cf-promises cf-runagent cf-serverd cf-upgrade; do
|
||||
%{__ln_s} -f ../../..%{_sbindir}/${i} %{buildroot}%{workdir}/bin/${i}
|
||||
done
|
||||
|
||||
@ -316,52 +320,53 @@ install -D -m 644 %{S:1} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/SuSEfirewall2.d
|
||||
# systemd
|
||||
%if 0%{?suse_version} >= 1210
|
||||
|
||||
####################################################################
|
||||
# Systemd
|
||||
####################################################################
|
||||
|
||||
%pre
|
||||
%service_add_pre cf-execd.service cf-monitord.service
|
||||
%service_add_pre cf-execd.service cf-monitord.service cf-serverd.service
|
||||
|
||||
%post
|
||||
%service_add_post cf-execd.service cf-monitord.service
|
||||
%service_add_post cf-execd.service cf-monitord.service cf-serverd.service
|
||||
%if 0%{?suse_version} > 1010
|
||||
%install_info --name=%{name} --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz
|
||||
%endif
|
||||
/sbin/ldconfig
|
||||
if [ $1 -lt 2 ]; then
|
||||
# first install, generate key pair
|
||||
cf-key
|
||||
fi
|
||||
|
||||
%preun
|
||||
%service_del_preun cf-execd.service cf-monitord.service
|
||||
%service_del_preun cf-execd.service cf-monitord.service cf-serverd.service
|
||||
|
||||
%postun
|
||||
%service_del_postun cf-execd.service cf-monitord.service
|
||||
%service_del_postun cf-execd.service cf-monitord.service cf-serverd.service
|
||||
%if 0%{?suse_version} > 1010
|
||||
%install_info_delete --name=%{name} --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz
|
||||
%endif
|
||||
# clean up inputs cache dir
|
||||
rm -rf %{basedir}/inputs/*
|
||||
if [ $1 -eq 0 ]; then
|
||||
# clean up inputs cache dir on removal
|
||||
rm -rf %{basedir}/inputs/*
|
||||
fi
|
||||
/sbin/ldconfig
|
||||
|
||||
%pre server
|
||||
%service_add_pre cf-serverd.service
|
||||
|
||||
%post server
|
||||
%service_add_post cf-serverd.service
|
||||
|
||||
%preun server
|
||||
%service_del_preun cf-serverd.service
|
||||
|
||||
%postun server
|
||||
%service_del_postun cf-serverd.service
|
||||
|
||||
%else # !systemd
|
||||
|
||||
####################################################################
|
||||
# Non-systemd
|
||||
####################################################################
|
||||
|
||||
%preun
|
||||
%if 0%{?suse_version}
|
||||
%stop_on_removal cf-monitord
|
||||
%stop_on_removal cf-execd
|
||||
%stop_on_removal cf-serverd
|
||||
%else
|
||||
/etc/init.d/cf-execd stop
|
||||
/etc/init.d/cf-monitord stop
|
||||
/etc/init.d/cf-serverd stop
|
||||
%endif
|
||||
|
||||
%post
|
||||
@ -374,13 +379,13 @@ rm -rf %{basedir}/inputs/*
|
||||
%if 0%{?suse_version} > 1010
|
||||
%install_info_delete --name=%{name} --info-dir=%{_infodir} %{_infodir}/cf3-reference.info.gz
|
||||
%insserv_cleanup
|
||||
for i in execd monitord; do
|
||||
for i in execd monitord serverd; do
|
||||
%restart_on_update cf-${i}
|
||||
done
|
||||
%else
|
||||
# Update ?
|
||||
if [ ${1:-0} -eq 1 ]; then
|
||||
for i in execd monitord; do
|
||||
for i in execd monitord serverd; do
|
||||
/etc/init.d/cf-${i} restart
|
||||
done
|
||||
else
|
||||
@ -389,25 +394,6 @@ rm -rf %{basedir}/inputs/*
|
||||
%endif
|
||||
/sbin/ldconfig
|
||||
|
||||
%preun server
|
||||
%if 0%{?suse_version}
|
||||
%stop_on_removal cf-serverd
|
||||
%else
|
||||
/etc/init.d/cf-serverd stop
|
||||
%endif
|
||||
|
||||
%postun server
|
||||
%if 0%{?suse_version}
|
||||
%restart_on_update cf-serverd
|
||||
%else
|
||||
# Update ?
|
||||
if [ ${1:-0} -eq 1 ]; then
|
||||
/etc/init.d/cf-serverd restart
|
||||
else
|
||||
:
|
||||
fi
|
||||
%endif
|
||||
|
||||
%endif # !systemd
|
||||
|
||||
%post -n %{libsoname} -p /sbin/ldconfig
|
||||
@ -422,21 +408,26 @@ rm -rf %{basedir}/inputs/*
|
||||
%{_sbindir}/cf-key
|
||||
%{_sbindir}/cf-monitord
|
||||
%{_sbindir}/cf-promises
|
||||
%{_sbindir}/cf-runagent
|
||||
%{_sbindir}/cf-serverd
|
||||
%{_sbindir}/cf-upgrade
|
||||
%{_sbindir}/rpmvercmp
|
||||
%if 0%{?suse_version} >= 1210
|
||||
%_unitdir/cf-execd.service
|
||||
%_unitdir/cf-monitord.service
|
||||
%_unitdir/cf-serverd.service
|
||||
%else
|
||||
%exclude /etc/init.d/cf-serverd
|
||||
%config %attr(0755,root,root) /etc/init.d/*
|
||||
%{_sbindir}/rccf-execd
|
||||
%{_sbindir}/rccf-monitord
|
||||
%{_sbindir}/rccf-serverd
|
||||
%endif
|
||||
%{_mandir}/man8/cf-serverd.8.*
|
||||
%if 0%{?suse_version} > 1010
|
||||
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/cfengine
|
||||
%endif
|
||||
|
||||
%{_mandir}/man8/*
|
||||
%exclude %{_mandir}/man8/cf-serverd.8.*
|
||||
%exclude %{_mandir}/man8/cf-runagent.8.*
|
||||
%dir %{basedir}
|
||||
%exclude %{basedir}/backup
|
||||
%exclude %{basedir}/config
|
||||
@ -444,7 +435,7 @@ rm -rf %{basedir}/inputs/*
|
||||
|
||||
%dir %{workdir}
|
||||
%{workdir}/*
|
||||
%exclude %{workdir}/bin/cf-serverd
|
||||
%exclude %{workdir}/bin/cf-runagent
|
||||
|
||||
%config(noreplace) /etc/cron.d/%{name}
|
||||
|
||||
@ -469,17 +460,8 @@ rm -rf %{basedir}/inputs/*
|
||||
%defattr(-,root,root)
|
||||
%{basedir}/backup
|
||||
%{basedir}/config
|
||||
%{_sbindir}/cf-serverd
|
||||
%{workdir}/bin/cf-serverd
|
||||
%if 0%{?suse_version} >= 1210
|
||||
%_unitdir/cf-serverd.service
|
||||
%else
|
||||
/etc/init.d/cf-serverd
|
||||
%{_sbindir}/rccf-serverd
|
||||
%endif
|
||||
%{_mandir}/man8/cf-serverd.8.*
|
||||
%if 0%{?suse_version} > 1010
|
||||
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/cfengine
|
||||
%endif
|
||||
%{_sbindir}/cf-runagent
|
||||
%{workdir}/bin/cf-runagent
|
||||
%{_mandir}/man8/cf-runagent.8.*
|
||||
|
||||
%changelog
|
||||
|
Loading…
Reference in New Issue
Block a user