commit:     76c83257c2f3496d7a3af17290109d7714527a3f
Author:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 28 07:40:05 2020 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Mon Sep 28 09:29:36 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=76c83257

sys-fs/zfs-auto-snapshot: revbump, add systemd timers

Package-Manager: Portage-3.0.8, Repoman-3.0.1
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>

 .../files/zfs-auto-snapshot-daily.service          |  6 ++
 .../files/zfs-auto-snapshot-daily.timer            |  8 ++
 .../files/zfs-auto-snapshot-frequent.service       |  6 ++
 .../files/zfs-auto-snapshot-frequent.timer         |  8 ++
 .../files/zfs-auto-snapshot-hourly.service         |  6 ++
 .../files/zfs-auto-snapshot-hourly.timer           |  8 ++
 .../files/zfs-auto-snapshot-monthly.service        |  6 ++
 .../files/zfs-auto-snapshot-monthly.timer          |  8 ++
 .../files/zfs-auto-snapshot-weekly.service         |  6 ++
 .../files/zfs-auto-snapshot-weekly.timer           |  8 ++
 .../files/zfs-auto-snapshot.target                 | 11 +++
 sys-fs/zfs-auto-snapshot/metadata.xml              |  3 +-
 .../zfs-auto-snapshot-1.2.4-r1.ebuild              | 90 ++++++++++++++++++++++
 13 files changed, 173 insertions(+), 1 deletion(-)

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
new file mode 100644
index 00000000000..6929cb83743
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=ZFS daily snapshot service
+Documentation=man:zfs-auto-snapshot(8)
+
+[Service]
+ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot 
@DEFAULT_EXCLUDE@ --skip-scrub --label=daily --keep=31 //

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
new file mode 100644
index 00000000000..2198d83f458
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=ZFS daily snapshot timer
+Documentation=man:zfs-auto-snapshot(8)
+
+[Timer]
+OnCalendar=daily
+Persistent=true
+RandomizedDelaySec=600

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
new file mode 100644
index 00000000000..ae698351ee3
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=ZFS frequent snapshot service
+Documentation=man:zfs-auto-snapshot(8)
+
+[Service]
+ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot 
@DEFAULT_EXCLUDE@ --skip-scrub --label=frequent --keep=4 //

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
new file mode 100644
index 00000000000..e42f2eec50e
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=ZFS frequent snapshot timer
+Documentation=man:zfs-auto-snapshot(8)
+
+[Timer]
+OnCalendar=*:0/15
+Persistent=true
+RandomizedDelaySec=60

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
new file mode 100644
index 00000000000..72dc764e4c7
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=ZFS hourly snapshot service
+Documentation=man:zfs-auto-snapshot(8)
+
+[Service]
+ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot 
@DEFAULT_EXCLUDE@ --skip-scrub --label=hourly --keep=24 //

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
new file mode 100644
index 00000000000..5d3f5e51e31
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=ZFS hourly snapshot timer
+Documentation=man:zfs-auto-snapshot(8)
+
+[Timer]
+OnCalendar=hourly
+Persistent=true
+RandomizedDelaySec=59

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
new file mode 100644
index 00000000000..c96607cd6a1
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=ZFS monthly snapshot service
+Documentation=man:zfs-auto-snapshot(8)
+
+[Service]
+ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot 
@DEFAULT_EXCLUDE@ --skip-scrub --label=monthly --keep=12 //

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
new file mode 100644
index 00000000000..bf5f8944bcb
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=ZFS monthly snapshot timer
+Documentation=man:zfs-auto-snapshot(8)
+
+[Timer]
+OnCalendar=monthly
+Persistent=true
+RandomizedDelaySec=600

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
new file mode 100644
index 00000000000..47a517ebbed
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.service
@@ -0,0 +1,6 @@
+[Unit]
+Description=ZFS weekly snapshot service
+Documentation=man:zfs-auto-snapshot(8)
+
+[Service]
+ExecStart=@GENTOO_PORTAGE_EPREFIX@/usr/sbin/zfs-auto-snapshot 
@DEFAULT_EXCLUDE@ --skip-scrub --label=weekly --keep=8 //

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
new file mode 100644
index 00000000000..9eebb0dfdb8
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=ZFS weekly snapshot timer
+Documentation=man:zfs-auto-snapshot(8)
+
+[Timer]
+OnCalendar=weekly
+Persistent=true
+RandomizedDelaySec=600

diff --git a/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot.target 
b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot.target
new file mode 100644
index 00000000000..b2d10f606da
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot.target
@@ -0,0 +1,11 @@
+[Unit]
+Description=Automatically create, rotate, and destroy periodic ZFS snapshots.
+Documentation=man:zfs-auto-snapshot(8)
+Requires=zfs-auto-snapshot-frequent.timer
+Requires=zfs-auto-snapshot-daily.timer
+Requires=zfs-auto-snapshot-hourly.timer
+Requires=zfs-auto-snapshot-weekly.timer
+Requires=zfs-auto-snapshot-monthly.timer
+
+[Install]
+WantedBy=timers.target

diff --git a/sys-fs/zfs-auto-snapshot/metadata.xml 
b/sys-fs/zfs-auto-snapshot/metadata.xml
index 7ee701b35b9..c5c19289388 100644
--- a/sys-fs/zfs-auto-snapshot/metadata.xml
+++ b/sys-fs/zfs-auto-snapshot/metadata.xml
@@ -15,7 +15,8 @@
                snapshots if it is installed.
        </longdescription>
        <use>
-               <flag name="default-exclude">Only take snapshots if dataset has 
com.sun:auto-snapshot=true property set</flag>
+               <flag name="cron">Install /etc/cron.* files and pull in 
<pkg>vritual/cron</pkg></flag>
+               <flag name="default-exclude">Only take snapshots of datasets 
with com.sun:auto-snapshot=true property set</flag>
        </use>
 
        <upstream>

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
new file mode 100644
index 00000000000..b1c288f934d
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r1.ebuild
@@ -0,0 +1,90 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+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"
+       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 )"
+
+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
+}
+
+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
+}

Reply via email to