From e2840dc97b543923a73812809fd9dc8e08c8f45f Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Mon, 3 Jul 2017 06:50:15 +0000 Subject: [PATCH] Move function "on_chroot" to main script --- build.sh | 19 +++++++++++++++++++ scripts/common.sh | 20 -------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/build.sh b/build.sh index fee7ff8..2cae71b 100755 --- a/build.sh +++ b/build.sh @@ -26,6 +26,25 @@ source "$FUNCTIONS_DIR/dependencies_check.sh" source "$SCRIPT_DIR/common.sh" +on_chroot() { + local proc_fs="$ROOTFS_DIR/proc" + local dev_fs="$ROOTFS_DIR/dev" + local devpts_fs="$ROOTFS_DIR/dev/pts" + local sys_fs="$ROOTFS_DIR/sys" + + mount --bind /dev "$dev_fs" + mount --bind /dev/pts "$devpts_fs" + mount -t proc proc "$proc_fs" + mount --bind /sys "$sys_fs" + + capsh --drop=cap_setfcap "--chroot=$ROOTFS_DIR/" -- "$@" + + umount "$sys_fs" + umount "$proc_fs" + umount "$devpts_fs" + umount "$dev_fs" +} + apply_patches() { if [ ! -d "$1" ]; then echo "Patches directory does not exist: $1" diff --git a/scripts/common.sh b/scripts/common.sh index 4bcea69..38c7482 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -32,25 +32,5 @@ unmount_image() { done } -on_chroot() { - local proc_fs="$ROOTFS_DIR/proc" - local dev_fs="$ROOTFS_DIR/dev" - local devpts_fs="$ROOTFS_DIR/dev/pts" - local sys_fs="$ROOTFS_DIR/sys" - - mount --bind /dev "$dev_fs" - mount --bind /dev/pts "$devpts_fs" - mount -t proc proc "$proc_fs" - mount --bind /sys "$sys_fs" - - capsh --drop=cap_setfcap "--chroot=$ROOTFS_DIR/" -- "$@" - - umount "$sys_fs" - umount "$proc_fs" - umount "$devpts_fs" - umount "$dev_fs" -} - export -f unmount export -f unmount_image -export -f on_chroot