LDFLAGS += $(bup_libacl_ldflags)
endif
-config/bin/python: config/config.vars
+bup_ext_cmds := lib/cmd/bup-import-rdiff-backup lib/cmd/bup-import-rsnapshot
-bup_cmds := \
- $(patsubst cmd/%-cmd.py,cmd/bup-%,$(wildcard cmd/*-cmd.py)) \
- $(patsubst cmd/%-cmd.sh,cmd/bup-%,$(wildcard cmd/*-cmd.sh))
+config/bin/python: config/config.vars
-bup_deps := lib/bup/_helpers$(SOEXT) $(bup_cmds)
+bup_deps := lib/bup/_helpers$(SOEXT)
all: $(bup_deps) Documentation/all $(current_sampledata)
dest_libdir := $(DESTDIR)$(LIBDIR)
install: all
- $(INSTALL) -d $(dest_bindir) \
- $(dest_libdir)/bup $(dest_libdir)/cmd \
- $(dest_libdir)/web $(dest_libdir)/web/static
+ $(INSTALL) -d $(dest_bindir) $(dest_libdir)/bup/cmd $(dest_libdir)/cmd \
+ $(dest_libdir)/web/static
test -z "$(man_roff)" || install -d $(dest_mandir)/man1
test -z "$(man_roff)" || $(INSTALL) -m 0644 $(man_roff) $(dest_mandir)/man1
test -z "$(man_html)" || install -d $(dest_docdir)
test -z "$(man_html)" || $(INSTALL) -m 0644 $(man_html) $(dest_docdir)
dev/install-python-script lib/cmd/bup "$(dest_libdir)/cmd/bup"
- set -e; \
- for cmd in $$(ls cmd/bup-*); do \
- dev/install-python-script "$$cmd" "$(dest_libdir)/$$cmd"; \
- done
+ $(INSTALL) -pm 0755 $(bup_ext_cmds) "$(dest_libdir)/cmd/"
cd "$(dest_bindir)" && \
ln -sf "$$($(bup_python) -c 'import os; print(os.path.relpath("$(abspath $(dest_libdir))/cmd/bup"))')"
set -e; \
- $(INSTALL) -pm 0644 \
- lib/bup/*.py \
- $(dest_libdir)/bup
+ $(INSTALL) -pm 0644 lib/bup/*.py $(dest_libdir)/bup/
+ $(INSTALL) -pm 0644 lib/bup/cmd/*.py $(dest_libdir)/bup/cmd/
$(INSTALL) -pm 0755 \
lib/bup/*$(SOEXT) \
$(dest_libdir)/bup
$(MAKE) clean && PYTHON=python3 $(MAKE) check
$(MAKE) clean && PYTHON=python2 $(MAKE) check
-cmd/bup-%: cmd/%-cmd.py
- rm -f $@
- ln -s $*-cmd.py $@
-
-cmd/bup-%: cmd/%-cmd.sh
- rm -f $@
- ln -s $*-cmd.sh $@
-
.PHONY: Documentation/all
Documentation/all: $(man_roff) $(man_html)
lib/bup/checkout_info.py \
randomgen memtest \
testfs.img test/int/testfs.img
- for x in $$(ls cmd/*-cmd.py cmd/*-cmd.sh | grep -vF python-cmd.sh | cut -b 5-); do \
- echo "cmd/bup-$${x%-cmd.*}"; \
- done | xargs -t rm -f
if test -e test/mnt; then dev/cleanup-mounts-under test/mnt; fi
if test -e test/mnt; then rm -r test/mnt; fi
if test -e test/tmp; then dev/cleanup-mounts-under test/tmp; fi
--- /dev/null
+#!/usr/bin/env bash
+
+cmd_dir="$(cd "$(dirname "$0")" && pwd)" || exit $?
+
+set -o pipefail
+
+must() {
+ local file=${BASH_SOURCE[0]}
+ local line=${BASH_LINENO[0]}
+ "$@"
+ local rc=$?
+ if test $rc -ne 0; then
+ echo "Failed at line $line in $file" 1>&2
+ exit $rc
+ fi
+}
+
+usage() {
+ echo "Usage: bup import-rdiff-backup [-n]" \
+ "<path to rdiff-backup root> <backup name>"
+ echo "-n,--dry-run: just print what would be done"
+ exit 1
+}
+
+control_c() {
+ echo "bup import-rdiff-backup: signal 2 received" 1>&2
+ exit 128
+}
+
+must trap control_c INT
+
+dry_run=
+while [ "$1" = "-n" -o "$1" = "--dry-run" ]; do
+ dry_run=echo
+ shift
+done
+
+bup()
+{
+ $dry_run "$cmd_dir/bup" "$@"
+}
+
+snapshot_root="$1"
+branch="$2"
+
+[ -n "$snapshot_root" -a "$#" = 2 ] || usage
+
+if [ ! -e "$snapshot_root/." ]; then
+ echo "'$snapshot_root' isn't a directory!"
+ exit 1
+fi
+
+
+backups=$(must rdiff-backup --list-increments --parsable-output "$snapshot_root") \
+ || exit $?
+backups_count=$(echo "$backups" | must wc -l) || exit $?
+counter=1
+echo "$backups" |
+while read timestamp type; do
+ tmpdir=$(must mktemp -d import-rdiff-backup-XXXXXXX) || exit $?
+
+ echo "Importing backup from $(date -d @$timestamp +%c) " \
+ "($counter / $backups_count)" 1>&2
+ echo 1>&2
+
+ echo "Restoring from rdiff-backup..." 1>&2
+ must rdiff-backup -r $timestamp "$snapshot_root" "$tmpdir"
+ echo 1>&2
+
+ echo "Importing into bup..." 1>&2
+ tmpidx=$(must mktemp -u import-rdiff-backup-idx-XXXXXXX) || exit $?
+ must bup index -ux -f "$tmpidx" "$tmpdir"
+ must bup save --strip --date="$timestamp" -f "$tmpidx" -n "$branch" "$tmpdir"
+ must rm -f "$tmpidx"
+
+ must rm -rf "$tmpdir"
+ counter=$((counter+1))
+ echo 1>&2
+ echo 1>&2
+done
--- /dev/null
+#!/bin/sh
+# Does an import of a rsnapshot archive.
+
+cmd_dir="$(cd "$(dirname "$0")" && pwd)" || exit $?
+
+usage() {
+ echo "Usage: bup import-rsnapshot [-n]" \
+ "<path to snapshot_root> [<backuptarget>]"
+ echo "-n,--dry-run: just print what would be done"
+ exit 1
+}
+
+DRY_RUN=
+while [ "$1" = "-n" -o "$1" = "--dry-run" ]; do
+ DRY_RUN=echo
+ shift
+done
+
+bup()
+{
+ $DRY_RUN "$cmd_dir/bup" "$@"
+}
+
+SNAPSHOT_ROOT=$1
+TARGET=$2
+
+[ -n "$SNAPSHOT_ROOT" -a "$#" -le 2 ] || usage
+
+if [ ! -e "$SNAPSHOT_ROOT/." ]; then
+ echo "'$SNAPSHOT_ROOT' isn't a directory!"
+ exit 1
+fi
+
+
+cd "$SNAPSHOT_ROOT" || exit 2
+
+for SNAPSHOT in *; do
+ [ -e "$SNAPSHOT/." ] || continue
+ echo "snapshot='$SNAPSHOT'" >&2
+ for BRANCH_PATH in "$SNAPSHOT/"*; do
+ BRANCH=$(basename "$BRANCH_PATH") || exit $?
+ [ -e "$BRANCH_PATH/." ] || continue
+ [ -z "$TARGET" -o "$TARGET" = "$BRANCH" ] || continue
+
+ echo "snapshot='$SNAPSHOT' branch='$BRANCH'" >&2
+
+ # Get the snapshot's ctime
+ DATE=$(perl -e '@a=stat($ARGV[0]) or die "$ARGV[0]: $!";
+ print $a[10];' "$BRANCH_PATH")
+ [ -n "$DATE" ] || exit 3
+
+ TMPIDX=bupindex.$BRANCH.tmp
+ bup index -ux -f "$TMPIDX" "$BRANCH_PATH/" || exit $?
+ bup save --strip --date="$DATE" \
+ -f "$TMPIDX" -n "$BRANCH" \
+ "$BRANCH_PATH/" || exit $?
+ rm "$TMPIDX" || exit $?
+ done
+done
+++ /dev/null
-#!/usr/bin/env bash
-
-cmd_dir="$(cd "$(dirname "$0")" && pwd)" || exit $?
-
-set -o pipefail
-
-must() {
- local file=${BASH_SOURCE[0]}
- local line=${BASH_LINENO[0]}
- "$@"
- local rc=$?
- if test $rc -ne 0; then
- echo "Failed at line $line in $file" 1>&2
- exit $rc
- fi
-}
-
-usage() {
- echo "Usage: bup import-rdiff-backup [-n]" \
- "<path to rdiff-backup root> <backup name>"
- echo "-n,--dry-run: just print what would be done"
- exit 1
-}
-
-control_c() {
- echo "bup import-rdiff-backup: signal 2 received" 1>&2
- exit 128
-}
-
-must trap control_c INT
-
-dry_run=
-while [ "$1" = "-n" -o "$1" = "--dry-run" ]; do
- dry_run=echo
- shift
-done
-
-bup()
-{
- $dry_run "$cmd_dir/bup" "$@"
-}
-
-snapshot_root="$1"
-branch="$2"
-
-[ -n "$snapshot_root" -a "$#" = 2 ] || usage
-
-if [ ! -e "$snapshot_root/." ]; then
- echo "'$snapshot_root' isn't a directory!"
- exit 1
-fi
-
-
-backups=$(must rdiff-backup --list-increments --parsable-output "$snapshot_root") \
- || exit $?
-backups_count=$(echo "$backups" | must wc -l) || exit $?
-counter=1
-echo "$backups" |
-while read timestamp type; do
- tmpdir=$(must mktemp -d import-rdiff-backup-XXXXXXX) || exit $?
-
- echo "Importing backup from $(date -d @$timestamp +%c) " \
- "($counter / $backups_count)" 1>&2
- echo 1>&2
-
- echo "Restoring from rdiff-backup..." 1>&2
- must rdiff-backup -r $timestamp "$snapshot_root" "$tmpdir"
- echo 1>&2
-
- echo "Importing into bup..." 1>&2
- tmpidx=$(must mktemp -u import-rdiff-backup-idx-XXXXXXX) || exit $?
- must bup index -ux -f "$tmpidx" "$tmpdir"
- must bup save --strip --date="$timestamp" -f "$tmpidx" -n "$branch" "$tmpdir"
- must rm -f "$tmpidx"
-
- must rm -rf "$tmpdir"
- counter=$((counter+1))
- echo 1>&2
- echo 1>&2
-done
+++ /dev/null
-#!/bin/sh
-# Does an import of a rsnapshot archive.
-
-cmd_dir="$(cd "$(dirname "$0")" && pwd)" || exit $?
-
-usage() {
- echo "Usage: bup import-rsnapshot [-n]" \
- "<path to snapshot_root> [<backuptarget>]"
- echo "-n,--dry-run: just print what would be done"
- exit 1
-}
-
-DRY_RUN=
-while [ "$1" = "-n" -o "$1" = "--dry-run" ]; do
- DRY_RUN=echo
- shift
-done
-
-bup()
-{
- $DRY_RUN "$cmd_dir/bup" "$@"
-}
-
-SNAPSHOT_ROOT=$1
-TARGET=$2
-
-[ -n "$SNAPSHOT_ROOT" -a "$#" -le 2 ] || usage
-
-if [ ! -e "$SNAPSHOT_ROOT/." ]; then
- echo "'$SNAPSHOT_ROOT' isn't a directory!"
- exit 1
-fi
-
-
-cd "$SNAPSHOT_ROOT" || exit 2
-
-for SNAPSHOT in *; do
- [ -e "$SNAPSHOT/." ] || continue
- echo "snapshot='$SNAPSHOT'" >&2
- for BRANCH_PATH in "$SNAPSHOT/"*; do
- BRANCH=$(basename "$BRANCH_PATH") || exit $?
- [ -e "$BRANCH_PATH/." ] || continue
- [ -z "$TARGET" -o "$TARGET" = "$BRANCH" ] || continue
-
- echo "snapshot='$SNAPSHOT' branch='$BRANCH'" >&2
-
- # Get the snapshot's ctime
- DATE=$(perl -e '@a=stat($ARGV[0]) or die "$ARGV[0]: $!";
- print $a[10];' "$BRANCH_PATH")
- [ -n "$DATE" ] || exit 3
-
- TMPIDX=bupindex.$BRANCH.tmp
- bup index -ux -f "$TMPIDX" "$BRANCH_PATH/" || exit $?
- bup save --strip --date="$DATE" \
- -f "$TMPIDX" -n "$BRANCH" \
- "$BRANCH_PATH/" || exit $?
- rm "$TMPIDX" || exit $?
- done
-done