Bug 205868

Summary: databases/opentsdb: Fix wrong path searching for logging.xml
Product: Ports & Packages Reporter: Davide D'Amico <davide.damico>
Component: Individual Port(s)Assignee: Martin Wilke <miwi>
Status: Closed FIXED    
Severity: Affects Only Me CC: miwi, xmj, xmj
Priority: --- Keywords: easy, patch, patch-ready
Version: LatestFlags: xmj: maintainer-feedback+
amdmi3: merge-quarterly+
Hardware: Any   
OS: Any   
See Also: https://github.com/OpenTSDB/opentsdb/pull/670
Attachments:
Description Flags
Patch to database/opentsdb to fix sysconfig/sysconf
koobs: maintainer-approval+
Updated my patch using prefix instead of sysconfdir
none
Updated my patch using prefix instead of sysconfdir
none
replace sysconfigdir with configdir in files/patch-Makefile.in none

Description Davide D'Amico 2016-01-04 09:22:29 UTC
After having installed opentsdb I saw that /var/log/opentsdb/tsdb.log is logging with DEBUG verbosity while in /usr/local/etc/opentsdb/logging.xml I specified an INFO level.
Looking in /usr/local/bin/tsdb I saw that confidir is set to /etc/opentsdb.
Looking further I found an error in Makefile.in with a typo between sysconfdir (the option specified in configure) and sysconfigdir (the var used to specify a config directory).
I'd like to report this to the mainstream software repository but I didn't find any Makefile.in in their github repo (and I'm not in autotools stuff).

The patch is trivial:
# diff -uh Makefile.orig Makefile
--- Makefile.orig       2016-01-04 04:16:51.446052000 -0500
+++ Makefile    2016-01-04 04:16:47.303694000 -0500
@@ -46,6 +46,7 @@
 post-patch:
        ${REINPLACE_CMD} -i "" -e "s|python|${PYTHON_CMD}|" ${WRKSRC}/build-aux/gen_build_data.sh
        #${REINPLACE_CMD} -i "" -e "s|%%PREFIX%%|${PREFIX}|" ${WRKSRC}/Makefile.in
+       ${REINPLACE_CMD} -i "" -e "s|sysconfigdir|sysconfdir|" ${WRKSRC}/Makefile.in
        ${REINPLACE_CMD} -i "" -e "s|%%PREFIX%%|${PREFIX}|" ${WRKSRC}/src/utils/Config.java
        ${REINPLACE_CMD} -i "" -e "s|tsd.http.staticroot =|tsd.http.staticroot = ${DATADIR}/static|; s|tsd.http.cachedir =|tsd.http.cachedir = /tmp/opentsdb|; s|tsd.network.port =|tsd.network.port = 4242|;" ${WRKSRC}/src/opentsdb.conf

#
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-04 10:54:01 UTC
Thanks for your submission David :)

Could you include your patch as an attachment please?

Also, regarding the upstream sources, the Makefile.in is generated (by automake) from Makefile.am [1] files :)

You should find that you need there

[1] https://github.com/OpenTSDB/opentsdb/blob/master/Makefile.am

While I'm here,

Correct category/portname and CC maintainer
Comment 2 Davide D'Amico 2016-01-04 10:59:06 UTC
Created attachment 165042 [details]
Patch to database/opentsdb to fix sysconfig/sysconf
Comment 3 Davide D'Amico 2016-01-04 11:01:49 UTC
I am seeing I specified 'logging.xml' as the file opentsdb uses for logging configuration options; the right filename is 'logback.xml': the patch is still valid.
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-04 11:07:34 UTC
Thank you Davide.

If you create an upstream Issue/PR, please link it here in "See Also"
Comment 5 Davide D'Amico 2016-01-04 11:09:39 UTC
Thanks, I'll do in 8h (now busy doing other things).
Comment 6 Johannes Jost Meixner freebsd_committer freebsd_triage 2016-01-04 12:09:56 UTC
LGTM, but make sure to submit a patch to upstream.
Chris Larsen is usually very responsive, and this patch would probably apply to both 2.1.x as well as the current release candidate for 2.2.x.
Comment 7 Davide D'Amico 2016-01-04 14:59:16 UTC
Created attachment 165058 [details]
Updated my patch using prefix instead of sysconfdir
Comment 8 Davide D'Amico 2016-01-04 15:00:14 UTC
Created attachment 165059 [details]
Updated my patch using prefix instead of sysconfdir
Comment 9 Davide D'Amico 2016-01-04 15:01:30 UTC
Comment on attachment 165058 [details]
Updated my patch using prefix instead of sysconfdir

>--- Makefile.orig       2016-01-04 04:16:51.446052000 -0500
>+++ Makefile    2016-01-04 09:55:55.342634000 -0500
>@@ -46,6 +46,7 @@
> post-patch:
>        ${REINPLACE_CMD} -i "" -e "s|python|${PYTHON_CMD}|" ${WRKSRC}/build-aux/gen_build_data.sh
>        #${REINPLACE_CMD} -i "" -e "s|%%PREFIX%%|${PREFIX}|" ${WRKSRC}/Makefile.in
>+       ${REINPLACE_CMD} -i "" -e "s|sysconfigdir|prefix|" ${WRKSRC}/Makefile.in
>        ${REINPLACE_CMD} -i "" -e "s|%%PREFIX%%|${PREFIX}|" ${WRKSRC}/src/utils/Config.java
>        ${REINPLACE_CMD} -i "" -e "s|tsd.http.staticroot =|tsd.http.staticroot = ${DATADIR}/static|; s|tsd.http.cachedir =|tsd.http.cachedir = /tmp/opentsdb|; s|tsd.network.port =|tsd.network.port = 4242|;" ${WRKSRC}/src/opentsdb.conf
>
Comment 10 Davide D'Amico 2016-01-04 15:09:34 UTC
I had to change sysconfdir with prefix because sysconfdir is already including a etc/.
I don't know if this can be solved via upstream because changing sysconfdir (as I proposed at first) with prefix could break something on other linux systems (I guess).
Comment 11 Johannes Jost Meixner freebsd_committer freebsd_triage 2016-01-04 15:14:41 UTC
Good catch.

Actually, files/patch-Makefile.in should probably include something like:

-       script=tsdb; pkgdatadir='$(pkgdatadir)'; configdir='$(sysconfigdir)/etc/opentsdb'; \
-       script=tsdb; pkgdatadir='$(pkgdatadir)'; configdir='$(sysconfdir)/opentsdb'; \


Given that sysconfdir should always resolve to either /etc/, /usr/local/etc or something along those lines:

https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
Comment 12 Davide D'Amico 2016-01-04 15:20:03 UTC
Sounds not only good, but also better :)
Comment 13 Johannes Jost Meixner freebsd_committer freebsd_triage 2016-01-04 15:35:22 UTC
Indeed, I'm currently running the patch through poudriere, let's see what happens..
Comment 14 Johannes Jost Meixner freebsd_committer freebsd_triage 2016-01-04 22:59:34 UTC
Created attachment 165084 [details]
replace sysconfigdir with configdir in files/patch-Makefile.in

Patch attached fixes the typo introduced upstream in an earlier patch, replacing sysconfigdir with sysconfdir,
and now sets 

configdir='/usr/local/etc/opentsdb'

within /usr/local/bin/tsdb,
so that the directory containing logback.xml is in CLASSPATH and that the file can actually be read by `tsdb`.
Comment 15 commit-hook freebsd_committer freebsd_triage 2016-01-06 08:50:30 UTC
A commit references this bug:

Author: miwi
Date: Wed Jan  6 08:50:24 UTC 2016
New revision: 405340
URL: https://svnweb.freebsd.org/changeset/ports/405340

Log:
  - Fix wrong path searching for logback.xml
  - While here remove unused sed line
  - Bump PORTREVISION

  PR:		205868
  Submitted by:	Davide D'Amico (based on)
  Approved by:	Johannes Jost Meixner (maintainer)

Changes:
  head/databases/opentsdb/Makefile
  head/databases/opentsdb/files/patch-Makefile.in
Comment 16 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-06 09:05:01 UTC
Needs to be merged to quarterly, or set flag to - with comment
Comment 17 commit-hook freebsd_committer freebsd_triage 2016-01-06 15:56:10 UTC
A commit references this bug:

Author: miwi
Date: Wed Jan  6 15:55:41 UTC 2016
New revision: 405363
URL: https://svnweb.freebsd.org/changeset/ports/405363

Log:
  MFH: r405340

  - Fix wrong path searching for logback.xml
  - While here remove unused sed line
  - Bump PORTREVISION

  PR:		205868
  Submitted by:	Davide D'Amico (based on)
  Approved by:	Johannes Jost Meixner (maintainer)
  Approved by:    portmgr blanket

Changes:
_U  branches/2016Q1/
  branches/2016Q1/databases/opentsdb/Makefile
  branches/2016Q1/databases/opentsdb/files/patch-Makefile.in