{"action":"created","issue":{"url":"https://api.github.com/repos/cfengine/core/issues/2319","labels_url":"https://api.github.com/repos/cfengine/core/issues/2319/labels{/name}","comments_url":"https://api.github.com/repos/cfengine/core/issues/2319/comments","events_url":"https://api.github.com/repos/cfengine/core/issues/2319/events","html_url":"https://github.com/cfengine/core/pull/2319","id":106741812,"number":2319,"title":"jq integration","user":{"login":"tzz","id":67764,"avatar_url":"https://avatars.githubusercontent.com/u/67764?v=3","gravatar_id":"","url":"https://api.github.com/users/tzz","html_url":"https://github.com/tzz","followers_url":"https://api.github.com/users/tzz/followers","following_url":"https://api.github.com/users/tzz/following{/other_user}","gists_url":"https://api.github.com/users/tzz/gists{/gist_id}","starred_url":"https://api.github.com/users/tzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzz/subscriptions","organizations_url":"https://api.github.com/users/tzz/orgs","repos_url":"https://api.github.com/users/tzz/repos","events_url":"https://api.github.com/users/tzz/events{/privacy}","received_events_url":"https://api.github.com/users/tzz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-16T10:09:17Z","updated_at":"2015-09-17T17:22:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cfengine/core/pulls/2319","html_url":"https://github.com/cfengine/core/pull/2319","diff_url":"https://github.com/cfengine/core/pull/2319.diff","patch_url":"https://github.com/cfengine/core/pull/2319.patch"},"body":"see https://dev.cfengine.com/issues/7435\r\n\r\nDO NOT MERGE\r\n\r\nCurrent state: I followed https://www.gnu.org/software/automake/manual/html_node/Subpackages.html#Subpackages and added the `3rdparty/jq-1.5` subdirectory.  When I run `configure` it's also built!\r\n\r\nI built a glue `jq_glue.h` header that has all the function definitions we'll need for the integration.  I also added the JQ la library to libpromises.  A minimal change to `evalfunction.c` calls two `jv_*` functions that live in the JQ libraries.\r\n\r\nHere's a minimal example to test things:\r\n\r\n```\r\nbundle agent main\r\n{\r\n  vars:\r\n      \"items\" data => '[ \"x\", \"y\" ]';\r\n      \"items2\" data => mapdata(\"jq\", \"nothing\", items);\r\n\r\n  reports:\r\n      \"we have item $(items)\";\r\n      \"we have item2 $(items2)\";\r\n}\r\n```\r\n\r\nThe build process fails at the installation step:\r\n\r\n```\r\nlibtool: install: warning: relinking `libpromises.la'\r\nlibtool: install: (cd /home/tzz/source/cfengine/core/libpromises; /bin/bash /home/tzz/source/cfengine/core/libtool  --silent --tag CC --mode=relink gcc -pthread -g -O2 -g -Wall -Wno-pointer-sign -Werror=implicit-function-declaration -Wunused-parameter -O2 -DNDEBUG -version-info 3:6:0 -no-undefined -R/lib -o libpromises.la -rpath /var/cfengine/lib cf3parse.lo cf3lex.lo acl_tools_posix.lo actuator.lo addr_lib.lo assoc.lo audit.lo attributes.lo bootstrap.lo cf3globals.lo chflags.lo class.lo constants.lo conversion.lo crypto.lo dbm_api.lo dbm_migration.lo dbm_migration_lastseen.lo dbm_lmdb.lo dbm_quick.lo dbm_tokyocab.lo enterprise_stubs.lo enterprise_extension.lo eval_context.lo evalfunction.lo exec_tools.lo expand.lo extensions.lo files_copy.lo files_hashes.lo files_interfaces.lo files_lib.lo files_names.lo fncall.lo generic_agent.lo granules.lo instrumentation.lo item_lib.lo iteration.lo keyring.lo known_dirs.lo lastseen.lo loading.lo locks.lo logic_expressions.lo matching.lo math_eval.lo mod_access.lo mod_common.lo mod_databases.lo mod_environ.lo mod_exec.lo mod_files.lo mod_measurement.lo mod_methods.lo mod_outputs.lo mod_packages.lo mod_process.lo mod_report.lo mod_services.lo mod_storage.lo mod_knowledge.lo mod_users.lo modes.lo mutex.lo ornaments.lo policy.lo parser.lo patches.lo pipes.lo processes_select.lo promises.lo rlist.lo scope.lo shared_lib.lo signals.lo sort.lo storage_tools.lo string_expressions.lo syntax.lo syslog_client.lo systype.lo timeout.lo unix.lo var_expressions.lo vars.lo variable.lo verify_classes.lo verify_reports.lo verify_vars.lo process_unix.lo pipes_unix.lo process_linux.lo ../libutils/libutils.la ../libcfnet/libcfnet.la ../3rdparty/jq-1.5/libjq.la ../libenv/libenv.la -llmdb -lpcre -lssl -lcrypto -lacl -lyaml )\r\n/usr/bin/ld: cannot find -ljq\r\ncollect2: error: ld returned 1 exit status\r\nlibtool: install: error: relink `libpromises.la' with the above command before installing it\r\nMakefile:713: recipe for target 'install-projlibLTLIBRARIES' failed\r\n```\r\nAlso, `jq` itself is getting installed in the bindir.  I think that's OK."},"comment":{"url":"https://api.github.com/repos/cfengine/core/issues/comments/141158057","html_url":"https://github.com/cfengine/core/pull/2319#issuecomment-141158057","issue_url":"https://api.github.com/repos/cfengine/core/issues/2319","id":141158057,"user":{"login":"jimis","id":3584514,"avatar_url":"https://avatars.githubusercontent.com/u/3584514?v=3","gravatar_id":"","url":"https://api.github.com/users/jimis","html_url":"https://github.com/jimis","followers_url":"https://api.github.com/users/jimis/followers","following_url":"https://api.github.com/users/jimis/following{/other_user}","gists_url":"https://api.github.com/users/jimis/gists{/gist_id}","starred_url":"https://api.github.com/users/jimis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimis/subscriptions","organizations_url":"https://api.github.com/users/jimis/orgs","repos_url":"https://api.github.com/users/jimis/repos","events_url":"https://api.github.com/users/jimis/events{/privacy}","received_events_url":"https://api.github.com/users/jimis/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T17:22:27Z","updated_at":"2015-09-17T17:22:27Z","body":"Argh, linking statically is not an easy job. Both CFEngine and jq are using yacc and lex it seems:\r\n```\r\n3rdparty/jq-1.5/parser.y:131: multiple definition of `yyerror'\r\njq-1.5/parser.y:145: multiple definition of `yylex'\r\njq-1.5/parser.c:2066: multiple definition of `yyparse'\r\n```\r\n\r\nIn this case I don't think it's worth making them cooperate.\r\n\r\nIf I abandon this path, the only other way is to link dynamically to `libjq.so`, which means that we should also install `libjq.so`, which also means that we should prefer system's `libjq.so` if available, as I commented on my other comment.\r\n"}}