diff options
author | Jan Blunck <jblunck@brocade.com> | 2014-11-28 20:53:50 +0100 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2014-12-10 08:43:02 +0100 |
commit | 9d5639e9a058ea7cfb13500ed71dd97447135069 (patch) | |
tree | 170a4babf9a39ec0be4d2095290390e6fa6c7fcc /functions | |
parent | 04a09f27e4089aaab0694ea067d7273d9420f9c8 (diff) | |
download | vyos-live-build-9d5639e9a058ea7cfb13500ed71dd97447135069.tar.gz vyos-live-build-9d5639e9a058ea7cfb13500ed71dd97447135069.zip |
Bind local repository into chroot directory.
If a local repository path is given as a mirror URL lets bind it into the
chroot. The local repository will be unmounted while processing "remove" or
latest by the exit function.
Diffstat (limited to 'functions')
-rw-r--r-- | functions/chroot_bind_path.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/functions/chroot_bind_path.sh b/functions/chroot_bind_path.sh new file mode 100644 index 000000000..1a2ab8be8 --- /dev/null +++ b/functions/chroot_bind_path.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +## live-build(7) - System Build Scripts +## Copyright (C) 2006-2014 Daniel Baumann <mail@daniel-baumann.ch> +## +## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING. +## This is free software, and you are welcome to redistribute it +## under certain conditions; see COPYING for details. + + +Chroot_bind_path () +{ + CHROOT="$(readlink -f ${1})" + BIND_SRC="$(readlink -f ${2})" + + BIND_DEST=$(echo "${BIND_SRC}" | sed -e 's|/\+||') + if [ ! -d "${CHROOT}/${BIND_DEST}" -o \ + -z "$(cat /proc/mounts | awk -vdir="${CHROOT}/${BIND_DEST}" '$2 ~ dir { print $2}')" ] + then + Echo_message "Binding local repository path" + mkdir -p "${CHROOT}/${BIND_DEST}" + mount --bind "${LB_PARENT_MIRROR_CHROOT#file:}" \ + "${CHROOT}/${BIND_DEST}" + fi +} + +Chroot_unbind_path () +{ + CHROOT="$(readlink -f ${1})" + BIND_SRC="$(readlink -f ${2})" + + BIND_DEST=$(echo "${BIND_SRC}" | sed -e 's|/\+||') + if [ -d "${CHROOT}/${BIND_DEST}" ] + then + Echo_message "Unbinding local repository path" + umount "${CHROOT}/${BIND_DEST}" > /dev/null 2>&1 || true + fi +} |