* [gentoo-commits] repo/gentoo:master commit in: app-admin/tmpwatch/files/, app-admin/tmpwatch/
@ 2021-08-20 2:18 Sam James
0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2021-08-20 2:18 UTC (permalink / raw
To: gentoo-commits
commit: ce830c8d6fc7869fd559d36c71cf3b8af3b4fd80
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 20 02:16:53 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 20 02:18:09 2021 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ce830c8d
app-admin/tmpwatch: address bug 524698 (bashism)
Remove the use of the [[ keyword in favour of the POSIX test command
(SC3010).
Don't hard-code pathnames to external programs and define silly
variables such as TMPWATCH. Instead, define a sane PATH at the beginning
of the script.
Don't force the user to reason with whether certain variables need to be
set or not. Instead, call out to portageq in the samples. Further, check
the exit status of portageq, rather than blindly assume that it always
succeeds. As a result, there are no more hard-coded paths, other than
/tmp.
Use pgrep in a less sloppy way.
Query PORT_LOGDIR if the query for PORTAGE_LOGDIR fails.
Closes: https://bugs.gentoo.org/524698
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
app-admin/tmpwatch/files/tmpwatch.cron | 40 ++++++++++------------
...atch-2.11-r2.ebuild => tmpwatch-2.11-r3.ebuild} | 0
2 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/app-admin/tmpwatch/files/tmpwatch.cron b/app-admin/tmpwatch/files/tmpwatch.cron
index 806b1453e55..d35a590379d 100644
--- a/app-admin/tmpwatch/files/tmpwatch.cron
+++ b/app-admin/tmpwatch/files/tmpwatch.cron
@@ -1,47 +1,45 @@
#!/bin/sh
-# vim: ft=sh
+
+PATH="/usr/sbin:/usr/bin:/sbin:/bin"
# This cron script contains several (commented out) examples. You may use
# them as is, by uncommenting them, or modify them to suit your needs. Read
# tmpwatch(8) for more information on tmpwatch parameters.
-### Variables ###
-
-TMPWATCH="/usr/sbin/tmpwatch"
-#PORTAGE_TMPDIR="$(portageq envvar PORTAGE_TMPDIR)/portage"
-#PORTAGE_LOGDIR="$(portageq envvar PORT_LOGDIR)"
-#DISTDIR="$(portageq distdir)"
-
### EXAMPLES ###
# NOTE: if you have noatime in /etc/fstab for any partitions you plan on
# running tmpwatch on, you should obviously change any of the examples that
# use atime (-u|--atime). Those that don't specify anything, default to
-# atime.
-
-# NOTE2: the time value is in HOURS!
+# atime. Be aware that the time value is in HOURS!
# Delete everything in /tmp that haven't been accessed in a week (>=168 hrs).
#
-# if [[ -d /tmp ]]; then
-# ${TMPWATCH} --atime 168 /tmp
+# if [ -d /tmp ]; then
+# tmpwatch --atime 168 /tmp
# fi
# Delete everything in PORTAGE_TMPDIR that hasn't been modified in 2 weeks.
#
-# if [[ -d ${PORTAGE_TMPDIR:-/var/tmp/portage} && -z $(/usr/bin/pgrep emerge) ]]; then
-# ${TMPWATCH} --mtime --all 336 ${PORTAGE_TMPDIR:-/var/tmp/portage}
+# if PORTAGE_TMPDIR=$(portageq envvar PORTAGE_TMPDIR) &&
+# [ -d "${PORTAGE_TMPDIR}/portage" ] &&
+# ! pgrep -x emerge >/dev/null
+# then
+# tmpwatch --mtime --all 336 "${PORTAGE_TMPDIR}/portage"
# fi
# Delete everything in DISTDIR that hasn't been accessed in 6 months (going
-# by 30 day months)
+# by 30 day months).
#
-# if [[ -d ${DISTDIR:-/usr/portage/distfiles} ]]; then
-# ${TMPWATCH} --atime --fuser 4320 ${DISTDIR:-/usr/portage/distfiles}
+# if DISTDIR=$(portageq distdir) && [ -d "${DISTDIR}" ]; then
+# tmpwatch --atime --fuser 4320 "${DISTDIR}"
# fi
-# Delete everything in PORTAGE_LOGDIR that hasn't been accessed in 4 weeks
+# Delete everything in PORTAGE_LOGDIR that hasn't been accessed in 4 weeks.
#
-# if [[ -d ${PORTAGE_LOGDIR:-/var/log/portage} ]]; then
-# ${TMPWATCH} --atime 772 ${PORTAGE_LOGDIR:-/var/log/portage}
+# if { PORTAGE_LOGDIR=$(portageq envvar PORTAGE_LOGDIR) ||
+# PORTAGE_LOGDIR=$(portageq envvar PORT_LOGDIR); } &&
+# [ -d "${PORTAGE_LOGDIR}" ]
+# then
+# tmpwatch --atime 772 "${PORTAGE_LOGDIR}"
# fi
diff --git a/app-admin/tmpwatch/tmpwatch-2.11-r2.ebuild b/app-admin/tmpwatch/tmpwatch-2.11-r3.ebuild
similarity index 100%
rename from app-admin/tmpwatch/tmpwatch-2.11-r2.ebuild
rename to app-admin/tmpwatch/tmpwatch-2.11-r3.ebuild
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: app-admin/tmpwatch/files/, app-admin/tmpwatch/
@ 2021-08-20 2:26 Sam James
0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2021-08-20 2:26 UTC (permalink / raw
To: gentoo-commits
commit: b32a477eba2470c5137d5c2b2da0d28d45c4bdc0
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Aug 20 02:16:53 2021 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Aug 20 02:26:17 2021 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b32a477e
app-admin/tmpwatch: address bug 524698 (bashism)
Remove the use of the [[ keyword in favour of the POSIX test command
(SC3010).
Don't hard-code pathnames to external programs and define silly
variables such as TMPWATCH. Instead, define a sane PATH at the beginning
of the script.
Don't force the user to reason with whether certain variables need to be
set or not. Instead, call out to portageq in the samples. Further, check
the exit status of portageq, rather than blindly assume that it always
succeeds. As a result, there are no more hard-coded paths, other than
/tmp.
Use pgrep in a less sloppy way.
Query PORT_LOGDIR if the query for PORTAGE_LOGDIR fails.
Closes: https://bugs.gentoo.org/524698
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
app-admin/tmpwatch/files/tmpwatch.cron | 40 ++++++++++------------
...atch-2.11-r2.ebuild => tmpwatch-2.11-r3.ebuild} | 0
2 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/app-admin/tmpwatch/files/tmpwatch.cron b/app-admin/tmpwatch/files/tmpwatch.cron
index 806b1453e55..d35a590379d 100644
--- a/app-admin/tmpwatch/files/tmpwatch.cron
+++ b/app-admin/tmpwatch/files/tmpwatch.cron
@@ -1,47 +1,45 @@
#!/bin/sh
-# vim: ft=sh
+
+PATH="/usr/sbin:/usr/bin:/sbin:/bin"
# This cron script contains several (commented out) examples. You may use
# them as is, by uncommenting them, or modify them to suit your needs. Read
# tmpwatch(8) for more information on tmpwatch parameters.
-### Variables ###
-
-TMPWATCH="/usr/sbin/tmpwatch"
-#PORTAGE_TMPDIR="$(portageq envvar PORTAGE_TMPDIR)/portage"
-#PORTAGE_LOGDIR="$(portageq envvar PORT_LOGDIR)"
-#DISTDIR="$(portageq distdir)"
-
### EXAMPLES ###
# NOTE: if you have noatime in /etc/fstab for any partitions you plan on
# running tmpwatch on, you should obviously change any of the examples that
# use atime (-u|--atime). Those that don't specify anything, default to
-# atime.
-
-# NOTE2: the time value is in HOURS!
+# atime. Be aware that the time value is in HOURS!
# Delete everything in /tmp that haven't been accessed in a week (>=168 hrs).
#
-# if [[ -d /tmp ]]; then
-# ${TMPWATCH} --atime 168 /tmp
+# if [ -d /tmp ]; then
+# tmpwatch --atime 168 /tmp
# fi
# Delete everything in PORTAGE_TMPDIR that hasn't been modified in 2 weeks.
#
-# if [[ -d ${PORTAGE_TMPDIR:-/var/tmp/portage} && -z $(/usr/bin/pgrep emerge) ]]; then
-# ${TMPWATCH} --mtime --all 336 ${PORTAGE_TMPDIR:-/var/tmp/portage}
+# if PORTAGE_TMPDIR=$(portageq envvar PORTAGE_TMPDIR) &&
+# [ -d "${PORTAGE_TMPDIR}/portage" ] &&
+# ! pgrep -x emerge >/dev/null
+# then
+# tmpwatch --mtime --all 336 "${PORTAGE_TMPDIR}/portage"
# fi
# Delete everything in DISTDIR that hasn't been accessed in 6 months (going
-# by 30 day months)
+# by 30 day months).
#
-# if [[ -d ${DISTDIR:-/usr/portage/distfiles} ]]; then
-# ${TMPWATCH} --atime --fuser 4320 ${DISTDIR:-/usr/portage/distfiles}
+# if DISTDIR=$(portageq distdir) && [ -d "${DISTDIR}" ]; then
+# tmpwatch --atime --fuser 4320 "${DISTDIR}"
# fi
-# Delete everything in PORTAGE_LOGDIR that hasn't been accessed in 4 weeks
+# Delete everything in PORTAGE_LOGDIR that hasn't been accessed in 4 weeks.
#
-# if [[ -d ${PORTAGE_LOGDIR:-/var/log/portage} ]]; then
-# ${TMPWATCH} --atime 772 ${PORTAGE_LOGDIR:-/var/log/portage}
+# if { PORTAGE_LOGDIR=$(portageq envvar PORTAGE_LOGDIR) ||
+# PORTAGE_LOGDIR=$(portageq envvar PORT_LOGDIR); } &&
+# [ -d "${PORTAGE_LOGDIR}" ]
+# then
+# tmpwatch --atime 772 "${PORTAGE_LOGDIR}"
# fi
diff --git a/app-admin/tmpwatch/tmpwatch-2.11-r2.ebuild b/app-admin/tmpwatch/tmpwatch-2.11-r3.ebuild
similarity index 100%
rename from app-admin/tmpwatch/tmpwatch-2.11-r2.ebuild
rename to app-admin/tmpwatch/tmpwatch-2.11-r3.ebuild
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-20 2:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-20 2:18 [gentoo-commits] repo/gentoo:master commit in: app-admin/tmpwatch/files/, app-admin/tmpwatch/ Sam James
-- strict thread matches above, loose matches on Subject: below --
2021-08-20 2:26 Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox