Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs-auto-snapshot/, sys-fs/zfs-auto-snapshot/files/
Date: Sun, 26 Jun 2022 05:12:06
Message-Id: 1656220315.105ed98cdb231affc852254ebb2903a57ac0c79e.sam@gentoo
1 commit: 105ed98cdb231affc852254ebb2903a57ac0c79e
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jun 26 05:11:00 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sun Jun 26 05:11:55 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=105ed98c
7
8 sys-fs/zfs-auto-snapshot: patch out which dep
9
10 Deliberately done separately to 66d873572ae205f78cc4aa015395e55d7b68b99a
11 as wanted to fix that immediately in stable (although it's still in @system,
12 it won't be for much longer hopefully, and more folks may be trying the
13 experiment -- for a backup/snapshot tool, it's too risky to not
14 have fixed it immediately).
15
16 Anyway, now try patching out the real which usage in ~arch.
17
18 Signed-off-by: Sam James <sam <AT> gentoo.org>
19
20 .../files/zfs-auto-snapshot-1.2.4-drop-which.patch | 47 +++++++++++
21 .../zfs-auto-snapshot-1.2.4-r3.ebuild | 92 ++++++++++++++++++++++
22 2 files changed, 139 insertions(+)
23
24 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
25 new file mode 100644
26 index 000000000000..125cb3d1fc04
27 --- /dev/null
28 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-1.2.4-drop-which.patch
29 @@ -0,0 +1,47 @@
30 +--- a/etc/zfs-auto-snapshot.cron.daily
31 ++++ b/etc/zfs-auto-snapshot.cron.daily
32 +@@ -1,6 +1,6 @@
33 + #!/bin/sh
34 +
35 + # Only call zfs-auto-snapshot if it's available
36 +-which zfs-auto-snapshot > /dev/null || exit 0
37 ++command -v zfs-auto-snapshot > /dev/null || exit 0
38 +
39 + exec zfs-auto-snapshot --quiet --syslog --label=daily --keep=31 //
40 +--- a/etc/zfs-auto-snapshot.cron.frequent
41 ++++ b/etc/zfs-auto-snapshot.cron.frequent
42 +@@ -1,3 +1,3 @@
43 + PATH="/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
44 +
45 +-*/15 * * * * root which zfs-auto-snapshot > /dev/null || exit 0 ; zfs-auto-snapshot --quiet --syslog --label=frequent --keep=4 //
46 ++*/15 * * * * root command -v zfs-auto-snapshot > /dev/null || exit 0 ; zfs-auto-snapshot --quiet --syslog --label=frequent --keep=4 //
47 +--- a/etc/zfs-auto-snapshot.cron.hourly
48 ++++ b/etc/zfs-auto-snapshot.cron.hourly
49 +@@ -1,6 +1,6 @@
50 + #!/bin/sh
51 +
52 + # Only call zfs-auto-snapshot if it's available
53 +-which zfs-auto-snapshot > /dev/null || exit 0
54 ++command -v zfs-auto-snapshot > /dev/null || exit 0
55 +
56 + exec zfs-auto-snapshot --quiet --syslog --label=hourly --keep=24 //
57 +--- a/etc/zfs-auto-snapshot.cron.monthly
58 ++++ b/etc/zfs-auto-snapshot.cron.monthly
59 +@@ -1,6 +1,6 @@
60 + #!/bin/sh
61 +
62 + # Only call zfs-auto-snapshot if it's available
63 +-which zfs-auto-snapshot > /dev/null || exit 0
64 ++command -v zfs-auto-snapshot > /dev/null || exit 0
65 +
66 + exec zfs-auto-snapshot --quiet --syslog --label=monthly --keep=12 //
67 +--- a/etc/zfs-auto-snapshot.cron.weekly
68 ++++ b/etc/zfs-auto-snapshot.cron.weekly
69 +@@ -1,6 +1,6 @@
70 + #!/bin/sh
71 +
72 + # Only call zfs-auto-snapshot if it's available
73 +-which zfs-auto-snapshot > /dev/null || exit 0
74 ++command -v zfs-auto-snapshot > /dev/null || exit 0
75 +
76 + exec zfs-auto-snapshot --quiet --syslog --label=weekly --keep=8 //
77
78 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
79 new file mode 100644
80 index 000000000000..e503554be28a
81 --- /dev/null
82 +++ b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r3.ebuild
83 @@ -0,0 +1,92 @@
84 +# Copyright 1999-2022 Gentoo Authors
85 +# Distributed under the terms of the GNU General Public License v2
86 +
87 +EAPI=8
88 +
89 +inherit prefix readme.gentoo-r1 systemd
90 +
91 +if [[ ${PV} == 9999 ]]; then
92 + inherit git-r3
93 + EGIT_REPO_URI="https://github.com/zfsonlinux/${PN}.git"
94 +else
95 + MY_P="${PN}-upstream-${PV}"
96 + SRC_URI="https://github.com/zfsonlinux/${PN}/archive/upstream/${PV}.tar.gz -> ${MY_P}.tar.gz"
97 + KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv"
98 + S="${WORKDIR}/${MY_P}"
99 +fi
100 +
101 +DESCRIPTION="ZFS Automatic Snapshot Service for Linux"
102 +HOMEPAGE="https://github.com/zfsonlinux/zfs-auto-snapshot"
103 +
104 +LICENSE="GPL-2+"
105 +SLOT="0"
106 +IUSE="+cron +default-exclude systemd"
107 +
108 +RDEPEND="
109 + sys-fs/zfs
110 + !systemd? ( virtual/cron )
111 +"
112 +
113 +REQUIRED_USE="!systemd? ( cron )"
114 +
115 +PATCHES=(
116 + "${FILESDIR}"/${PN}-1.2.4-drop-which.patch
117 +)
118 +
119 +src_install() {
120 + if use default-exclude; then
121 + for cronfile in etc/"${PN}".cron.{daily,hourly,monthly,weekly}; do
122 + sed -i "s/\(^exec ${PN}\)/\1 --default-exclude/" "${cronfile}" || die
123 + done
124 + sed -i "s/\(; ${PN}\)/\1 --default-exclude/" etc/"${PN}".cron.frequent || die
125 + fi
126 + readme.gentoo_create_doc
127 + emake PREFIX="${EPREFIX}/usr" DESTDIR="${D}" install
128 +
129 + local exclude unit
130 + exclude="$(usev default-exclude)"
131 + for unit in "${PN}"{-daily,-frequent,-hourly,-monthly,-weekly}.service; do
132 + cp "${FILESDIR}/${unit}" "${T}/${unit}" || die
133 + eprefixify "${T}/${unit}"
134 + sed -i "s/@DEFAULT_EXCLUDE@/${exclude:+--default-exclude}/g" "${T}/${unit}" || die
135 + systemd_dounit "${T}/${unit}"
136 + done
137 + for unit in "${PN}"{-daily,-frequent,-hourly,-monthly,-weekly}.timer; do
138 + systemd_dounit "${FILESDIR}/${unit}"
139 + done
140 + systemd_dounit "${FILESDIR}/${PN}.target"
141 +
142 + if ! use cron; then
143 + ebegin "removing cron files from installation image"
144 + rm -rfv "${ED}/etc" || die
145 + eend "$?"
146 + fi
147 +}
148 +
149 +pkg_postinst() {
150 + readme.gentoo_print_elog
151 +
152 + if ! use default-exclude; then
153 + ewarn "snapshots are enabled by default for ALL zfs datasets"
154 + ewarn "set com.sun:auto-snapshot=false or enable 'default-exclude' flag"
155 + elog
156 + fi
157 +
158 + if use cron && has_version sys-process/fcron; then
159 + ewarn "frequent snapshot may not work if you are using fcron"
160 + ewarn "you should add frequent job to crontab manually"
161 + fi
162 +
163 + if use cron; then
164 + if systemd_is_booted || has_version sys-apps/systemd; then
165 + echo
166 + ewarn "Both 'cron' and 'systemd' flags are enabled."
167 + ewarn "So both ${PN}.target and cron files were installed."
168 + ewarn "Please don't use 2 implementations at the same time."
169 + ewarn "Cronjobs are usually enabled by default via /etc/cron.* jobs"
170 + ewarn "If you want to use systemd ${PN}.target timers"
171 + ewarn "disable 'cron' flag and reinstall ${PN}"
172 + echo
173 + fi
174 + fi
175 +}