X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fbackupninja.git;a=blobdiff_plain;f=lib%2Fbackends%2Fchroot.in;fp=lib%2Fbackends%2Fchroot.in;h=b0c5cfa732889c30cb366b23bae70f673598910f;hp=0000000000000000000000000000000000000000;hb=3c04ecde671ef12c01ff79393f936b879fb08f04;hpb=a8f65652866003814b6f2c79bec0165beee24ab9 diff --git a/lib/backends/chroot.in b/lib/backends/chroot.in new file mode 100644 index 0000000..b0c5cfa --- /dev/null +++ b/lib/backends/chroot.in @@ -0,0 +1,42 @@ +# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- +# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: + +getconf CHROOT "`which chroot`" + +function backend_chroot_init () { + # Is the changeroot command available? + [ -x "$CHROOT" ] +} + +function backend_chroot_host_available () { + if [ -d "$1" ]; then + # The root exists and is a directory, everything ok + return 0 + else + if [ ! -e "$1" ]; then + # The root does not exist? + eval "$2=\"No such file or directory: '\$1'\"" + else + # The root exists, so is not a directory + eval "$2=\"Not a directory: '\$1'\"" + fi + return 1 + fi +} + +function backend_chroot_host_root () { + # The host part is the root, but strip any trailing slashes + echo "$1" | sed 's/\/*$//' +} + +function backend_chroot_run () { + # Run the command using the chroot command + "$CHROOT" "$root" "$@" +} + +function backend_chroot_interpolate_vars () { + echo "" +} + +function backend_chroot_interpolate_value () { +}