summaryrefslogtreecommitdiff
path: root/sys-fs/zfs-auto-snapshot
diff options
context:
space:
mode:
Diffstat (limited to 'sys-fs/zfs-auto-snapshot')
-rw-r--r--sys-fs/zfs-auto-snapshot/Manifest16
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.service6
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-daily.timer8
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.service6
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-frequent.timer8
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.service6
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-hourly.timer8
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.service6
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-monthly.timer8
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.service6
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot-weekly.timer8
-rw-r--r--sys-fs/zfs-auto-snapshot/files/zfs-auto-snapshot.target11
-rw-r--r--sys-fs/zfs-auto-snapshot/metadata.xml3
-rw-r--r--sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r1.ebuild88
-rw-r--r--sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-9999.ebuild48
15 files changed, 227 insertions, 9 deletions
diff --git a/sys-fs/zfs-auto-snapshot/Manifest b/sys-fs/zfs-auto-snapshot/Manifest
index 01464528c1cc..d57db57dfb6e 100644
--- a/sys-fs/zfs-auto-snapshot/Manifest
+++ b/sys-fs/zfs-auto-snapshot/Manifest
@@ -1,5 +1,17 @@
AUX README.gentoo 684 BLAKE2B 7175ddfbb8dd5b209fa4fa5e5a3aeecac3fdd102e240f93b640f91bbf0204f9101801a94087383d7087bec08ae490e9769dfcf4f7f218d6daa4779087a8a0d23 SHA512 e77c3a573c2d4499df902b68909c186e4c80ba8b451b493c7e08e5e96ebe281933ce4b5fc11c201e33f27b14a02a35fd85270baf7ddece42a2fcbc6c3c421146
+AUX zfs-auto-snapshot-daily.service 216 BLAKE2B 7c07eb29b2923cdce50af71f356edcb688a803f36711edd4cef61d89324425f255ba17139f0eb7c9fb75bc5316051b76504e8fe476ea84592a0fa318c2f84711 SHA512 0cd391b026d3f2d2af312bd2c572cff7ee136f1575fb69b9a2fc044105d8fa463b4fb511fd5f17cf773a53894b9fe20691aac11d95f7884cfcf6ef76e0c615bf
+AUX zfs-auto-snapshot-daily.timer 148 BLAKE2B 2392e77048af08c24cf18b5428706251a292701343d967f61f8fb1aa0cc0b3f0f0fa7ce70556fd46951608b2ebeb16b7ac76e29eda9c19a75b7db98a76768320 SHA512 38b4a48132afe5634934a6064eccb9089f9b32514c1614bc5a28798b67dac5f378f65e7f437d2f2b7f35063460be26df7c663733d719c2e2de7fd4d63fe70c60
+AUX zfs-auto-snapshot-frequent.service 221 BLAKE2B 8d7268fbb74fb4193d5e136c86065ad3432e7d25d6875296ea0175ce809d7d8663ff3c8f769643e9d8131a45c3c1912a942308f93680e91b910e47da5a887d5e SHA512 60bb1f59c187388db631da02340102802a22957ed314ab92042e144df38276d741ab5d02b10b200182686b5b4a0f2af54db29e57eaeed5dece3ffca3d1d258f0
+AUX zfs-auto-snapshot-frequent.timer 151 BLAKE2B 1a64a3cfdd3158bc37efb289e7ab6d9e072e7cad45859ac6003a110cda20acbdf07050b9e71348fbdc4741fd6eeabe92ccfca04608244768057dbf6ece92ee31 SHA512 4b4fbf5794e63abcbff1a5f88bc502c084b5a205b0c316a981e64b29e86eebec23cf0b8aac8d324d73324d2fd624b6866a16c1e3074ac73834aa83bd5d5000ad
+AUX zfs-auto-snapshot-hourly.service 218 BLAKE2B 8ba476bc812861ddc9afb35c5ce125a6ee96941459856a30841d037b29080569c8a69e13ab2b7b9fce262622e02609a290656ce39fb0170cf9e839961b346b6a SHA512 f3893aafa3081866158e13a9fdd74ebed20cdde90b898fc79a7b041479e9e031c3d5cb40c257f38216456228a2caa02e48bf44ca59000e8d045061875a1ae412
+AUX zfs-auto-snapshot-hourly.timer 149 BLAKE2B 47af6c37755b03df10920abd2ba44afaaab3f72f0dac1071c9b0d4b1c1ea58c4d8578ebf9b24f8dc7104b5abf19c2d5a18f8eafafe232fa222073e1250739bbf SHA512 63f79c2495a08dfbb908416b33ff0dc419c8ad69d7bb472c6ec7a4cb7988ccb3713f38f2697cf5ed4bf8bfaaea597bef84585257f95c20f67929cf6e6c1c3f3d
+AUX zfs-auto-snapshot-monthly.service 220 BLAKE2B 31f47f232a7eea37068c7881fc7a0fbeedfa4ebc90e8f6611aecd5bf434287198c78fb2bc5b0961f9dc7b8a84135df7756fe4c79ebddf3b8d2592e36a242c253 SHA512 a108f652d86a7d90ebae2694178ac03305d9ffaf8b77a1ad4d1f2ef77678e53a67fa8f4cf0bcd53eea8df62bdcb599c299d00739d451e0ecdefd93386e954670
+AUX zfs-auto-snapshot-monthly.timer 152 BLAKE2B 617e0e9e31b6c081bd4aa626978a9c988931ffc37738bc841b7dbbf2c5877a80f7e80893f133c3ee64b36fafb5842e1da18366ab061ab132b9303325731c2d20 SHA512 20339cc6e317a7bf7eae8c1e8ec2e2669276aa9148e8a4f5697896b261617214ca20dff109e452e3af06dd91ca9787f77691fb021a62a4fd5243d6cc43edf87b
+AUX zfs-auto-snapshot-weekly.service 217 BLAKE2B 715f8f8da6272b9ea782dbe77dbafa6e919297c9c24c58f38775cc9356f5644a57a86fa7ff80134558c8f3081df3c102cc455eb815c729ef4cebed81bc4dfe9d SHA512 7ecaf7256a3921a5cac6c551b3b7d833907c02530141abfcf2689c90f3bb091d6115fb3e62695bccf4fce172ec3c8b6b8a8ff0960f73dd65404cfff4b15985cf
+AUX zfs-auto-snapshot-weekly.timer 150 BLAKE2B 655187add790017f8328edae33e88eb0a4b88774999e67a5fb9c990f5bae9a13ac1e64c290c7e0a218cdcf05dd7bbe320369d1741da036c54994371eecfc50d7 SHA512 49357f15660900b344eba04f8d4bab7e153b728b4665e285b2f9320a287c15b62c426d568d2ba9a43daf69c6f1a6fbccff8b68417f8991dd5f8c3368d562b73c
+AUX zfs-auto-snapshot.target 360 BLAKE2B 17be6ab113a8849d5244fd36140d1165c4e919df2a04f4b16aa591c1c92b29243b1be4f2243bcc6a8ef015b0cc1fb53b183da1c83668e4e7e0b609f7301a3372 SHA512 f607dada27e4be409184152b93e2079eecf12f5eba76f2dbe42bdbf4793603063c23813e752bfd829a081eeb6d09c86bc18ab75d65bff87b2c1d4f998abac516
DIST zfs-auto-snapshot-upstream-1.2.4.tar.gz 13375 BLAKE2B 2a44cdecb7c4bb432c1804dba9a6674289aced9664ae0fcc6a33b604b128d852fce459367316f11961747594516916da51072ed10f84d0c01ea8cca553ce7eec SHA512 26382303fce8b90dfb40f69fcab92308e88c17c147b4a566c5d32f2e9aa241d64f5da56ad82b4becb824ba01a470037a724460d35676a1d46de9c578c02a57d9
+EBUILD zfs-auto-snapshot-1.2.4-r1.ebuild 2569 BLAKE2B f263b09a100de5847cd23761b53f123e61f4ab8e9c4f98bb7a0dd8854e3e70e41fd4e4df730b2c265e5a18a636c479bbf7a689309b6a8bd7fe8ae011801a8732 SHA512 ecbcdd796820464725ecab22bd8fd5049c46cd1a3f45bef305e1910f14dddbc3ca9973afe623423c409b71ff8459b22a5eda201b2e0b08235b728dd6fbf74301
EBUILD zfs-auto-snapshot-1.2.4.ebuild 1388 BLAKE2B bbdc50ab6b3ee05cd8c7606b07d7609d62e092345232261a47bf12e423d0bd548d1f009f54aa8fa25a387264e20abfbf8efa415f87cb6ab2331a6e8250ef8a55 SHA512 2bbc915d73fe4fb581af4b9a512228834eaa13105be89e8b9a2303334328c426030220fe750ab7662f83c173184787367994bdb1c2adb7647fc9bc5e14b4a8d0
-EBUILD zfs-auto-snapshot-9999.ebuild 1390 BLAKE2B 641dd27e8910fce57c130dbaf49460efb5ca9f89a694f0f9661b898b75bd0af015d9036d43eb6d36840b325eb4a56c03d609dad326211534e97c2c53f8394e29 SHA512 180789c017c9c0f2fc432cf7cdcb147bfa2862a265fcab804585904c4cf0bd759ba89fe989d0a3474d5a1ffa4b3ae8a3f4fb0919241278624a5023265da26e97
-MISC metadata.xml 909 BLAKE2B 74eeac781ab385dfd962c316d6792c79ebdffed9084f3c7b071a13b502edb881555e4e9525a1c8c5f2fe0ca51241afbe430f7ce07fdbd4b2554c841f1837af85 SHA512 d98be1718d600b6a04af37294de1eb47e814c74ddf24d4e119d037554baf3f9b551ab43dabd1dcd70b35b65e9fb687325c04371d078757d26c07385ac72143c8
+EBUILD zfs-auto-snapshot-9999.ebuild 2569 BLAKE2B f263b09a100de5847cd23761b53f123e61f4ab8e9c4f98bb7a0dd8854e3e70e41fd4e4df730b2c265e5a18a636c479bbf7a689309b6a8bd7fe8ae011801a8732 SHA512 ecbcdd796820464725ecab22bd8fd5049c46cd1a3f45bef305e1910f14dddbc3ca9973afe623423c409b71ff8459b22a5eda201b2e0b08235b728dd6fbf74301
+MISC metadata.xml 964 BLAKE2B 1770ba286fb8bc951069d778bed894d02536ee199e9cfa776878af509ecc77db36048a62ea45ff4f3ce6e4320e1d03ad373825a9de54fcd42e16031d8be52125 SHA512 89291918f6f2f4fb919513ed50ec47d3abeb0b5bb9227c13f6d5875a0d12765fee685c75b547745df90f625b7231226a2f299a197336d57e6970a0bbe6fc4071
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 000000000000..6929cb837438
--- /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 000000000000..2198d83f458b
--- /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 000000000000..ae698351ee3e
--- /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 000000000000..e42f2eec50e0
--- /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 000000000000..72dc764e4c7f
--- /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 000000000000..5d3f5e51e312
--- /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 000000000000..c96607cd6a16
--- /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 000000000000..bf5f8944bcb5
--- /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 000000000000..47a517ebbed9
--- /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 000000000000..9eebb0dfdb8d
--- /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 000000000000..b2d10f606da5
--- /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 7ee701b35b9f..3e7ea4e0074d 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</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 000000000000..4096503e2fff
--- /dev/null
+++ b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-1.2.4-r1.ebuild
@@ -0,0 +1,88 @@
+# 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() {
+ 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
+}
diff --git a/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-9999.ebuild b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-9999.ebuild
index c880e32a7601..4096503e2fff 100644
--- a/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-9999.ebuild
+++ b/sys-fs/zfs-auto-snapshot/zfs-auto-snapshot-9999.ebuild
@@ -1,9 +1,9 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI=6
+EAPI=7
-inherit readme.gentoo-r1
+inherit prefix readme.gentoo-r1 systemd
if [[ ${PV} == 9999 ]]; then
inherit git-r3
@@ -20,10 +20,14 @@ HOMEPAGE="https://github.com/zfsonlinux/zfs-auto-snapshot"
LICENSE="GPL-2+"
SLOT="0"
-IUSE="+default-exclude"
+IUSE="+cron +default-exclude systemd"
-RDEPEND="sys-fs/zfs
- virtual/cron"
+RDEPEND="
+ sys-fs/zfs
+ !systemd? ( virtual/cron )
+"
+
+REQUIRED_USE="!systemd? ( cron )"
src_install() {
if use default-exclude; then
@@ -34,6 +38,25 @@ src_install() {
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() {
@@ -45,8 +68,21 @@ pkg_postinst() {
elog
fi
- if has_version sys-process/fcron; then
+ 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
}