public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs-auto-snapshot/, sys-fs/zfs-auto-snapshot/files/
@ 2022-06-26  5:12 Sam James
  0 siblings, 0 replies; only message in thread
From: Sam James @ 2022-06-26  5:12 UTC (permalink / raw
  To: gentoo-commits

commit:     105ed98cdb231affc852254ebb2903a57ac0c79e
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 26 05:11:00 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun 26 05:11:55 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=105ed98c

sys-fs/zfs-auto-snapshot: patch out which dep

Deliberately done separately to 66d873572ae205f78cc4aa015395e55d7b68b99a
as wanted to fix that immediately in stable (although it's still in @system,
it won't be for much longer hopefully, and more folks may be trying the
experiment -- for a backup/snapshot tool, it's too risky to not
have fixed it immediately).

Anyway, now try patching out the real which usage in ~arch.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/zfs-auto-snapshot-1.2.4-drop-which.patch | 47 +++++++++++
 .../zfs-auto-snapshot-1.2.4-r3.ebuild              | 92 ++++++++++++++++++++++
 2 files changed, 139 insertions(+)

diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-1.2.4-drop-which.patch b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-1.2.4-drop-which.patch
new file mode 100644
index 000000000000..125cb3d1fc04
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-1.2.4-drop-which.patch
@@ -0,0 +1,47 @@
+--- a/etc/zfs-auto-snapshot.cron.daily
++++ b/etc/zfs-auto-snapshot.cron.daily
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+ 
+ # Only call zfs-auto-snapshot if it's available
+-which zfs-auto-snapshot > /dev/null || exit 0
++command -v zfs-auto-snapshot > /dev/null || exit 0
+ 
+ exec zfs-auto-snapshot --quiet --syslog --label=daily --keep=31 //
+--- a/etc/zfs-auto-snapshot.cron.frequent
++++ b/etc/zfs-auto-snapshot.cron.frequent
+@@ -1,3 +1,3 @@
+ PATH="/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
+ 
+-*/15 * * * * root which zfs-auto-snapshot > /dev/null || exit 0 ; zfs-auto-snapshot --quiet --syslog --label=frequent --keep=4 //
++*/15 * * * * root command -v zfs-auto-snapshot > /dev/null || exit 0 ; zfs-auto-snapshot --quiet --syslog --label=frequent --keep=4 //
+--- a/etc/zfs-auto-snapshot.cron.hourly
++++ b/etc/zfs-auto-snapshot.cron.hourly
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+ 
+ # Only call zfs-auto-snapshot if it's available
+-which zfs-auto-snapshot > /dev/null || exit 0
++command -v zfs-auto-snapshot > /dev/null || exit 0
+ 
+ exec zfs-auto-snapshot --quiet --syslog --label=hourly --keep=24 //
+--- a/etc/zfs-auto-snapshot.cron.monthly
++++ b/etc/zfs-auto-snapshot.cron.monthly
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+ 
+ # Only call zfs-auto-snapshot if it's available
+-which zfs-auto-snapshot > /dev/null || exit 0
++command -v zfs-auto-snapshot > /dev/null || exit 0
+ 
+ exec zfs-auto-snapshot --quiet --syslog --label=monthly --keep=12 //
+--- a/etc/zfs-auto-snapshot.cron.weekly
++++ b/etc/zfs-auto-snapshot.cron.weekly
+@@ -1,6 +1,6 @@
+ #!/bin/sh
+ 
+ # Only call zfs-auto-snapshot if it's available
+-which zfs-auto-snapshot > /dev/null || exit 0
++command -v zfs-auto-snapshot > /dev/null || exit 0
+ 
+ exec zfs-auto-snapshot --quiet --syslog --label=weekly --keep=8 //

diff --git a/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r3.ebuild b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r3.ebuild
new file mode 100644
index 000000000000..e503554be28a
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r3.ebuild
@@ -0,0 +1,92 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit prefix readme.gentoo-r1 systemd
+
+if [[ ${PV} == 9999 ]]; then
+	inherit git-r3
+	EGIT_REPO_URI="https://github.com/zfsonlinux/${PN}.git"
+else
+	MY_P="${PN}-upstream-${PV}"
+	SRC_URI="https://github.com/zfsonlinux/${PN}/archive/upstream/${PV}.tar.gz -> ${MY_P}.tar.gz"
+	KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv"
+	S="${WORKDIR}/${MY_P}"
+fi
+
+DESCRIPTION="ZFS Automatic Snapshot Service for Linux"
+HOMEPAGE="https://github.com/zfsonlinux/zfs-auto-snapshot"
+
+LICENSE="GPL-2+"
+SLOT="0"
+IUSE="+cron +default-exclude systemd"
+
+RDEPEND="
+	sys-fs/zfs
+	!systemd? ( virtual/cron )
+"
+
+REQUIRED_USE="!systemd? ( cron )"
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-1.2.4-drop-which.patch
+)
+
+src_install() {
+	if use default-exclude; then
+		for cronfile in etc/"${PN}".cron.{daily,hourly,monthly,weekly}; do
+			sed -i "s/\(^exec ${PN}\)/\1 --default-exclude/" "${cronfile}" || die
+		done
+		sed -i "s/\(; ${PN}\)/\1 --default-exclude/" etc/"${PN}".cron.frequent || die
+	fi
+	readme.gentoo_create_doc
+	emake PREFIX="${EPREFIX}/usr" DESTDIR="${D}" install
+
+	local exclude unit
+	exclude="$(usev default-exclude)"
+	for unit in "${PN}"{-daily,-frequent,-hourly,-monthly,-weekly}.service; do
+		cp "${FILESDIR}/${unit}" "${T}/${unit}" || die
+		eprefixify "${T}/${unit}"
+		sed -i "s/@DEFAULT_EXCLUDE@/${exclude:+--default-exclude}/g" "${T}/${unit}" || die
+		systemd_dounit "${T}/${unit}"
+	done
+	for unit in "${PN}"{-daily,-frequent,-hourly,-monthly,-weekly}.timer; do
+		systemd_dounit "${FILESDIR}/${unit}"
+	done
+	systemd_dounit "${FILESDIR}/${PN}.target"
+
+	if ! use cron; then
+		ebegin "removing cron files from installation image"
+		rm -rfv "${ED}/etc" || die
+		eend "$?"
+	fi
+}
+
+pkg_postinst() {
+	readme.gentoo_print_elog
+
+	if ! use default-exclude; then
+		ewarn "snapshots are enabled by default for ALL zfs datasets"
+		ewarn "set com.sun:auto-snapshot=false or enable 'default-exclude' flag"
+		elog
+	fi
+
+	if use cron && has_version sys-process/fcron; then
+		ewarn "frequent snapshot may not work if you are using fcron"
+		ewarn "you should add frequent job to crontab manually"
+	fi
+
+	if use cron; then
+		if systemd_is_booted || has_version sys-apps/systemd; then
+			echo
+			ewarn "Both 'cron' and 'systemd' flags are enabled."
+			ewarn "So both ${PN}.target and cron files were installed."
+			ewarn "Please don't use 2 implementations at the same time."
+			ewarn "Cronjobs are usually enabled by default via /etc/cron.* jobs"
+			ewarn "If you want to use systemd ${PN}.target timers"
+			ewarn "disable 'cron' flag and reinstall ${PN}"
+			echo
+		fi
+	fi
+}


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-26  5:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-26  5:12 [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs-auto-snapshot/, sys-fs/zfs-auto-snapshot/files/ Sam James

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