mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] determining compiler/libc/target capabilities for monit
@ 2014-01-20 16:17 Alexander Dahl
  2014-01-20 19:30 ` [ptxdist] [PATCH] monit: add new package Robert Schwebel
  2014-01-20 19:37 ` [ptxdist] determining compiler/libc/target capabilities for monit Robert Schwebel
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Dahl @ 2014-01-20 16:17 UTC (permalink / raw)
  To: PTXdist Developer Mailinglist

Hei hei, 

I'm working on a package for monit [1]. While building fine in a usual
environment things are a little different with cross-compiling it with
ptxdist. I'm using ptxdist 2014.01.0 and OSELAS Toolchain 2012.12.1
building for armv5te. In the prepare stage aka when ./configure is
called for this autotool using project I get:

checking sys/filio.h presence... configure: error: cross-compiling:
please set 'libmonit_cv_setjmp_available=yes|no'
no
checking for sys/filio.h... no
checking setjmp is available... configure: error: ./configure failed for
libmonit

By setting those variable (and another) I could successfully make the
prepare stage run. This was introduced by monit in release 5.4 to
support cross compilation [2] and it circumvents the test program
compiled in ./configure call using AC_LANG_PROGRAM.

I'm not happy with this. The change seems like a workaround because
obviously you can not execute those small programms on the target in
this stage. Would it be possible to automatically get this information
instead of the developer having to set it? It took me quite a while to
verify which settings are correct for my toolchain/libc/target
combination and I do not want to release a package where a developer
would have to set those options.

So anyone having experience with autotools and cross-compiling, who can
suggest a technical solution? If yes I would try to get this change
upstream then.

Greets
Alex

[1] http://mmonit.com/monit/
[2] http://osdir.com/ml/monit-general/2012-05/msg00009.html

-- 
»With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie)
*** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601  D1D5 8FBA 7744 CC87 10D0 ***

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ptxdist] [PATCH] monit: add new package
  2014-01-20 16:17 [ptxdist] determining compiler/libc/target capabilities for monit Alexander Dahl
@ 2014-01-20 19:30 ` Robert Schwebel
  2014-01-21  8:51   ` Alexander Dahl
  2014-01-20 19:37 ` [ptxdist] determining compiler/libc/target capabilities for monit Robert Schwebel
  1 sibling, 1 reply; 7+ messages in thread
From: Robert Schwebel @ 2014-01-20 19:30 UTC (permalink / raw)
  To: ptxdist; +Cc: Robert Schwebel

This adds the system monitoring daemon 'monit'.

Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
---
 rules/monit.in   | 20 ++++++++++++++++
 rules/monit.make | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 rules/monit.in
 create mode 100644 rules/monit.make

diff --git a/rules/monit.in b/rules/monit.in
new file mode 100644
index 0000000..281ab21
--- /dev/null
+++ b/rules/monit.in
@@ -0,0 +1,20 @@
+## SECTION=networking
+
+menuconfig MONIT
+	tristate
+	prompt "monit                         "
+	select OPENSSL if MONIT_SSL
+	help
+	  Monit is a tool for managing and monitoring processes, files,
+	  programs, directories and filesystems.
+
+if MONIT
+
+config MONIT_SSL
+
+	bool
+	prompt "SSL support"
+	help
+	  Enable Secure Socket Layer support, using OpenSSL.
+
+endif
diff --git a/rules/monit.make b/rules/monit.make
new file mode 100644
index 0000000..3430b0e
--- /dev/null
+++ b/rules/monit.make
@@ -0,0 +1,70 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2014 by Robert Schwebel <r.schwebel@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+PACKAGES-$(PTXCONF_MONIT) += monit
+
+#
+# Paths and names
+#
+MONIT_VERSION	:= 5.6
+MONIT_MD5	:= 19dfc1ce8512e832134d06eedd96ba50
+MONIT		:= monit-$(MONIT_VERSION)
+MONIT_SUFFIX	:= tar.gz
+MONIT_URL	:= http://mmonit.com/monit/dist/$(MONIT).$(MONIT_SUFFIX)
+MONIT_SOURCE	:= $(SRCDIR)/$(MONIT).$(MONIT_SUFFIX)
+MONIT_DIR	:= $(BUILDDIR)/$(MONIT)
+MONIT_LICENSE	:= AGPLv3 with OpenSSL exception
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+MONIT_CONF_ENV	:= $(CROSS_ENV) \
+	libmonit_cv_setjmp_available=yes \
+	libmonit_cv_vsnprintf_c99_conformant=yes
+
+#
+# autoconf
+#
+MONIT_CONF_TOOL	:= autoconf
+MONIT_CONF_OPT	:= $(CROSS_AUTOCONF_USR) \
+	--enable-optimized \
+	--without-pam \
+	--enable-largefile
+
+ifdef PTXCONF_MONIT_SSL
+MONIT_CONF_OPT += --with-ssl-dir=$(SYSROOT)/usr
+else
+MONIT_CONF_OPT += --without-ssl
+endif
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/monit.targetinstall:
+	@$(call targetinfo)
+
+	@$(call install_init, monit)
+	@$(call install_fixup, monit,PRIORITY,optional)
+	@$(call install_fixup, monit,SECTION,base)
+	@$(call install_fixup, monit,AUTHOR,"Robert Schwebel <r.schwebel@pengutronix.de>")
+	@$(call install_fixup, monit,DESCRIPTION,missing)
+
+	@$(call install_copy, monit, 0, 0, 0755, /usr/bin/monit)
+
+	@$(call install_finish, monit)
+
+	@$(call touch)
+
+# vim: syntax=make
-- 
1.8.5.2


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ptxdist] determining compiler/libc/target capabilities for monit
  2014-01-20 16:17 [ptxdist] determining compiler/libc/target capabilities for monit Alexander Dahl
  2014-01-20 19:30 ` [ptxdist] [PATCH] monit: add new package Robert Schwebel
