From owner-dev-commits-ports-main@freebsd.org Wed Apr 7 11:23:29 2021 Return-Path: Delivered-To: dev-commits-ports-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2CDCC5D35A3; Wed, 7 Apr 2021 11:23:29 +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 4FFhpn0mRXz4t8n; Wed, 7 Apr 2021 11:23:29 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 0D21A1E3C7; Wed, 7 Apr 2021 11:23:29 +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 137BNSCg087336; Wed, 7 Apr 2021 11:23:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137BNS68087335; Wed, 7 Apr 2021 11:23:28 GMT (envelope-from git) Date: Wed, 7 Apr 2021 11:23:28 GMT Message-Id: <202104071123.137BNS68087335@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: =?utf-8?B?RmVybmFuZG8gQXBlc3RlZ3XDrWE=?= Subject: git: 1a76a776c71c - main - sysutils/anacron: Fix start after resume MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fernape X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1a76a776c71cf0cf74e8e66586cc64cc6896b558 Auto-Submitted: auto-generated X-BeenThere: dev-commits-ports-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the main branch of the FreeBSD ports repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 11:23:29 -0000 The branch main has been updated by fernape: URL: https://cgit.FreeBSD.org/ports/commit/?id=1a76a776c71cf0cf74e8e66586cc64cc6896b558 commit 1a76a776c71cf0cf74e8e66586cc64cc6896b558 Author: Fernando ApesteguĂ­a AuthorDate: 2021-04-07 11:16:00 +0000 Commit: Fernando ApesteguĂ­a CommitDate: 2021-04-07 11:20:03 +0000 sysutils/anacron: Fix start after resume The anacron utility should be run by it's rc(8) script after resume, since the time to run jobs from the anacrontab(5) might have passed while the system was sleeping. PR: 253567 Reported by: walter.von.entferndt@posteo.net Approved by: dz@426.ch (maintainer) --- sysutils/anacron/Makefile | 20 +++++++++++--------- sysutils/anacron/files/anacron.in | 31 +++++++++++++++++++++++-------- sysutils/anacron/files/patch-log.c | 10 ++++++++++ sysutils/anacron/files/patch-main.c | 10 ++++++++++ sysutils/anacron/files/patch-matchrx.c | 6 +++++- sysutils/anacron/files/patch-runjob.c | 13 +++++++++++-- sysutils/anacron/files/pkg-message.in | 15 ++++++++++----- sysutils/anacron/pkg-plist | 12 +++++++----- 8 files changed, 87 insertions(+), 30 deletions(-) diff --git a/sysutils/anacron/Makefile b/sysutils/anacron/Makefile index 944f2f537689..795bcf61a49d 100644 --- a/sysutils/anacron/Makefile +++ b/sysutils/anacron/Makefile @@ -2,7 +2,7 @@ PORTNAME= anacron PORTVERSION= 2.3 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= sysutils MASTER_SITES= SF @@ -13,20 +13,22 @@ LICENSE= GPLv2+ LICENSE_FILE= ${WRKSRC}/COPYING USES= gmake -USE_RC_SUBR= anacron +USE_RC_SUBR= ${PORTNAME} SUB_FILES= pkg-message +PLIST_SUB= PORTNAME=${PORTNAME} +SUB_LIST+= PORTNAME=${PORTNAME} COMMENT="${COMMENT}" post-patch: -.for f in Makefile anacron.8 anacrontab.5 - @${REINPLACE_CMD} -e 's|\(/etc/anacrontab\)|${PREFIX}\1|' ${WRKSRC}/${f} +.for f in Makefile ${PORTNAME}.8 ${PORTNAME}tab.5 + @${REINPLACE_CMD} -e 's|\(/etc/${PORTNAME}tab\)|${PREFIX}\1|' ${WRKSRC}/${f} .endfor @${REINPLACE_CMD} -e 's|^CFLAGS = .*||' ${WRKSRC}/Makefile do-install: - ${INSTALL_PROGRAM} ${WRKSRC}/anacron ${STAGEDIR}${PREFIX}/sbin - ${INSTALL_MAN} ${WRKSRC}/anacron.8 ${STAGEDIR}${MAN8PREFIX}/man/man8 - ${INSTALL_MAN} ${WRKSRC}/anacrontab.5 ${STAGEDIR}${MAN5PREFIX}/man/man5 - ${INSTALL_DATA} ${FILESDIR}/anacrontab.sample ${STAGEDIR}${PREFIX}/etc - @${MKDIR} ${STAGEDIR}/var/spool/anacron + ${INSTALL_PROGRAM} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/sbin + ${INSTALL_MAN} ${WRKSRC}/${PORTNAME}.8 ${STAGEDIR}${MAN8PREFIX}/man/man8 + ${INSTALL_MAN} ${WRKSRC}/${PORTNAME}tab.5 ${STAGEDIR}${MAN5PREFIX}/man/man5 + ${INSTALL_DATA} ${FILESDIR}/${PORTNAME}tab.sample ${STAGEDIR}${PREFIX}/etc + @${MKDIR} ${STAGEDIR}/var/spool/${PORTNAME} .include diff --git a/sysutils/anacron/files/anacron.in b/sysutils/anacron/files/anacron.in index b3698b7e5cac..9e32e4420335 100644 --- a/sysutils/anacron/files/anacron.in +++ b/sysutils/anacron/files/anacron.in @@ -1,21 +1,36 @@ #!/bin/sh -# PROVIDE: anacron +# PROVIDE: %%PORTNAME%% # REQUIRE: LOGIN +# KEYWORD: resume # -# Add the following line to /etc/rc.conf to enable anacron: +# Execute one of the following commands as root to enable %%PORTNAME%%: # -# anacron_enable="YES" +# service %%PORTNAME%% enable +# sysrc %%PORTNAME%%_enable=YES # . /etc/rc.subr -name=anacron -rcvar=anacron_enable +name=%%PORTNAME%% +command="%%PREFIX%%/sbin/%%PORTNAME%%" +desc="%%COMMENT%%" +extra_commands=resume +rcvar=%%PORTNAME%%_enable +required_vars=syslogd_enable load_rc_config $name -: ${anacron_enable:=NO} -command="%%PREFIX%%/sbin/anacron" +: ${%%PORTNAME%%_enable:=NO} -run_rc_command "$1" +if [ $# -gt 0 -a $1 = "resume" ]; then + arg=start + if checkyesno $rcvar; then + info "starting ${name} after resume" + fi +else + arg=$1 +fi +debug "$name: \$1 = $1, arg = $arg" + +run_rc_command "$arg" diff --git a/sysutils/anacron/files/patch-log.c b/sysutils/anacron/files/patch-log.c new file mode 100644 index 000000000000..320a83d8c606 --- /dev/null +++ b/sysutils/anacron/files/patch-log.c @@ -0,0 +1,10 @@ +--- log.c.orig 2000-06-22 22:55:13 UTC ++++ log.c +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/sysutils/anacron/files/patch-main.c b/sysutils/anacron/files/patch-main.c new file mode 100644 index 000000000000..12dafcab98f3 --- /dev/null +++ b/sysutils/anacron/files/patch-main.c @@ -0,0 +1,10 @@ +--- main.c.orig 2000-06-22 22:58:07 UTC ++++ main.c +@@ -24,6 +24,7 @@ + + #include + #include ++#include + #include + #include + #include diff --git a/sysutils/anacron/files/patch-matchrx.c b/sysutils/anacron/files/patch-matchrx.c index a8a5d456fbdd..ffba9b6baa56 100644 --- a/sysutils/anacron/files/patch-matchrx.c +++ b/sysutils/anacron/files/patch-matchrx.c @@ -1,6 +1,6 @@ --- matchrx.c.orig 2000-06-20 23:12:18 UTC +++ matchrx.c -@@ -23,6 +23,7 @@ +@@ -23,9 +23,11 @@ #include @@ -8,3 +8,7 @@ #include #include #include ++#include + #include "matchrx.h" + + int diff --git a/sysutils/anacron/files/patch-runjob.c b/sysutils/anacron/files/patch-runjob.c index a984d32ce1bb..781ea1693057 100644 --- a/sysutils/anacron/files/patch-runjob.c +++ b/sysutils/anacron/files/patch-runjob.c @@ -9,8 +9,6 @@ - int fd, i; + int fd; + char name[] = "/tmp/anacron.XXXXXX"; -+ -+ fd = mkstemp(name); - i = 0; - name = NULL; @@ -25,6 +23,8 @@ - /* I'm not sure we actually need to be so persistent here */ - } while (fd == -1 && errno == EEXIST && i < max_retries); - ++ fd = mkstemp(name); ++ if (fd == -1) die_e("Can't open temporary file"); if (unlink(name)) die_e("Can't unlink temporary file"); - free(name); @@ -32,3 +32,12 @@ fcntl(fd, F_SETFD, 1); /* set close-on-exec flag */ return fd; } +@@ -84,7 +72,7 @@ username() + } + + static void +-xputenv(const char *s) ++xputenv(char *s) + { + if (putenv(s)) die_e("Can't set the environment"); + } diff --git a/sysutils/anacron/files/pkg-message.in b/sysutils/anacron/files/pkg-message.in index 77c5d61d0db1..64d2be3ba0d6 100644 --- a/sysutils/anacron/files/pkg-message.in +++ b/sysutils/anacron/files/pkg-message.in @@ -2,12 +2,17 @@ { type: install message: </dev/null || echo "If you are permanently removing this port, you should do a 'rm -rf /var/spool/anacron'." -man/man8/anacron.8.gz -man/man5/anacrontab.5.gz +sbin/%%PORTNAME%% +@sample etc/%%PORTNAME%%tab.sample +@postexec mkdir -p /var/spool/%%PORTNAME%% 2>/dev/null +@postunexec rmdir /var/spool/%%PORTNAME%% 2>/dev/null || echo "If you are permanently removing this port, you should do a 'rm -rf /var/spool/%%PORTNAME%%'." +man/man8/%%PORTNAME%%.8.gz +man/man5/%%PORTNAME%%tab.5.gz +@dir /var/spool/%%PORTNAME%%