[iwhd] build: work around jansson-2.1's API change
by Jim Meyering
commit 6bbc52f0a7ad647e35209b91b6ec13e876883622
Author: Jim Meyering <meyering(a)redhat.com>
Date: Mon Jul 4 09:47:31 2011 +0200
build: work around jansson-2.1's API change
* configure.ac: Add a compile-test to detect whether we need to
insert the new "flags" argument in each json_loads and json_load_file
argument list.
* setup.c (parse_config, auto_config): Use JANSSON_LOAD_FLAG.
* dc-rhev-image.c (main): Likewise.
* NEWS (Infrastructure): Mention this.
Reported by Chris Lalancette in http://bugzilla.redhat.com/718249
NEWS | 5 +++++
configure.ac | 12 ++++++++++++
dc-rhev-image.c | 2 +-
setup.c | 4 ++--
4 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/NEWS b/NEWS
index ecd8847..2476201 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,11 @@ iwhd NEWS -*- outline -*-
On Fedora systems, /etc/iwhd/conf.js is not overwritten anymore when
upgrading the package (added %config(noreplace)).
+** Infrastructure
+
+ Adapt to jansson-1.2's new, incompatible changed API, so we can build
+ both with it and the older API.
+
* Noteworthy changes in release 0.96 (2011-06-15) [stable]
diff --git a/configure.ac b/configure.ac
index 8945f7c..61199c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,18 @@ AC_CHECK_HEADER([mongo/client/dbclient.h], ,
[#undef VERSION])
AC_LANG_POP
+# Starting in jansson 2.1, file-loading functions require an
+# additional "flags" argument. Test for this.
+AC_CACHE_CHECK([whether json_load_file takes 3 arguments],
+ [iw_cv_func_jansson_flag],
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ #include <jansson.h>
+ json_t *f (void) { return json_load_file ("file", 0, NULL); }]])],
+ [iw_cv_func_jansson_flag=0,],
+ [iw_cv_func_jansson_flag=])])
+AC_DEFINE_UNQUOTED([JANSSON_LOAD_FLAG], $iw_cv_func_jansson_flag,
+ [Define to "0," if json_load_file and json_loads require a flags arguments.])
+
# from http://www.gnu.org/software/autoconf-archive/
AX_BOOST_BASE
AX_BOOST_SYSTEM
diff --git a/dc-rhev-image.c b/dc-rhev-image.c
index 7599fb8..c768445 100644
--- a/dc-rhev-image.c
+++ b/dc-rhev-image.c
@@ -2329,7 +2329,7 @@ int main(int argc, char **argv, char **envp)
memset(&cfg, 0, sizeof(struct config));
- jcfg = json_load_file(cfgname, &err);
+ jcfg = json_load_file(cfgname, JANSSON_LOAD_FLAG &err);
if (!jcfg) {
fprintf(stderr, "ERROR configuration JSON error %s:%d: %s\n",
cfgname, err.line, err.text);
diff --git a/setup.c b/setup.c
index caeb430..af2bb22 100644
--- a/setup.c
+++ b/setup.c
@@ -583,7 +583,7 @@ parse_config (char *cfg_file)
return NULL;
}
- config = json_load_file(cfg_file,&err);
+ config = json_load_file(cfg_file, JANSSON_LOAD_FLAG &err);
if (!config) {
error(0,0,_("JSON error on line %d: %s"),err.line,err.text);
return NULL;
@@ -614,7 +614,7 @@ auto_config(void)
return NULL;
}
- config = json_loads(auto_json,&err);
+ config = json_loads(auto_json, JANSSON_LOAD_FLAG &err);
if (!config) {
error(0, 0, _("JSON error on line %d: %s"), err.line, err.text);
return NULL;
12 years, 10 months
[iwhd] mark conf.js as a config file to avoid accidental overwrite
by Jim Meyering
commit 97e6d6010b335d17a5a11942d870be0abfedf058
Author: Pete Zaitcev <zaitcev(a)redhat.com>
Date: Fri Jul 1 16:20:39 2011 -0600
mark conf.js as a config file to avoid accidental overwrite
Folks who did "rpm -U iwhd-0.96.x86_64.rpm" or "yum update iwhd" received
an unpleasant surprise when their local configurations were blown away.
Mark the configuration so it's not overwritten.
NEWS | 5 +++++
iwhd.spec.in | 2 +-
2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index fc1cb1b..ecd8847 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ iwhd NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Bug fixes
+
+ On Fedora systems, /etc/iwhd/conf.js is not overwritten anymore when
+ upgrading the package (added %config(noreplace)).
+
* Noteworthy changes in release 0.96 (2011-06-15) [stable]
diff --git a/iwhd.spec.in b/iwhd.spec.in
index 5d39ffc..950879b 100644
--- a/iwhd.spec.in
+++ b/iwhd.spec.in
@@ -63,7 +63,7 @@ rm -rf %{buildroot}
%{_bindir}/dc-vmware-image
%{_mandir}/man8/iwhd.8*
%{_sysconfdir}/rc.d/init.d/iwhd
-%{_sysconfdir}/iwhd/conf.js
+%config(noreplace) %{_sysconfdir}/iwhd/conf.js
%{_localstatedir}/lib/iwhd
%changelog
12 years, 10 months