@ 2014-01-20 19:37 ` Robert Schwebel
  1 sibling, 0 replies; 7+ messages in thread
From: Robert Schwebel @ 2014-01-20 19:37 UTC (permalink / raw)
  To: ptxdist

Hi Alexander,

On Mon, Jan 20, 2014 at 05:17:20PM +0100, Alexander Dahl wrote:
> I'm working on a package for monit [1]. While building fine in a usual
> environment things are a little different with cross-compiling it with
> ptxdist. I'm using ptxdist 2014.01.0 and OSELAS Toolchain 2012.12.1
> building for armv5te. In the prepare stage aka when ./configure is
> called for this autotool using project I get:
> 
> checking sys/filio.h presence... configure: error: cross-compiling:
> please set 'libmonit_cv_setjmp_available=yes|no'
> no
> checking for sys/filio.h... no
> checking setjmp is available... configure: error: ./configure failed for
> libmonit

This is caused by a patch submitted by the buildroot people. They do
the right thing here: if you can't determine something at runtime and
there is no way to know it beforehand, make it overwritable by a cached
variable on configure time. This way a build system, which might know
about the result of the check for a certain architecture, can just set
the right things.

> By setting those variable (and another) I could successfully make the
> prepare stage run. This was introduced by monit in release 5.4 to
> support cross compilation [2] and it circumvents the test program
> compiled in ./configure call using AC_LANG_PROGRAM.

Correct.
 
> I'm not happy with this. The change seems like a workaround because
> obviously you can not execute those small programms on the target in
> this stage.

You can't, because in a cross build system, you can't run anything on
the target. However, the intention is not to run something, but to find
out if the setjmp mechanism is available. According to my understanding,
it is always available on glibc based systems.

> Would it be possible to automatically get this information
> instead of the developer having to set it? It took me quite a while to
> verify which settings are correct for my toolchain/libc/target
> combination and I do not want to release a package where a developer
> would have to set those options.

It is in the rules, see my patch I've just sent.
 
> So anyone having experience with autotools and cross-compiling, who can
> suggest a technical solution? If yes I would try to get this change
> upstream then.

I don't think that an upstream patch is necessary. Setting ac_cv_
variables is common practise, grep rules/* for other examples.

The only question is if setting the variables unconditionally is the
right thing to do. If you like, you can do more research about that.

Or just wait if someone complains and sends a patch :-)

rsc
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ptxdist] [PATCH] monit: add new package
  2014-01-20 19:30 ` [ptxdist] [PATCH] monit: add new package Robert Schwebel
