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.
This commit is contained in:
parent
04a09f27e4
commit
9d5639e9a0
|
@ -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
|
||||
}
|
|
@ -59,6 +59,11 @@ Restore_cache cache/packages.chroot
|
|||
|
||||
# Configure custom sources.list
|
||||
|
||||
if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/'
|
||||
then
|
||||
Chroot_bind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')"
|
||||
fi
|
||||
|
||||
cat > chroot/etc/apt/${_PARENT_FILE} << EOF
|
||||
deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LIVE_IMAGE_PARENT_ARCHIVE_AREAS}
|
||||
EOF
|
||||
|
|
|
@ -60,6 +60,11 @@ case "${1}" in
|
|||
|
||||
# Configure custom sources.list
|
||||
|
||||
if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/'
|
||||
then
|
||||
Chroot_bind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')"
|
||||
fi
|
||||
|
||||
cat > chroot/etc/apt/${_PARENT_FILE} << EOF
|
||||
deb ${LB_PARENT_MIRROR_CHROOT} ${LB_PARENT_DISTRIBUTION} ${LIVE_IMAGE_PARENT_ARCHIVE_AREAS}
|
||||
EOF
|
||||
|
@ -534,6 +539,12 @@ EOF
|
|||
mv chroot/etc/apt/sources.list.d/zz-sources.list chroot/etc/apt/sources.list
|
||||
fi
|
||||
|
||||
# Unmount local repository
|
||||
if echo "${LB_PARENT_MIRROR_CHROOT}" | grep -q '^file:/'
|
||||
then
|
||||
Chroot_unbind_path chroot "$(echo ${LB_PARENT_MIRROR_CHROOT} | sed -e 's|file:||')"
|
||||
fi
|
||||
|
||||
# Configure generic indices
|
||||
# Don't do anything if it's not required
|
||||
if [ "${LB_PARENT_MIRROR_CHROOT}" = "${LB_PARENT_MIRROR_BINARY}" ] && \
|
||||
|
|
Loading…
Reference in New Issue