1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-21 08:42:23 +00:00

sysutils/zfsnap2: must install periodic script in relevant directory.

Previously they were installed to %%EXAMPLESDIR%%.  This commit also
combines the create and delete scripts into one, and fixes a bug in the
delete script.

Upstream PR:	https://github.com/zfsnap/zfsnap/pull/112

PR:		221689
Reported by:	Anton Saietskii <vsasjason@gmail.com>
Approved by:	dmgk (ports) mm (maintainer timeout)
Sponsored by:	Axcient
This commit is contained in:
Alan Somers 2020-08-20 01:37:05 +00:00
parent 7d0dff717b
commit 876153fccf
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=545482
3 changed files with 70 additions and 13 deletions

View File

@ -4,7 +4,7 @@
PORTNAME= zfsnap
DISTVERSIONPREFIX= v
DISTVERSION= 2.0.0-beta3
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= sysutils
PKGNAMESUFFIX= 2
@ -23,14 +23,22 @@ OPTIONS_SUB= yes
PORTDOCS= AUTHORS NEWS PORTABILITY README.md
PERIODICDIR?= ${PREFIX}/etc/periodic
post-patch:
@${REINPLACE_CMD} -e "s,# ZFSNAP_LIB_DIR=.*,ZFSNAP_LIB_DIR=${PREFIX}/share/zfsnap,g" ${WRKSRC}/sbin/zfsnap.sh
.for period in daily weekly monthly
@${SED} -e "s/xPERIODICx/${period}/g" -e "s#xPREFIXx#${PREFIX}/sbin#g" ${WRKSRC}/periodic/xPERIODICx_zfsnap.sh > ${WRKSRC}/periodic/${period}_zfsnap.sh
.endfor
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/sbin/zfsnap.sh ${STAGEDIR}${PREFIX}/sbin/zfsnap
cd ${WRKSRC}/share && ${COPYTREE_SHARE} zfsnap ${STAGEDIR}${PREFIX}/share/
cd ${WRKSRC} && ${COPYTREE_SHARE} completion ${STAGEDIR}${PREFIX}/share/zfsnap
cd ${WRKSRC} && ${COPYTREE_SHARE} periodic ${STAGEDIR}${PREFIX}/share/zfsnap
.for period in daily weekly monthly
@${MKDIR} ${STAGEDIR}${PERIODICDIR}/${period}
${INSTALL_SCRIPT} ${WRKSRC}/periodic/${period}_zfsnap.sh ${STAGEDIR}${PERIODICDIR}/${period}/402.zfsnap
.endfor
${INSTALL_MAN} ${WRKSRC}/man/man8/zfsnap.8 ${STAGEDIR}${MAN8PREFIX}/man/man8/zfsnap.8
${MKDIR} ${STAGEDIR}${DOCSDIR}
.for file in ${PORTDOCS}

View File