@ 2014-01-21  8:51   ` Alexander Dahl
  2014-01-21  9:31     ` Michael Olbrich
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Dahl @ 2014-01-21  8:51 UTC (permalink / raw)
  To: ptxdist

Hei hei, 

because I did almost exactly the same yesterday, I just comment on this
instead of sending my own patch.

Am 2014-01-20 20:30, schrieb Robert Schwebel:
> This adds the system monitoring daemon 'monit'.
> 
> Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
> ---
>  rules/monit.in   | 20 ++++++++++++++++
>  rules/monit.make | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 90 insertions(+)
>  create mode 100644 rules/monit.in
>  create mode 100644 rules/monit.make
> 
> diff --git a/rules/monit.in b/rules/monit.in
> new file mode 100644
> index 0000000..281ab21
> --- /dev/null
> +++ b/rules/monit.in
> @@ -0,0 +1,20 @@
> +## SECTION=networking
> +
> +menuconfig MONIT
> +	tristate
> +	prompt "monit                         "
> +	select OPENSSL if MONIT_SSL
> +	help
> +	  Monit is a tool for managing and monitoring processes, files,
> +	  programs, directories and filesystems.
> +
> +if MONIT
> +
> +config MONIT_SSL
> +
> +	bool
> +	prompt "SSL support"
> +	help
> +	  Enable Secure Socket Layer support, using OpenSSL.
> +
> +endif
> diff --git a/rules/monit.make b/rules/monit.make
> new file mode 100644
> index 0000000..3430b0e
> --- /dev/null
> +++ b/rules/monit.make
> @@ -0,0 +1,70 @@
> +# -*-makefile-*-
> +#
> +# Copyright (C) 2014 by Robert Schwebel <r.schwebel@pengutronix.de>
> +#
> +# See CREDITS for details about who has contributed to this project.
> +#
> +# For further information about the PTXdist project and license conditions
> +# see the README file.
> +#
> +
> +#
> +# We provide this package
> +#
> +PACKAGES-$(PTXCONF_MONIT) += monit
> +
> +#
> +# Paths and names
> +#
> +MONIT_VERSION	:= 5.6
> +MONIT_MD5	:= 19dfc1ce8512e832134d06eedd96ba50
> +MONIT		:= monit-$(MONIT_VERSION)
> +MONIT_SUFFIX	:= tar.gz
> +MONIT_URL	:= http://mmonit.com/monit/dist/$(MONIT).$(MONIT_SUFFIX)
> +MONIT_SOURCE	:= $(SRCDIR)/$(MONIT).$(MONIT_SUFFIX)
> +MONIT_DIR	:= $(BUILDDIR)/$(MONIT)
> +MONIT_LICENSE	:= AGPLv3 with OpenSSL exception
> +
> +# ----------------------------------------------------------------------------
> +# Prepare
> +# ----------------------------------------------------------------------------
> +
> +MONIT_CONF_ENV	:= $(CROSS_ENV) \
> +	libmonit_cv_setjmp_available=yes \
> +	libmonit_cv_vsnprintf_c99_conformant=yes
> +
> +#
> +# autoconf
> +#
> +MONIT_CONF_TOOL	:= autoconf
> +MONIT_CONF_OPT	:= $(CROSS_AUTOCONF_USR) \
> +	--enable-optimized \

This seems to always set -O3. Shouldn't this be set by the build system
which can distinguish between Debug and Release builds?

> +	--without-pam \
> +	--enable-largefile
> +
> +ifdef PTXCONF_MONIT_SSL
> +MONIT_CONF_OPT += --with-ssl-dir=$(SYSROOT)/usr
> +else
> +MONIT_CONF_OPT += --without-ssl
> +endif

