From nobody Wed Aug 31 16:43:45 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MHqkV1RNdz4bqlT; Wed, 31 Aug 2022 16:43:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MHqkV0gHlz40N0; Wed, 31 Aug 2022 16:43:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661964226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ffjoxs3j0WQtRRyrwhZe6/Mq4zvPmddmgjN3skorFUs=; b=tb+sYFAlWUuzErQp3pKdba7Io8X6z61hSHL1ldttZFsuZ+orCQDiV9+Ozecj6FeG0P/eJF E74NOsQa3PvLRoPjJEcPW8R8MzNihBkGPCgNn8Qc9PzX1XaunAFCu/OHNMp6bHjQAF2sSt 4i44g02Wybh8PM+McQbfdEGj4sDZSNtsbshtqvetQiiJjDHHVJ1fmZW1X7xisCGQEVm68D Lske/GLKkyRQl+WPg/sv5mKbhpFoptBgff6XSfY8veUWI2IOKG2grQdpul5oec8VMgSmB3 gTBEV9rqqKA0iMBExYRAXzzJJObkutgpSd+dqYu3nGk983I7GCV9PU7t+fEKxw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MHqkT6rdGz1BHW; Wed, 31 Aug 2022 16:43:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27VGhjgi074715; Wed, 31 Aug 2022 16:43:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27VGhj7L074714; Wed, 31 Aug 2022 16:43:45 GMT (envelope-from git) Date: Wed, 31 Aug 2022 16:43:45 GMT Message-Id: <202208311643.27VGhj7L074714@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Cy Schubert Subject: git: c18825ce6d0c - main - sysutils/nut-devel: Update to the latest networkupstools/nut github commit List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c18825ce6d0ca97cf6801436bfb5e096ef347479 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661964226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ffjoxs3j0WQtRRyrwhZe6/Mq4zvPmddmgjN3skorFUs=; b=hi7R87JpphLoMZyKY6F0o9Ea66hMqYKjK+NjoOvEA1vAXNYxztlFaFSNZDiRFjsx9nA4gt KUiCqg/TqtArRv8uI9wmEiBuipnr1FZGns8DivksJdTxlsOKyxwExTRu+p46ZevUUB2JNQ T1TA+5PSVSmTsEgcm/6M9ALRGLAPrVW2/1NhxoDTA9h7RroFUeOLfBxMbudsxUpu1Usmgn Bk36GVcjdTbbsoOolngUT6UUTOIAJDoshnOcL01Yl3lcMyPkyzyriJyHASS3maTyFDR7i1 1FziG7NT2yjHAEaymT5x4naPQGQyp4DPzTMFRowhuc/yjmvOTJeW4K7YOwNJuQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661964226; a=rsa-sha256; cv=none; b=mkJa8MPGcvpqpRd/Ind9zdL6Crr87f5Gn+3coEYfyGjjUVl88ITBDmVAnwgbvXNzgBXbo/ YZDK39p+GrWTUSqWW6xIXon2T6tIK+x/8PUgFwawA5CZ0M7UXtVJ/pCOJoj68/eX81JnZs MEvw5vwPNO4dN8DcZCxuKC54rqIA67vIbftlNBHuUtNojQbj9/9BMuSse9ufwPBWgAuPrB 1BUv6ikv6p33p9u9VuoUmE3UdTtMlSgkkraE+Q0q6YFM4Y3zul3PPEuJbDimYIDiIVhz2y 3wnAfnNaK85eHFRnOwRghZFEq40FDqHha1Yj+5CavJhXLHHmi05FRG/7B5xnCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/ports/commit/?id=c18825ce6d0ca97cf6801436bfb5e096ef347479 commit c18825ce6d0ca97cf6801436bfb5e096ef347479 Author: Cy Schubert AuthorDate: 2022-08-31 16:40:06 +0000 Commit: Cy Schubert CommitDate: 2022-08-31 16:40:06 +0000 sysutils/nut-devel: Update to the latest networkupstools/nut github commit Now that muliple UPS support has been accepted and merged into our upstream's mainline, revert the nut-devl part of 2c6ac43b0d95 and 9c4a120c36bf, and pull in the latest nut commit on GH. --- sysutils/nut-devel/Makefile | 4 +- sysutils/nut-devel/distinfo | 6 +- sysutils/nut-devel/files/patch-clients_upslog.c | 280 --------------------- sysutils/nut-devel/files/patch-docs_man_upslog.txt | 14 -- 4 files changed, 5 insertions(+), 299 deletions(-) diff --git a/sysutils/nut-devel/Makefile b/sysutils/nut-devel/Makefile index 39a576b32ea6..cbed9c263078 100644 --- a/sysutils/nut-devel/Makefile +++ b/sysutils/nut-devel/Makefile @@ -18,8 +18,8 @@ CONFLICTS= nut-[0-9]* USE_GITHUB= yes GH_ACCOUNT= networkupstools -GH_TAGNAME= 2ce9dfa4a -NUT_COMMIT_DATE= 2022.08.25 +GH_TAGNAME= ef842b40c +NUT_COMMIT_DATE= 2022.08.31 MAKE_JOBS_UNSAFE= yes USE_GCC= yes diff --git a/sysutils/nut-devel/distinfo b/sysutils/nut-devel/distinfo index 7701c7bfde6b..8f3558f483e4 100644 --- a/sysutils/nut-devel/distinfo +++ b/sysutils/nut-devel/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1661703464 -SHA256 (networkupstools-nut-2022.08.25-2ce9dfa4a_GH0.tar.gz) = 16a7077c4df92021d01e7355673d8c30021f51c76af1bc52560d340ff408689e -SIZE (networkupstools-nut-2022.08.25-2ce9dfa4a_GH0.tar.gz) = 3509186 +TIMESTAMP = 1661963762 +SHA256 (networkupstools-nut-2022.08.31-ef842b40c_GH0.tar.gz) = ecb812c3a813b3a5561116d58375f8f939fb9fe3b9ef1381eb19f904a121e470 +SIZE (networkupstools-nut-2022.08.31-ef842b40c_GH0.tar.gz) = 3514816 diff --git a/sysutils/nut-devel/files/patch-clients_upslog.c b/sysutils/nut-devel/files/patch-clients_upslog.c deleted file mode 100644 index 199f55efd69c..000000000000 --- a/sysutils/nut-devel/files/patch-clients_upslog.c +++ /dev/null @@ -1,280 +0,0 @@ ---- clients/upslog.c.orig 2022-08-29 22:20:20.954722000 -0700 -+++ clients/upslog.c 2022-08-29 22:21:18.844395000 -0700 -@@ -41,32 +45,49 @@ - #include "upslog.h" - - static int reopen_flag = 0, exit_flag = 0; -- static uint16_t port; -- static char *upsname, *hostname; -- static UPSCONN_t ups; -+ static char *upsname; -+ static UPSCONN_t *ups; - -- static FILE *logfile; -- static const char *logfn, *monhost; -+ static char *logfn, *monhost; - static sigset_t nut_upslog_sigmask; - static char logbuffer[LARGEBUF], *logformat; - - static flist_t *fhead = NULL; -+ struct monhost_ups { -+ char *monhost; -+ char *logfn; -+ char *upsname; -+ char *hostname; -+ uint16_t port; -+ UPSCONN_t *ups; -+ FILE *logfile; -+ struct monhost_ups *next; -+ }; -+ static struct monhost_ups *monhost_ups_anchor = NULL; -+ static struct monhost_ups *monhost_ups_current = NULL; -+ static struct monhost_ups *monhost_ups_prev = NULL; - -+ - #define DEFAULT_LOGFORMAT "%TIME @Y@m@d @H@M@S% %VAR battery.charge% " \ - "%VAR input.voltage% %VAR ups.load% [%VAR ups.status%] " \ - "%VAR ups.temperature% %VAR input.frequency%" - - static void reopen_log(void) - { -- if (logfile == stdout) { -- upslogx(LOG_INFO, "logging to stdout"); -- return; -- } -+ for (monhost_ups_current = monhost_ups_anchor; -+ monhost_ups_current != NULL; -+ monhost_ups_current = monhost_ups_current->next) { -+ if (monhost_ups_current->logfile == stdout) { -+ upslogx(LOG_INFO, "logging to stdout"); -+ return; -+ } - -- fclose(logfile); -- logfile = fopen(logfn, "a"); -- if (logfile == NULL) -- fatal_with_errno(EXIT_FAILURE, "could not reopen logfile %s", logfn); -+ if ((monhost_ups_current->logfile = freopen( -+ monhost_ups_current->logfn, "a", -+ monhost_ups_current->logfile)) == NULL) -+ fatal_with_errno(EXIT_FAILURE, -+ "could not reopen logfile %s", logfn); -+ } - } - - static void set_reopen_flag(int sig) -@@ -131,6 +152,8 @@ - printf(" -p - Base name for PID file (defaults to \"%s\")\n", prog); - printf(" -s - Monitor UPS - @[:]\n"); - printf(" - Example: -s myups@server\n"); -+ printf(" -m - Monitor UPS \n"); -+ printf(" - Example: -m myups@server,/var/log/myups.log\n"); - printf(" -u - Switch to if started as root\n"); - - printf("\n"); -@@ -215,7 +238,7 @@ - query[2] = var; - numq = 3; - -- ret = upscli_get(&ups, numq, query, &numa, &answer); -+ ret = upscli_get(ups, numq, query, &numa, &answer); - - if ((ret < 0) || (numa < numq)) { - snprintfcat(logbuffer, sizeof(logbuffer), "NA"); -@@ -368,7 +391,7 @@ - } - - /* go through the list of functions and call them in order */ --static void run_flist(void) -+static void run_flist(struct monhost_ups *monhost_ups_print) - { - flist_t *tmp; - -@@ -382,8 +405,8 @@ - tmp = tmp->next; - } - -- fprintf(logfile, "%s\n", logbuffer); -- fflush(logfile); -+ fprintf(monhost_ups_print->logfile, "%s\n", logbuffer); -+ fflush(monhost_ups_print->logfile); - } - - /* -s -@@ -396,6 +419,7 @@ - int main(int argc, char **argv) - { - int interval = 30, i, foreground = -1; -+ size_t monhost_len = 0; - const char *prog = xbasename(argv[0]); - time_t now, nextpoll = 0; - const char *user = NULL; -@@ -407,7 +431,7 @@ - - printf("Network UPS Tools %s %s\n", prog, UPS_VERSION); - -- while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FB")) != -1) { -+ while ((i = getopt(argc, argv, "+hs:l:i:f:u:Vp:FBm:")) != -1) { - switch(i) { - case 'h': - help(prog); -@@ -415,6 +439,33 @@ - break; - #endif - -+ case 'm': { /* var scope */ -+ char *m_arg, *s; -+ -+ monhost_ups_prev = monhost_ups_current; -+ monhost_ups_current = xmalloc(sizeof(struct monhost_ups)); -+ if (monhost_ups_anchor == NULL) -+ monhost_ups_anchor = monhost_ups_current; -+ else -+ monhost_ups_prev->next = monhost_ups_current; -+ monhost_ups_current->next = NULL; -+ monhost_len++; -+ -+ /* Be sure to not mangle original optarg, nor rely on its longevity */ -+ s = xstrdup(optarg); -+ m_arg = s; -+ monhost_ups_current->monhost = xstrdup(strsep(&m_arg, ",")); -+ if (!m_arg) -+ fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile' requires exactly 2 components in the tuple"); -+ monhost_ups_current->logfn = xstrdup(strsep(&m_arg, ",")); -+ if (m_arg) /* Had a third comma - also unexpected! */ -+ fatalx(EXIT_FAILURE, "Argument '-m upsspec,logfile' requires exactly 2 components in the tuple"); -+ if (upscli_splitname(monhost_ups_current->monhost, &(monhost_ups_current->upsname), &(monhost_ups_current->hostname), &(monhost_ups_current->port)) != 0) { -+ fatalx(EXIT_FAILURE, "Error: invalid UPS definition. Required format: upsname[@hostname[:port]]\n"); -+ } -+ free(s); -+ } /* var scope */ -+ break; - case 's': - monhost = optarg; - break; -@@ -479,42 +530,59 @@ - snprintfcat(logformat, LARGEBUF, "%s ", argv[i]); - } - -- if (!monhost) -- fatalx(EXIT_FAILURE, "No UPS defined for monitoring - use -s "); -+ if (monhost_ups_anchor == NULL) { -+ if (monhost) { -+ monhost_ups_current = xmalloc(sizeof(struct monhost_ups)); -+ monhost_ups_anchor = monhost_ups_current; -+ monhost_ups_current->next = NULL; -+ monhost_ups_current->monhost = monhost; -+ monhost_len=1; -+ } else { -+ fatalx(EXIT_FAILURE, "No UPS defined for monitoring - use -s "); -+ } - -- if (!logfn) -- fatalx(EXIT_FAILURE, "No filename defined for logging - use -l "); -+ if (logfn) -+ monhost_ups_current->logfn = logfn; -+ else -+ fatalx(EXIT_FAILURE, "No filename defined for logging - use -l "); -+ } - - /* shouldn't happen */ - if (!logformat) - fatalx(EXIT_FAILURE, "No format defined - but this should be impossible"); - -- printf("logging status of %s to %s (%is intervals)\n", -- monhost, logfn, interval); -+ for (monhost_ups_current = monhost_ups_anchor; -+ monhost_ups_current != NULL; -+ monhost_ups_current = monhost_ups_current->next) { -+ printf("logging status of %s to %s (%is intervals)\n", -+ monhost_ups_current->monhost, monhost_ups_current->logfn, interval); -+ if (upscli_splitname(monhost_ups_current->monhost, &(monhost_ups_current->upsname), &(monhost_ups_current->hostname), &(monhost_ups_current->port)) != 0) { -+ fatalx(EXIT_FAILURE, "Error: invalid UPS definition. Required format: upsname[@hostname[:port]]\n"); -+ } - -- if (upscli_splitname(monhost, &upsname, &hostname, &port) != 0) { -- fatalx(EXIT_FAILURE, "Error: invalid UPS definition. Required format: upsname[@hostname[:port]]\n"); -- } -+ monhost_ups_current->ups = xmalloc(sizeof(UPSCONN_t)); -+ if (upscli_connect(monhost_ups_current->ups, monhost_ups_current->hostname, monhost_ups_current->port, UPSCLI_CONN_TRYSSL) < 0) -+ fprintf(stderr, "Warning: initial connect failed: %s\n", -+ upscli_strerror(monhost_ups_current->ups)); - -- if (upscli_connect(&ups, hostname, port, UPSCLI_CONN_TRYSSL) < 0) -- fprintf(stderr, "Warning: initial connect failed: %s\n", -- upscli_strerror(&ups)); -+ if (strcmp(monhost_ups_current->logfn, "-") == 0) -+ monhost_ups_current->logfile = stdout; -+ else -+ monhost_ups_current->logfile = fopen(monhost_ups_current->logfn, "a"); - -- if (strcmp(logfn, "-") == 0) -- logfile = stdout; -- else -- logfile = fopen(logfn, "a"); -+ if (monhost_ups_current->logfile == NULL) -+ fatal_with_errno(EXIT_FAILURE, "could not open logfile %s", logfn); - -- if (logfile == NULL) -- fatal_with_errno(EXIT_FAILURE, "could not open logfile %s", logfn); -+ } - -+ - /* now drop root if we have it */ - new_uid = get_user_pwent(user); - - open_syslog(prog); - - if (foreground < 0) { -- if (logfile == stdout) { -+ if (monhost_ups_anchor->logfile == stdout) { - foreground = 1; - } else { - foreground = 0; -@@ -552,25 +620,35 @@ - reopen_flag = 0; - } - -- /* reconnect if necessary */ -- if (upscli_fd(&ups) < 0) { -- upscli_connect(&ups, hostname, port, 0); -- } -+ for (monhost_ups_current = monhost_ups_anchor; -+ monhost_ups_current != NULL; -+ monhost_ups_current = monhost_ups_current->next) { -+ ups = monhost_ups_current->ups; /* XXX Not ideal */ -+ upsname = monhost_ups_current->upsname; /* XXX Not ideal */ -+ /* reconnect if necessary */ -+ if (upscli_fd(ups) < 0) { -+ upscli_connect(ups, monhost_ups_current->hostname, monhost_ups_current->port, 0); -+ } - -- run_flist(); -+ run_flist(monhost_ups_current); - -- /* don't keep connection open if we don't intend to use it shortly */ -- if (interval > 30) { -- upscli_disconnect(&ups); -+ /* don't keep connection open if we don't intend to use it shortly */ -+ if (interval > 30) { -+ upscli_disconnect(ups); -+ } - } - } - - upslogx(LOG_INFO, "Signal %d: exiting", exit_flag); -+ for (monhost_ups_current = monhost_ups_anchor; -+ monhost_ups_current != NULL; -+ monhost_ups_current = monhost_ups_current->next) { - -- if (logfile != stdout) -- fclose(logfile); -+ if (monhost_ups_current->logfile != stdout) -+ fclose(monhost_ups_current->logfile); - -- upscli_disconnect(&ups); -+ upscli_disconnect(monhost_ups_current->ups); -+ } - - exit(EXIT_SUCCESS); - } diff --git a/sysutils/nut-devel/files/patch-docs_man_upslog.txt b/sysutils/nut-devel/files/patch-docs_man_upslog.txt deleted file mode 100644 index 9e139ccb6105..000000000000 --- a/sysutils/nut-devel/files/patch-docs_man_upslog.txt +++ /dev/null @@ -1,14 +0,0 @@ ---- docs/man/upslog.txt.orig 2022-08-30 05:56:15.850373000 -0700 -+++ docs/man/upslog.txt 2022-08-30 06:01:45.955996000 -0700 -@@ -78,6 +78,11 @@ - Monitor this UPS. The format for this option is - +upsname[@hostname[:port]]+. The default hostname is "localhost". - -+*-m* 'tuple':: -+Monitor multiple UPSs. The format for this option is a tuple of -+ups and logfile separated by commas. An example would be: -+`upsname@hostname:9999,/var/log/nut/cps.log` -+ - *-u* 'username':: - - If started as root, upslog will *setuid*(2) to the user id