Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs-auto-snapshot/files/, sys-fs/zfs-auto-snapshot/
Date: Mon, 28 Sep 2020 09:29:56
Message-Id: 1601285376.76c83257c2f3496d7a3af17290109d7714527a3f.gyakovlev@gentoo
1 commit: 76c83257c2f3496d7a3af17290109d7714527a3f
2 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
3 AuthorDate: Mon Sep 28 07:40:05 2020 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 28 09:29:36 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=76c83257
7
8 sys-fs/zfs-auto-snapshot: revbump, add systemd timers
9
10 Package-Manager: Portage-3.0.8, Repoman-3.0.1
11 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
12
13 .../files/zfs-auto-snapshot-daily.service | 6 ++
14 .../files/zfs-auto-snapshot-daily.timer | 8 ++
15 .../files/zfs-auto-snapshot-frequent.service | 6 ++
16 .../files/zfs-auto-snapshot-frequent.timer | 8 ++
17 .../files/zfs-auto-snapshot-hourly.service | 6 ++
18 .../files/zfs-auto-snapshot-hourly.timer | 8 ++
19 .../files/zfs-auto-snapshot-monthly.service | 6 ++
20 .../files/zfs-auto-snapshot-monthly.timer | 8 ++
21 .../files/zfs-auto-snapshot-weekly.service | 6 ++
22 .../files/zfs-auto-snapshot-weekly.timer | 8 ++
23 .../files/zfs-auto-snapshot.target | 11 +++
24 sys-fs/zfs-auto-snapshot/metadata.xml | 3 +-
25 .../zfs-auto-snapshot-1.2.4-r1.ebuild | 90 ++++++++++++++++++++++
26 13 files changed, 173 insertions(+), 1 deletion(-)
27
28 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.service b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.service
29 new file mode 100644
30 index 00000000000..6929cb83743
31 --- /dev/null
32 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.service
33 @@ -0,0 +1,6 @@
34 +[Unit]
35 +Description=ZFS daily snapshot service
36 +Documentation=man:zfs-auto-snapshot(8)
37 +
38 +[Service]
39 +ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot @DEFAULT_EXCLUDE@ --skip-scrub --label=daily --keep=31 //
40
41 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.timer b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.timer
42 new file mode 100644
43 index 00000000000..2198d83f458
44 --- /dev/null
45 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.timer
46 @@ -0,0 +1,8 @@
47 +[Unit]
48 +Description=ZFS daily snapshot timer
49 +Documentation=man:zfs-auto-snapshot(8)
50 +
51 +[Timer]
52 +OnCalendar=daily
53 +Persistent=true
54 +RandomizedDelaySec=600
55
56 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.service b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.service
57 new file mode 100644
58 index 00000000000..ae698351ee3
59 --- /dev/null
60 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.service
61 @@ -0,0 +1,6 @@
62 +[Unit]
63 +Description=ZFS frequent snapshot service
64 +Documentation=man:zfs-auto-snapshot(8)
65 +
66 +[Service]
67 +ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot @DEFAULT_EXCLUDE@ --skip-scrub --label=frequent --keep=4 //
68
69 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.timer b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.timer
70 new file mode 100644
71 index 00000000000..e42f2eec50e
72 --- /dev/null
73 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.timer
74 @@ -0,0 +1,8 @@
75 +[Unit]
76 +Description=ZFS frequent snapshot timer
77 +Documentation=man:zfs-auto-snapshot(8)
78 +
79 +[Timer]
80 +OnCalendar=*:0/15
81 +Persistent=true
82 +RandomizedDelaySec=60
83
84 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.service b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.service
85 new file mode 100644
86 index 00000000000..72dc764e4c7
87 --- /dev/null
88 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.service
89 @@ -0,0 +1,6 @@
90 +[Unit]
91 +Description=ZFS hourly snapshot service
92 +Documentation=man:zfs-auto-snapshot(8)
93 +
94 +[Service]
95 +ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot @DEFAULT_EXCLUDE@ --skip-scrub --label=hourly --keep=24 //
96
97 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.timer b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.timer
98 new file mode 100644
99 index 00000000000..5d3f5e51e31
100 --- /dev/null
101 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.timer
102 @@ -0,0 +1,8 @@
103 +[Unit]
104 +Description=ZFS hourly snapshot timer
105 +Documentation=man:zfs-auto-snapshot(8)
106 +
107 +[Timer]
108 +OnCalendar=hourly
109 +Persistent=true
110 +RandomizedDelaySec=59
111
112 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.service b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.service
113 new file mode 100644
114 index 00000000000..c96607cd6a1
115 --- /dev/null
116 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.service
117 @@ -0,0 +1,6 @@
118 +[Unit]
119 +Description=ZFS monthly snapshot service
120 +Documentation=man:zfs-auto-snapshot(8)
121 +
122 +[Service]
123 +ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot @DEFAULT_EXCLUDE@ --skip-scrub --label=monthly --keep=12 //
124
125 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.timer b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.timer
126 new file mode 100644
127 index 00000000000..bf5f8944bcb
128 --- /dev/null
129 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.timer
130 @@ -0,0 +1,8 @@
131 +[Unit]
132 +Description=ZFS monthly snapshot timer
133 +Documentation=man:zfs-auto-snapshot(8)
134 +
135 +[Timer]
136 +OnCalendar=monthly
137 +Persistent=true
138 +RandomizedDelaySec=600
139
140 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.service b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.service
141 new file mode 100644
142 index 00000000000..47a517ebbed
143 --- /dev/null
144 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.service
145 @@ -0,0 +1,6 @@
146 +[Unit]
147 +Description=ZFS weekly snapshot service
148 +Documentation=man:zfs-auto-snapshot(8)
149 +
150 +[Service]
151 +ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot @DEFAULT_EXCLUDE@ --skip-scrub --label=weekly --keep=8 //
152
153 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.timer b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.timer
154 new file mode 100644
155 index 00000000000..9eebb0dfdb8
156 --- /dev/null
157 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.timer
158 @@ -0,0 +1,8 @@
159 +[Unit]
160 +Description=ZFS weekly snapshot timer
161 +Documentation=man:zfs-auto-snapshot(8)
162 +
163 +[Timer]
164 +OnCalendar=weekly
165 +Persistent=true
166 +RandomizedDelaySec=600
167
168 diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot.target b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot.target
169 new file mode 100644
170 index 00000000000..b2d10f606da
171 --- /dev/null
172 +++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot.target
173 @@ -0,0 +1,11 @@
174 +[Unit]
175 +Description=Automatically create, rotate, and destroy periodic ZFS snapshots.
176 +Documentation=man:zfs-auto-snapshot(8)
177 +Requires=zfs-auto-snapshot-frequent.timer
178 +Requires=zfs-auto-snapshot-daily.timer
179 +Requires=zfs-auto-snapshot-hourly.timer
180 +Requires=zfs-auto-snapshot-weekly.timer
181 +Requires=zfs-auto-snapshot-monthly.timer
182 +
183 +[Install]
184 +WantedBy=timers.target
185
186 diff --git a/sys-fs/zfs-auto-snapshot/metadata.xml b/sys-fs/zfs-auto-snapshot/metadata.xml
187 index 7ee701b35b9..c5c19289388 100644
188 --- a/sys-fs/zfs-auto-snapshot/metadata.xml
189 +++ b/sys-fs/zfs-auto-snapshot/metadata.xml
190 @@ -15,7 +15,8 @@
191 snapshots if it is installed.
192 </longdescription>
193 <use>
194 - <flag name="default-exclude">Only take snapshots if dataset has com.sun:auto-snapshot=true property set</flag>
195 + <flag name="cron">Install /etc/cron.* files and pull in <pkg>vritual/cron</pkg></flag>
196 + <flag name="default-exclude">Only take snapshots of datasets with com.sun:auto-snapshot=true property set</flag>
197 </use>
198
199 <upstream>
200
201 diff --git a/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r1.ebuild b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r1.ebuild
202 new file mode 100644
203 index 00000000000..b1c288f934d
204 --- /dev/null
205 +++ b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r1.ebuild
206 @@ -0,0 +1,90 @@
207 +# Copyright 1999-2020 Gentoo Authors
208 +# Distributed under the terms of the GNU General Public License v2
209 +
210 +EAPI=7
211 +
212 +inherit prefix readme.gentoo-r1 systemd
213 +
214 +if [[ ${PV} == 9999 ]]; then
215 + inherit git-r3
216 + EGIT_REPO_URI="https://github.com/zfsonlinux/${PN}.git"
217 +else
218 + MY_P="${PN}-upstream-${PV}"
219 + SRC_URI="https://github.com/zfsonlinux/${PN}/archive/upstream/${PV}.tar.gz -> ${MY_P}.tar.gz"
220 + KEYWORDS="~amd64 ~arm64 ~ppc64"
221 + S="${WORKDIR}/${MY_P}"
222 +fi
223 +
224 +DESCRIPTION="ZFS Automatic Snapshot Service for Linux"
225 +HOMEPAGE="https://github.com/zfsonlinux/zfs-auto-snapshot"
226 +
227 +LICENSE="GPL-2+"
228 +SLOT="0"
229 +IUSE="+cron +default-exclude systemd"
230 +
231 +RDEPEND="
232 + sys-fs/zfs
233 + !systemd? ( virtual/cron )
234 +"
235 +
236 +REQUIRED_USE="!systemd? ( cron )"
237 +
238 +src_install() {
239 + if use default-exclude; then
240 + for cronfile in etc/"${PN}".cron.{daily,hourly,monthly,weekly}; do
241 + sed -i "s/\(^exec ${PN}\)/\1 --default-exclude/" "${cronfile}" || die
242 + done
243 + sed -i "s/\(; ${PN}\)/\1 --default-exclude/" etc/"${PN}".cron.frequent || die
244 + fi
245 + readme.gentoo_create_doc
246 + emake PREFIX="${EPREFIX}/usr" DESTDIR="${D}" install
247 +
248 + local exclude unit
249 + exclude="$(usev default-exclude)"
250 + for unit in "${PN}"{-daily,-frequent,-hourly,-monthly,-weekly}.service; do
251 + cp "${FILESDIR}/${unit}" "${T}/${unit}" || die
252 + eprefixify "${T}/${unit}"
253 + sed -i "s/@DEFAULT_EXCLUDE@/${exclude:+--default-exclude}/g" "${T}/${unit}" || die
254 + systemd_dounit "${T}/${unit}"
255 + done
256 + for unit in "${PN}"{-daily,-frequent,-hourly,-monthly,-weekly}.timer; do
257 + systemd_dounit "${FILESDIR}/${unit}"
258 + done
259 + systemd_dounit "${FILESDIR}/${PN}.target"
260 +
261 + if ! use cron; then
262 + ebegin "removing cron files from installation image"
263 + rm -rfv "${ED}/etc" || die
264 + eend "$?"
265 + fi
266 +
267 + pkg_postinst
268 +}
269 +
270 +pkg_postinst() {
271 + readme.gentoo_print_elog
272 +
273 + if ! use default-exclude; then
274 + ewarn "snapshots are enabled by default for ALL zfs datasets"
275 + ewarn "set com.sun:auto-snapshot=false or enable 'default-exclude' flag"
276 + elog
277 + fi
278 +
279 + if use cron && has_version sys-process/fcron; then
280 + ewarn "frequent snapshot may not work if you are using fcron"
281 + ewarn "you should add frequent job to crontab manually"
282 + fi
283 +
284 + if use cron; then
285 + if systemd_is_booted || has_version sys-apps/systemd; then
286 + echo
287 + ewarn "Both 'cron' and 'systemd' flags are enabled."
288 + ewarn "So both ${PN}.target and cron files were installed."
289 + ewarn "Please don't use 2 implementations at the same time."
290 + ewarn "Cronjobs are usually enabled by default via /etc/cron.* jobs"
291 + ewarn "If you want to use systemd ${PN}.target timers"
292 + ewarn "disable 'cron' flag and reinstall ${PN}"
293 + echo
294 + fi
295 + fi
296 +}