@ -0,0 +1,48 @@
--- periodic/xPERIODICx_zfsnap.sh.orig 2020-07-28 02:17:05 UTC
+++ periodic/xPERIODICx_zfsnap.sh
@@ -11,23 +11,29 @@ fi
# xPERIODICx_zfsnap_enable - Enable xPERIODICx snapshots (values: YES | NO)
# xPERIODICx_zfsnap_flags - `zfsnap snapshot` flags
-# xPERIODICx_zfsnap_fs - Space-separated ZFS filesystems to create non-recursive snapshots
-# xPERIODICx_zfsnap_recursive_fs - Space-separated ZFS filesystems to create recursive snapshots
+# xPERIODICx_zfsnap_delete_flags - `zfsnap destroy` flags
+# xPERIODICx_zfsnap_fs - Space-separated ZFS filesystems to manage non-recursive snapshots
+# xPERIODICx_zfsnap_recursive_fs - Space-separated ZFS filesystems to manage recursive snapshots
# xPERIODICx_zfsnap_ttl - Explicit TTL value
# xPERIODICx_zfsnap_verbose - Verbose output (values: YES | NO)
# xPERIODICx_zfsnap_enable_prefix - Create snapshots with prefix (values: YES | NO) (Default = YES)
# xPERIODICx_zfsnap_prefix - set prefix for snapshots (Default = xPERIODICx)
+# xPERIODICx_zfsnap_delete_prefixes - Space-separated list of prefixes of expired zfsnap snapshots to delete
case "${xPERIODICx_zfsnap_enable-"NO"}" in
[Yy][Ee][Ss])
- OPTIONS="$xPERIODICx_zfsnap_flags"
+ CREATE_OPTIONS="$xPERIODICx_zfsnap_flags"
+ DESTROY_OPTIONS="$xPERIODICx_zfsnap_delete_flags"
case "${xPERIODICx_zfsnap_verbose-"NO"}" in
- [Yy][Ee][Ss]) OPTIONS="$OPTIONS -v" ;;
+ [Yy][Ee][Ss])
+ CREATE_OPTIONS="$CREATE_OPTIONS -v"
+ DESTROY_OPTIONS="$DESTROY_OPTIONS -v"
+ ;;
esac
case "${xPERIODICx_zfsnap_enable_prefix-"YES"}" in
- [Yy][Ee][Ss]) OPTIONS="$OPTIONS -p ${xPERIODICx_zfsnap_prefix:-"xPERIODICx-"}" ;;
+ [Yy][Ee][Ss]) CREATE_OPTIONS="$CREATE_OPTIONS -p ${xPERIODICx_zfsnap_prefix:-"xPERIODICx-"}" ;;
esac
case 'xPERIODICx' in
@@ -49,7 +55,9 @@ case "${xPERIODICx_zfsnap_enable-"NO"}" in
;;
esac
- xPREFIXx/zfsnap snapshot $OPTIONS -a ${xPERIODICx_zfsnap_ttl:-"$default_ttl"} $xPERIODICx_zfsnap_fs -r $xPERIODICx_zfsnap_recursive_fs
+ # Destroy before create, just in case the pool is out of space
+ xPREFIXx/zfsnap destroy $DESTROY_OPTIONS -p "hourly- daily- weekly- monthly- reboot- $xPERIODICx_zfsnap_delete_prefixes" $xPERIODICx_zfsnap_fs -r $xPERIODICx_zfsnap_recursive_fs && \
+ xPREFIXx/zfsnap snapshot $CREATE_OPTIONS -a ${xPERIODICx_zfsnap_ttl:-"$default_ttl"} $xPERIODICx_zfsnap_fs -r $xPERIODICx_zfsnap_recursive_fs
exit $?
;;

View File

@ -1,13 +1,14 @@
etc/bash_completion.d/zfsnap.sh
etc/periodic/daily/402.zfsnap
etc/periodic/monthly/402.zfsnap
etc/periodic/weekly/402.zfsnap
man/man8/zfsnap.8.gz
sbin/zfsnap
share/zfsnap/commands/destroy.sh
share/zfsnap/commands/recurseback.sh
share/zfsnap/commands/snapshot.sh
share/zfsnap/completion/zfsnap-completion.bash
share/zfsnap/completion/zfsnap-completion.tcsh
share/zfsnap/completion/zfsnap-completion.zsh
share/zfsnap/core.sh
share/zfsnap/periodic/xPERIODICx_zfsnap_delete.sh
share/zfsnap/periodic/xPERIODICx_zfsnap.sh
%%BASH%%etc/bash_completion.d/zfsnap.sh
%%ZSH%%share/zsh/site-functions/_zfsnap
%%DATADIR%%/commands/destroy.sh
%%DATADIR%%/commands/recurseback.sh
%%DATADIR%%/commands/snapshot.sh
%%DATADIR%%/completion/zfsnap-completion.bash
%%DATADIR%%/completion/zfsnap-completion.tcsh
%%DATADIR%%/completion/zfsnap-completion.zsh
%%DATADIR%%/core.sh
share/zsh/site-functions/_zfsnap