What about just this?

     --$(call ptx/wwo, PTXCONF_MONIT_SSL)-ssl

Monit had no problems finding OpenSSL on my machine, so I didn't set
ssl-dir.

> +
> +# ----------------------------------------------------------------------------
> +# Target-Install
> +# ----------------------------------------------------------------------------
> +
> +$(STATEDIR)/monit.targetinstall:
> +	@$(call targetinfo)
> +
> +	@$(call install_init, monit)
> +	@$(call install_fixup, monit,PRIORITY,optional)
> +	@$(call install_fixup, monit,SECTION,base)
> +	@$(call install_fixup, monit,AUTHOR,"Robert Schwebel
> <r.schwebel@pengutronix.de>")
> +	@$(call install_fixup, monit,DESCRIPTION,missing)
> +
> +	@$(call install_copy, monit, 0, 0, 0755, /usr/bin/monit)
> +
> +	@$(call install_finish, monit)
> +
> +	@$(call touch)
> +
> +# vim: syntax=make

This could be improved:

# vim: ft=make noet

I'm not entirely sure about filetype vs. syntax, I assumed filetype may
not only set syntax, but a check may be useful. However noexpandtab is
useful, because someone may have set expandtab in his general personal
settings and this would lead to a corrupt Makefile which has to be
indented with tabs.

> -- 
> 1.8.5.2

Greets
Alex

-- 
»With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie)
*** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601  D1D5 8FBA 7744 CC87 10D0 ***

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ptxdist] [PATCH] monit: add new package
  2014-01-21  8:51   ` Alexander Dahl
@ 2014-01-21  9:31     ` Michael Olbrich
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Olbrich @ 2014-01-21  9:31 UTC (permalink / raw)
  To: ptxdist

On Tue, Jan 21, 2014 at 09:51:01AM +0100, Alexander Dahl wrote:
> Hei hei, 
> 
> because I did almost exactly the same yesterday, I just comment on this
> instead of sending my own patch.
> 
> Am 2014-01-20 20:30, schrieb Robert Schwebel:
> > This adds the system monitoring daemon 'monit'.
> > 
> > Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
> > ---
> >  rules/monit.in   | 20 ++++++++++++++++
> >  rules/monit.make | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 90 insertions(+)
> >  create mode 100644 rules/monit.in
> >  create mode 100644 rules/monit.make
> > 
> > diff --git a/rules/monit.in b/rules/monit.in
> > new file mode 100644
> > index 0000000..281ab21
> > --- /dev/null
> > +++ b/rules/monit.in
> > @@ -0,0 +1,20 @@
> > +## SECTION=networking
> > +
> > +menuconfig MONIT
> > +	tristate
> > +	prompt "monit                         "
> > +	select OPENSSL if MONIT_SSL
> > +	help
> > +	  Monit is a tool for managing and monitoring processes, files,
> > +	  programs, directories and filesystems.
> > +
> > +if MONIT
> > +
> > +config MONIT_SSL
> > +
> > +	bool
> > +	prompt "SSL support"
> > +	help
> > +	  Enable Secure Socket Layer support, using OpenSSL.
> > +
> > +endif
> > diff --git a/rules/monit.make b/rules/monit.make
> > new file mode 100644
> > index 0000000..3430b0e
> > --- /dev/null
> > +++ b/rules/monit.make
> > @@ -0,0 +1,70 @@
> > +# -*-makefile-*-
> > +#
> > +# Copyright (C) 2014 by Robert Schwebel <r.schwebel@pengutronix.de>
> > +#
> > +# See CREDITS for details about who has contributed to this project.
> > +#
> > +# For further information about the PTXdist project and license conditions
> > +# see the README file.
> > +#
> > +
> > +#
> > +# We provide this package
> > +#
> > +PACKAGES-$(PTXCONF_MONIT) += monit
> > +
> > +#
> > +# Paths and names
> > +#
> > +MONIT_VERSION	:= 5.6
> > +MONIT_MD5	:= 19dfc1ce8512e832134d06eedd96ba50
> > +MONIT		:= monit-$(MONIT_VERSION)
> > +MONIT_SUFFIX	:= tar.gz
> > +MONIT_URL	:= http://mmonit.com/monit/dist/$(MONIT).$(MONIT_SUFFIX)
> > +MONIT_SOURCE	:= $(SRCDIR)/$(MONIT).$(MONIT_SUFFIX)
> > +MONIT_DIR	:= $(BUILDDIR)/$(MONIT)
> > +MONIT_LICENSE	:= AGPLv3 with OpenSSL exception
> > +
> > +# ----------------------------------------------------------------------------
> > +# Prepare
> > +# ----------------------------------------------------------------------------
> > +
> > +MONIT_CONF_ENV	:= $(CROSS_ENV) \
> > +	libmonit_cv_setjmp_available=yes \
> > +	libmonit_cv_vsnprintf_c99_conformant=yes
> > +
> > +#
> > +# autoconf
> > +#
> > +MONIT_CONF_TOOL	:= autoconf
> > +MONIT_CONF_OPT	:= \

