Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Aug 2021 11:16:54 +0200
From:      Ole <ole@free.de>
To:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Patching a port (monit) with EXTRA_PATCHES and poudriere - fails
Message-ID:  <20210820111654.48c52853.ole@free.de>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hello,

there is a Bug in the current version of the monit port.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257941

It was already fixed in the repo.
https://bitbucket.org/tildeslash/monit/commits/47e042610940624e492119a895098dfbd459b8df

I am building my packages with poudriere. And since I need the package
strongly, i thought it would be good to learn how to patch a port with
poudriere.

I took my information from this sites:
https://dan.langille.org/2014/06/10/freebsd-custom-port-patches-when-using-poudriere/
https://docs.freebsd.org/en/books/porters-handbook/slow-porting/

1. Create the patch:
diff -u src/validate.c.orig src/validate.c /usr/ports/distfiles/local-patches/monit.patch

2. Edit make.conf:
.if ${.CURDIR:M*/sysutils/monit}
EXTRA_PATCHES+= /distfiles/local-patches/monit.patch
.endif

3. remove old package
find /poudriere/base/data/packages/freebsd:12:x86:64-HEAD/ -name monit\* -delete

4. run poudriere again.

===>  Patching for monit-5.28.1
===>  Applying extra patch /distfiles/local-patches/monit.patch
Ignoring previously applied (or reversed) patch.
2 out of 2 hunks ignored--saving rejects to src/validate.c.rej
===>  FAILED Applying extra
patch /distfiles/local-patches/monit.patch *** Error code 1

Stop.
make: stopped in /usr/ports/sysutils/monit


sadly it fails applying the patch. Any idea why?
The patch is below.

Ole



--- src/validate.c.orig	2021-08-20 10:58:45.165650000 +0200
+++ src/validate.c	2021-08-20 10:58:48.797744000 +0200
@@ -1518,17 +1518,21 @@
         int errors = 0;
         /* Check the services */
         for (Service_T s = servicelist; s && ! interrupt(); s = s->next) {
-                // FIXME: The Service_Program must collect the exit value from last run, even if the program start should be skipped in this cycle => let check program always run the test (to be refactored with new scheduler)
-                if (! _doScheduledAction(s) && s->monitor && (s->type == Service_Program || ! _checkSkip(s))) {
-                        _checkTimeout(s); // Can disable monitoring => need to check s->monitor again
-                        if (s->monitor) {
-                                State_Type state = s->check(s);
-                                if (state != State_Init && s->monitor != Monitor_Not) // The monitoring can be disabled by some matching rule in s->check so we have to check again before setting to Monitor_Yes
-                                        s->monitor = Monitor_Yes;
-                                if (state == State_Failed)
-                                        errors++;
-                                if (s->type != Service_Program)
-                                        gettimeofday(&s->collected, NULL);
+                if (! _doScheduledAction(s) && s->monitor) {
+                        bool skip = _checkSkip(s);
+                        // FIXME: The Service_Program must collect the exit value from last run, even if the program start should be skipped in this cycle => let check program always run the test (to be refactored with new scheduler)
+                        if (! skip || s->type == Service_Program) {
+                                _checkTimeout(s); // Can disable monitoring => need to check s->monitor again
+                                if (s->monitor) {
+                                        State_Type state = s->check(s);
+                                        if (state != State_Init && s->monitor != Monitor_Not) // The monitoring can be disabled by some matching rule in s->check so we have to check again before setting to Monitor_Yes
+                                                s->monitor = Monitor_Yes;
+                                        if (state == State_Failed)
+                                                errors++;
+                                        //FIXME: the Service_Program is executed each cycle to collect exit value ... record the last data collection timestamp only on the real non-skip cycle
+                                        if (! skip)
+                                                gettimeofday(&s->collected, NULL);
+                                }
                         }
                 }
         }
@@ -1920,8 +1924,6 @@
                         Event_post(s, Event_Status, State_Succeeded, s->action_EXEC, "program started");
                         s->program->started = now;
                 }
-                // We canot set the data collection timestmap in validate(), as the program check calls the _checkSkip() here
-                gettimeofday(&s->collected, NULL);
         }
         return rv;
 }

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE60BGd7KVfL83NXCUJZaRRqjklFAFAmEfcwYACgkQJZaRRqjk
lFBdFg//fmtbK3JTqTxTB0ucI/bc50HMWbx5NjOxIJ8Z2QkCbj4Jri0+T63kf1xW
IXiamBOaYbx2qD1xj6UO4PvboqGH9qci577P4zzghmVn0Cp0Tw5puZ6Y1rxhDopS
Job9a0YNVwMQgdSswh1XdxNkFkVToyB6W3P/P/XJW4c88+8JjIO/B9+0mVtW+k/b
xVYoeTXqPhQ0oyibRTTWWknS9KPaCjcxofX62H9qxve+totV8rtdHDv3e/DbXHOY
cFucRa5qbfUj7Soj4Qb2mmP0tFfwgu3GkVco3PZaaVTJoiSmycGhqH6bB2Qk8Luk
3SWGvWSLnA6tLkDBulRjZTNe4wa84/9XMucccReq4bX704pEoBBfWOQHuMKFHhLn
MvlEgQBQouUTD6c8IvQt7/5KSP4+QCs2SWXB57sF6F1YWogiWqFycAS1loFGtez0
YWvbL+HJnwiiXPISuv9jknLfL28mXEARb7/1JMx15ymqQ5aZNyE1zB1iayVDI5hK
30tHIY/puS51fDOAQwvd1IEYQInKvgc0aYSz+wF8juw5rGwlCahOZiTwk8SFN7Ek
swWpwP+9VpVAjABXENN0rtfBRhoHTiDi/cn2hXrTUiKvRvlvtP6OE0zh/ihPzuId
Fu1EMMd3vYKJzGwZThtiRSr80mxooVykC45BjOKt6O0iVgdePsA=
=IXdY
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210820111654.48c52853.ole>