diff options
author | Henrik Riomar <henrik.riomar@gmail.com> | 2018-06-27 16:33:18 +0200 |
---|---|---|
committer | Henrik Riomar <henrik.riomar@gmail.com> | 2018-06-27 18:49:08 +0200 |
commit | c566212c4a59d2b8a21d257d6818dcca23e01597 (patch) | |
tree | b003f034a6c2abebc15733f7d02d5a9c7250ac5c | |
parent | 6c7cdd83eb8533325dbc46b6899b87fc14c8cd2e (diff) | |
download | aports-c566212c4a59d2b8a21d257d6818dcca23e01597.tar.bz2 aports-c566212c4a59d2b8a21d257d6818dcca23e01597.tar.xz |
testing/simplesnap: new aport
Patches are from upstream/master
4 files changed, 181 insertions, 0 deletions
diff --git a/testing/simplesnap/0001-fix-simplesnap-line-2-dotlockfile-command-not-found.patch b/testing/simplesnap/0001-fix-simplesnap-line-2-dotlockfile-command-not-found.patch new file mode 100644 index 0000000000..2c2954ff7e --- /dev/null +++ b/testing/simplesnap/0001-fix-simplesnap-line-2-dotlockfile-command-not-found.patch @@ -0,0 +1,66 @@ +From f477a6895512c77eef3637581ab36ad8319a0204 Mon Sep 17 00:00:00 2001 +From: Henrik Riomar <henrik.riomar@gmail.com> +Date: Mon, 18 Jun 2018 19:15:54 +0200 +Subject: [PATCH] fix: simplesnap: line 2??: dotlockfile: command not found + +Closes: #12 +--- + simplesnap | 28 +++++++++------------------- + 1 file changed, 9 insertions(+), 19 deletions(-) + +diff --git a/simplesnap b/simplesnap +index 6d60885..63fc0c2 100755 +--- a/simplesnap ++++ b/simplesnap +@@ -149,15 +149,11 @@ done + SSHCMD="${SSHCMD:-ssh}" + WRAPCMD="${WRAPCMD:-simplesnapwrap}" + +-DATE="gdate" +-gdate &> /dev/null || [ $? -eq 127 ] && DATE="date" +-SED="gsed" +-gsed &> /dev/null || [ $? -eq 127 ] && SED="sed" +-GREP="ggrep" +-ggrep &> /dev/null || [ $? -eq 127 ] && GREP="grep" +-HEAD="ghead" +-ghead -h &> /dev/null || [ $? -eq 127 ] && HEAD="head" +- ++command -v gdate > /dev/null && DATE="gdate" || DATE="date" ++command -v gsed > /dev/null && SED="gsed" || SED="sed" ++command -v ggrep > /dev/null && GREP="ggrep" || GREP="grep" ++command -v ghead > /dev/null && HEAD="ghead" || HEAD="head" ++command -v dotlockfile > /dev/null && LOCKMETHOD="dotlockfile" || LOCKMETHOD="mkdir" + + # Validating + [ -n "$SSHCMD" ] || syntaxerror "Invalid SSH command: $SSHCMD" +@@ -244,23 +240,17 @@ fi + + LOCKFILE="${MOUNTPOINT}/${HOST}/.lock" + +-if dotlockfile -r 0 -l -p "${LOCKFILE}"; then +- LOCKMETHOD="dotlockfile" ++if [ x"$LOCKMETHOD" = x"dotlockfile" ] && ${LOCKMETHOD} -r 0 -l -p "${LOCKFILE}" ; then + logit "Lock obtained at ${LOCKFILE} with dotlockfile" + trap "ECODE=$?; dotlockfile -u \"${LOCKFILE}\"; exit $ECODE" EXIT INT TERM +-else +- RETVAL="$?" +- if [ "$RETVAL" = "127" ]; then +- LOCKMETHOD="mkdir" +- mkdir "${LOCKFILE}" || exiterror "Could not obtain lock at ${LOCKFILE}; if $0 is not already running, rmdir that path." ++elif [ x"$LOCKMETHOD" = x"mkdir" ]; then ++ ${LOCKMETHOD} "${LOCKFILE}" || exiterror "Could not obtain lock at ${LOCKFILE}; if $0 is not already running, rmdir that path." + logit "Lock obtained at ${LOCKFILE} with mkdir" + trap "ECODE=$?; rmdir \"${LOCKFILE}\"" EXIT INT TERM +- else ++else + exiterror "Could not obtain lock at ${LOCKFILE}; $0 likely already running." +- fi + fi + +- + reap () { + DATASET="$1" + # We always save the most recent. +-- +2.17.1 + diff --git a/testing/simplesnap/0002-trap-do-not-define-ECODE-at-setup.patch b/testing/simplesnap/0002-trap-do-not-define-ECODE-at-setup.patch new file mode 100644 index 0000000000..d15735afa7 --- /dev/null +++ b/testing/simplesnap/0002-trap-do-not-define-ECODE-at-setup.patch @@ -0,0 +1,41 @@ +From cfa251c80c31ea9b3a2993ec204061cdd4c06ef4 Mon Sep 17 00:00:00 2001 +From: Henrik Riomar <henrik.riomar@gmail.com> +Date: Mon, 18 Jun 2018 19:26:30 +0200 +Subject: [PATCH] trap: do not define ECODE at setup + +We need to delay defining ECODE until we call the trap + +Before this change (set -x output): ++ trap 'ECODE=0; dotlockfile -u "/mypool2/simplesnap/storage01/.lock"; exit ' EXIT INT TERM + +After: ++ trap 'ECODE=$?; dotlockfile -u /mypool2/simplesnap/storage01/.lock; exit $ECODE' EXIT INT TERM +--- + simplesnap | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/simplesnap b/simplesnap +index 63fc0c2..fb9c4d2 100755 +--- a/simplesnap ++++ b/simplesnap +@@ -239,14 +239,15 @@ if [ ! -d "${MOUNTPOINT}/${HOST}" ]; then + fi + + LOCKFILE="${MOUNTPOINT}/${HOST}/.lock" ++printf -v EVAL_SAFE_LOCKFILE '%q' "$LOCKFILE" + + if [ x"$LOCKMETHOD" = x"dotlockfile" ] && ${LOCKMETHOD} -r 0 -l -p "${LOCKFILE}" ; then + logit "Lock obtained at ${LOCKFILE} with dotlockfile" +- trap "ECODE=$?; dotlockfile -u \"${LOCKFILE}\"; exit $ECODE" EXIT INT TERM ++ trap 'ECODE=$?; dotlockfile -u '"${EVAL_SAFE_LOCKFILE}"'; exit $ECODE' EXIT INT TERM + elif [ x"$LOCKMETHOD" = x"mkdir" ]; then + ${LOCKMETHOD} "${LOCKFILE}" || exiterror "Could not obtain lock at ${LOCKFILE}; if $0 is not already running, rmdir that path." + logit "Lock obtained at ${LOCKFILE} with mkdir" +- trap "ECODE=$?; rmdir \"${LOCKFILE}\"" EXIT INT TERM ++ trap 'ECODE=$?; rmdir '"${EVAL_SAFE_LOCKFILE}"'; exit $ECODE' EXIT INT TERM + else + exiterror "Could not obtain lock at ${LOCKFILE}; $0 likely already running." + fi +-- +2.17.1 + diff --git a/testing/simplesnap/0003-use-CHECKHOST-in-checkbackups-function.patch b/testing/simplesnap/0003-use-CHECKHOST-in-checkbackups-function.patch new file mode 100644 index 0000000000..b1bd214c43 --- /dev/null +++ b/testing/simplesnap/0003-use-CHECKHOST-in-checkbackups-function.patch @@ -0,0 +1,32 @@ +From 79dd4680928fdc999527123ebd6b3363ca705e4a Mon Sep 17 00:00:00 2001 +From: Henrik Riomar <henrik.riomar@gmail.com> +Date: Tue, 26 Jun 2018 07:57:58 +0200 +Subject: [PATCH] use CHECKHOST in checkbackups() function + +$CHECKHOST variable defined in checkbackups is unused, lets use it +instead of the global $HOST +--- + simplesnap | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/simplesnap b/simplesnap +index 63fc0c2..d9e1806 100755 +--- a/simplesnap ++++ b/simplesnap +@@ -192,11 +192,11 @@ runzfs () { + + checkbackups () { + CHECKHOST="$1" +- DATASETS="`runzfs list -t filesystem,volume -o name -H -r \"${STORE}/${HOST}\"`" ++ DATASETS="`runzfs list -t filesystem,volume -o name -H -r \"${STORE}/${CHECKHOST}\"`" + CUTOFF="`$DATE -d \"${CHECKMODE}\" +%s`" + for CHECKDS in ${DATASETS}; do + # Don't check the top-level host dataset itself. +- if [ "${CHECKDS}" = "${STORE}/${HOST}" ]; then ++ if [ "${CHECKDS}" = "${STORE}/${CHECKHOST}" ]; then + continue + fi + +-- +2.17.1 + diff --git a/testing/simplesnap/APKBUILD b/testing/simplesnap/APKBUILD new file mode 100644 index 0000000000..4476cfca5d --- /dev/null +++ b/testing/simplesnap/APKBUILD @@ -0,0 +1,42 @@ +# Contributor: Henrik Riomar <henrik.riomar@gmail.com> +# Maintainer: +pkgname=simplesnap +pkgver=1.0.4 +pkgrel=0 +pkgdesc="Simple and powerful network transmission of ZFS snapshots" +url="https://github.com/jgoerzen/simplesnap" +arch="noarch" +license="GPL-3.0-or-later" +depends="bash coreutils liblockfile openssh-client zfs" +subpackages="$pkgname-doc" +options="!check" +source="$pkgname-$pkgver.tar.gz::https://github.com/jgoerzen/$pkgname/archive/release/$pkgver.tar.gz + 0001-fix-simplesnap-line-2-dotlockfile-command-not-found.patch + 0002-trap-do-not-define-ECODE-at-setup.patch + 0003-use-CHECKHOST-in-checkbackups-function.patch + " +builddir="$srcdir/$pkgname-release-$pkgver" + +prepare() { + default_prepare + cd "$builddir" + + sed -i 's|sbin/zfs|usr/&|' simplesnap + sed -i 's|sbin/zfs|usr/&|' simplesnapwrap +} + +package() { + cd "$builddir" + + install -m 0755 -d "$pkgdir"/usr/sbin + install -m 0755 simplesnap "$pkgdir"/usr/sbin/ + install -m 0755 simplesnapwrap "$pkgdir"/usr/sbin/ + + install -m 0755 -d "$pkgdir"/usr/share/man/man8 + install -m 0644 doc/simplesnap.8 "$pkgdir"/usr/share/man/man8/ +} + +sha512sums="818f917d65b87366af1530441f2c070a51e34efbf7790509f00aa18949dae4f8f5b1bbde4b67ca45f95df4ea816f42416c9f09aba060769d3548eb5f12551b62 simplesnap-1.0.4.tar.gz +54273ec9630cc5e764db65361ac4a03e27dafcbbe67794053e8a94584e7e8ed10db908b0285485a80253cf93bb7daf9f5257924a1476ab235138c88abb0111b7 0001-fix-simplesnap-line-2-dotlockfile-command-not-found.patch +618fd1ed200ae30437528a52090bf4363ba7f3641741865fb78ef67401fbde41a77fe83681d9c26a2391b7be6c25d22ba4285922911c28a1d0b7c4b093a19df7 0002-trap-do-not-define-ECODE-at-setup.patch +49248602dbbdb22ae1ac224f716e71165320184941434e968c214e969e26a8dbbfe6058a6af56684b31b51440817ef9fe874e64fa793a32713e5d3a644def73b 0003-use-CHECKHOST-in-checkbackups-function.patch" |