break

	$(CROSS_AUTOCONF_USR) \
> > +	--enable-optimized \
> 
> This seems to always set -O3. Shouldn't this be set by the build system
> which can distinguish between Debug and Release builds?

Well ptxdist really only does release builds.

> > +	--without-pam \
> > +	--enable-largefile
> > +
> > +ifdef PTXCONF_MONIT_SSL
> > +MONIT_CONF_OPT += --with-ssl-dir=$(SYSROOT)/usr
> > +else
> > +MONIT_CONF_OPT += --without-ssl
> > +endif
> 
> What about just this?
> 
>      --$(call ptx/wwo, PTXCONF_MONIT_SSL)-ssl
> 
> Monit had no problems finding OpenSSL on my machine, so I didn't set
> ssl-dir.

	--$(call ptx/wwo, PTXCONF_MONIT_SSL)-ssl \
	--with-ssl-dir=$(SYSROOT)/usr

is correct. The dir is needed but is ignored for "--without-ssl". It
probably works for you because you have openssl in /usr.

mol

> 
> > +
> > +# ----------------------------------------------------------------------------
> > +# Target-Install
> > +# ----------------------------------------------------------------------------
> > +
> > +$(STATEDIR)/monit.targetinstall:
> > +	@$(call targetinfo)
> > +
> > +	@$(call install_init, monit)
> > +	@$(call install_fixup, monit,PRIORITY,optional)
> > +	@$(call install_fixup, monit,SECTION,base)
> > +	@$(call install_fixup, monit,AUTHOR,"Robert Schwebel
> > <r.schwebel@pengutronix.de>")
> > +	@$(call install_fixup, monit,DESCRIPTION,missing)
> > +
> > +	@$(call install_copy, monit, 0, 0, 0755, /usr/bin/monit)
> > +
> > +	@$(call install_finish, monit)
> > +
> > +	@$(call touch)
> > +
> > +# vim: syntax=make
> 
> This could be improved:
> 
> # vim: ft=make noet
> 
> I'm not entirely sure about filetype vs. syntax, I assumed filetype may
> not only set syntax, but a check may be useful. However noexpandtab is
> useful, because someone may have set expandtab in his general personal
> settings and this would lead to a corrupt Makefile which has to be
> indented with tabs.
> 
> > -- 
> > 1.8.5.2
> 
> Greets
> Alex
> 
> -- 
> »With the first link, the chain is forged. The first speech censured,
> the first thought forbidden, the first freedom denied, chains us all
> irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie)
> *** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601  D1D5 8FBA 7744 CC87 10D0 ***
> 
> -- 
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ptxdist] [PATCH] monit: add new package
  2014-01-27 10:27 [ptxdist] [PATCH] monit: add new package Alexander Dahl
@ 2014-01-27 12:55 ` Alexander Dahl
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Dahl @ 2014-01-27 12:55 UTC (permalink / raw)
  To: ptxdist

Hei hei, 

I forgot to include the target install rule for the config file. I'll
fix this and resubmit the patch.

Greets
Alex

Am 2014-01-27 11:27, schrieb Alexander Dahl:
> +# ----------------------------------------------------------------------------
> +# Target-Install
> +# ----------------------------------------------------------------------------
> +
> +$(STATEDIR)/monit.targetinstall:
> +	@$(call targetinfo)
> +
> +	@$(call install_init, monit)
> +	@$(call install_fixup, monit,PRIORITY,optional)
> +	@$(call install_fixup, monit,SECTION,base)
> +	@$(call install_fixup, monit,AUTHOR,"Alexander Dahl <post@lespocky.de>")
> +	@$(call install_fixup, monit,DESCRIPTION,missing)
> +
> +	@$(call install_copy, monit, 0, 0, 0755, -, /usr/bin/monit)
> +	@$(call install_copy, monit, 0, 0, 0755, /var/lib/monit)
> +
> +ifdef PTXCONF_INITMETHOD_BBINIT
> +ifdef PTXCONF_MONIT_STARTSCRIPT
> +	@$(call install_alternative, monit, 0, 0, 0755, /etc/init.d/monit)
> +ifneq ($(call remove_quotes,$(PTXCONF_MONIT_BBINIT_LINK)),)
> +	@$(call install_link, monit, ../init.d/monit, \
> +		/etc/rc.d/$(PTXCONF_MONIT_BBINIT_LINK))
> +endif
> +endif
> +endif
> +
> +	@$(call install_finish, monit)
> +
> +	@$(call touch)
> +
> +# vim: ft=make noet

-- 
»With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie)
*** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601  D1D5 8FBA 7744 CC87 10D0 ***

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ptxdist] [PATCH] monit: add new package
@ 2014-01-27 10:27 Alexander Dahl
  2014-01-27 12:55 ` Alexander Dahl
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Dahl @ 2014-01-27 10:27 UTC (permalink / raw)
  To: ptxdist

This adds the system monitoring daemon 'monit'. An init script for
busybox init method is included and a generic config file to start with.

Signed-off-by: Alexander Dahl <post@lespocky.de>
---
 generic/etc/init.d/monit |  167 ++++++++++++++++++++++++++++++++++++++++++++++
 generic/etc/monitrc      |    8 +++
 rules/monit-bbinit.in    |    9 +++
 rules/monit.in           |   26 ++++++++
 rules/monit.make         |   74 ++++++++++++++++++++
 5 files changed, 284 insertions(+)
 create mode 100644 generic/etc/init.d/monit
 create mode 100644 generic/etc/monitrc
 create mode 100644 rules/monit-bbinit.in
 create mode 100644 rules/monit.in
 create mode 100644 rules/monit.make

diff --git a/generic/etc/init.d/monit b/generic/etc/init.d/monit
new file mode 100644
index 0000000..96ec86a
--- /dev/null
+++ b/generic/etc/init.d/monit
@@ -0,0 +1,167 @@
+#!/bin/sh
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="daemon monitor"
+NAME=monit
+DAEMON=/usr/bin/$NAME
+CONFIG="/etc/monitrc"
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+MONIT_OPTS=
+
+# exit if binary is missing
+[ -x "$DAEMON" ] || exit 0
+
+monit_check_config() {
+    # Check for existing config file
+    if [ ! -f "$CONFIG" ]
+    then
+        echo " missing config, please edit $CONFIG."
+        exit 1
+    fi
+
+    # Check for emtpy config
+    if [ $(grep -cv '^\s*$\|^\s*#' $CONFIG) -eq 0 ]
+    then
+        echo " empty config, please edit $CONFIG."
+        exit 2
+    fi
+
+    # Let monit check syntax
+    if ! $DAEMON -c $CONFIG -t >/dev/null 2>&1
+    then
+        echo " syntax error in $CONFIG"
+        exit 3
+    fi
+}
+
+is_running() {
+    start-stop-daemon -K --quiet --test --exec $DAEMON \
+        --pidfile $PIDFILE
+}
+
+do_start() {
+    is_running && return 1
+    start-stop-daemon -S --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+        $MONIT_OPTS || return 2
+}
+
+do_stop() {
+    is_running || return 0
+    start-stop-daemon -K --quiet --pidfile $PIDFILE --exec $DAEMON
+    RETVAL="$?"
+
+    # wait up to 30 seconds until daemon stopped
+    for i in $(seq 30)
+    do
+        sleep 1
+        echo -n '.'
+        if ! is_running
+        then
+            break
+        fi
+    done
+
+    # see if it's still running
+    if is_running
+    then
+        start-stop-daemon -K --quiet --signal KILL --pidfile $PIDFILE \
+            --exec $DAEMON
+
+        for i in $(seq 5)
+        do
+            sleep 1
+            echo -n '.'
+            if ! is_running
+            then
+                break
+            fi
+        done
+
+        if is_running
+        then
+            return 2
+        fi
+    fi
+
+    rm -f $PIDFILE
+    return "$RETVAL"
+}
+
+do_reload() {
+    # monit has an own call for this, no need to send SIGHUP
+    $DAEMON reload
+}
+
+monit_check_perms() {
+  # Check the permission on configfile.
+  # The permission must not have more than -rwx------ (0700) permissions.
+
+  # Skip checking, fix perms instead.
+  /bin/chmod go-rwx $CONFIG
+}
+
+monit_checks() {
+  # Check for emtpy configfile
+  monit_check_config
+  # Check permissions of configfile
+  monit_check_perms
+}
+
+case "$1" in
+    start)
+        monit_checks
+        do_start
+        case "$?" in
+            0)  ;;
+            1)  echo "$DESC already running." ;;
+            *)  echo "Starting $DESC failed." ;;
+        esac
+        ;;
+    stop)
+        echo -n "Stopping $DESC ."
+        do_stop
+        case "$?" in
+            0|1)    echo " Done." ;;
+            *)      echo " Failed." ;;
+        esac
+        ;;
+    reload)
+        do_reload
+        ;;
+    restart|force-reload)
+        echo -n "Restarting $DESC .."
+        do_stop
+        case "$?" in
+            0|1)
+                echo ""
+                do_start
+                case "$?" in
+                    0)  ;;
+                    1)  echo " Failed." ;; # Old process still running
+                    *)  echo " Failed." ;; # Failed to start
+                esac
+                ;;
+            *)
+                echo " Failed." # Failed to stop
+                ;;
+        esac
+        ;;
+    status)
+        if is_running
+        then
+            echo "$NAME is running with PID $(cat $PIDFILE) ..."
+        else
+            echo "$NAME is not running"
+        fi
+        ;;
+    syntax)
+        $DAEMON -c $CONFIG -t
+        ;;
+    *)
+        echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
+        exit 3
+        ;;
+esac
+
+:
diff --git a/generic/etc/monitrc b/generic/etc/monitrc
new file mode 100644
index 0000000..810b9b4
--- /dev/null
+++ b/generic/etc/monitrc
@@ -0,0 +1,8 @@
+set daemon 120
+set logfile /var/log/monit.log
+set idfile /var/lib/monit/id
+set pidfile /var/run/monit.pid
+set statefile /var/lib/monit/state
+set eventqueue
+	basedir /var/monit/events
+	slots 100
diff --git a/rules/monit-bbinit.in b/rules/monit-bbinit.in
new file mode 100644
index 0000000..94bf2e9
--- /dev/null
+++ b/rules/monit-bbinit.in
@@ -0,0 +1,9 @@
+## SECTION=initmethod_bbinit
+
+config MONIT_BBINIT_LINK
+	string
+	depends on MONIT_STARTSCRIPT
+	prompt "monit"
+	default "S98monit"
+
+# vim: ft=kconfig noet tw=72
diff --git a/rules/monit.in b/rules/monit.in
new file mode 100644
index 0000000..8d20d22
--- /dev/null
+++ b/rules/monit.in
@@ -0,0 +1,26 @@
+## SECTION=shell_and_console
+
+menuconfig MONIT
+	tristate
+	prompt "monit                         "
+	select OPENSSL if MONIT_SSL
+	select BUSYBOX_START_STOP_DAEMON if MONIT_STARTSCRIPT
+	select BUSYBOX_FEATURE_START_STOP_DAEMON_LONG_OPTIONS if MONIT_STARTSCRIPT
+	help
+	  Utility for managing and monitoring of processes, programs, files,
+	  directories, and filesystems.
+
+if MONIT
+
+config MONIT_SSL
+	bool
+	prompt "SSL support"
+
+config MONIT_STARTSCRIPT
+	bool
+	prompt "install /etc/init.d/monit"
+	default y
+
+endif
+
+# vim: ft=kconfig noet tw=72
diff --git a/rules/monit.make b/rules/monit.make
new file mode 100644
index 0000000..7dbe4f0
--- /dev/null
+++ b/rules/monit.make
@@ -0,0 +1,74 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2014 by Alexander Dahl <post@lespocky.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+PACKAGES-$(PTXCONF_MONIT) += monit
+
+#
+# Paths and names
+#
+MONIT_VERSION	:= 5.6
+MONIT_MD5		:= 19dfc1ce8512e832134d06eedd96ba50
+MONIT			:= monit-$(MONIT_VERSION)
+MONIT_SUFFIX	:= tar.gz
+MONIT_URL		:= http://mmonit.com/monit/dist/$(MONIT).$(MONIT_SUFFIX)
+MONIT_SOURCE	:= $(SRCDIR)/$(MONIT).$(MONIT_SUFFIX)
+MONIT_DIR		:= $(BUILDDIR)/$(MONIT)
+MONIT_LICENSE	:= AGPLv3
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+MONIT_CONF_ENV	:= $(CROSS_ENV) \
+	libmonit_cv_setjmp_available=yes \
+	libmonit_cv_vsnprintf_c99_conformant=yes
+
+MONIT_CONF_TOOL	:= autoconf
+MONIT_CONF_OPT	:= $(CROSS_AUTOCONF_USR) \
+	--without-pam \
+	--enable-optimized \
+	--enable-largefile \
+	--$(call ptx/wwo, PTXCONF_MONIT_SSL)-ssl \
+	--with-ssl-dir=$(SYSROOT)/usr
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/monit.targetinstall:
+	@$(call targetinfo)
+
+	@$(call install_init, monit)
+	@$(call install_fixup, monit,PRIORITY,optional)
+	@$(call install_fixup, monit,SECTION,base)
+	@$(call install_fixup, monit,AUTHOR,"Alexander Dahl <post@lespocky.de>")
+	@$(call install_fixup, monit,DESCRIPTION,missing)
+
+	@$(call install_copy, monit, 0, 0, 0755, -, /usr/bin/monit)
+	@$(call install_copy, monit, 0, 0, 0755, /var/lib/monit)
+
+ifdef PTXCONF_INITMETHOD_BBINIT
+ifdef PTXCONF_MONIT_STARTSCRIPT
+	@$(call install_alternative, monit, 0, 0, 0755, /etc/init.d/monit)
+ifneq ($(call remove_quotes,$(PTXCONF_MONIT_BBINIT_LINK)),)
+	@$(call install_link, monit, ../init.d/monit, \
+		/etc/rc.d/$(PTXCONF_MONIT_BBINIT_LINK))
+endif
+endif
+endif
+
+	@$(call install_finish, monit)
+
+	@$(call touch)
+
+# vim: ft=make noet
-- 
1.7.10.4


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-01-27 12:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-20 16:17 [ptxdist] determining compiler/libc/target capabilities for monit Alexander Dahl
2014-01-20 19:30 ` [ptxdist] [PATCH] monit: add new package Robert Schwebel
2014-01-21  8:51   ` Alexander Dahl
2014-01-21  9:31     ` Michael Olbrich
2014-01-20 19:37 ` [ptxdist] determining compiler/libc/target capabilities for monit Robert Schwebel
2014-01-27 10:27 [ptxdist] [PATCH] monit: add new package Alexander Dahl
2014-01-27 12:55 ` Alexander Dahl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox