f4d17450 |
#!/bin/bash
#################################################
# Title: prepare-build-root.sh #
# Date: 2014-12-12 #
# Version: 1.0 #
# Author: sharathg@vmware.com #
#################################################
set -o errexit
set -o nounset
set +h
source common.inc
PRGNAME=${0##*/} |
a4a06c39 |
|
58120db4 |
if [ $# -lt 1 ]; then
fail "${PRGNAME}: No build root specified. Usage : ${PRGNAME} <build-root>" |
f4d17450 |
fi
#Clean up our build root first
BUILDROOT=$1
PARENT=/usr/src/photon
if mountpoint ${BUILDROOT}/run >/dev/null 2>&1; then umount ${BUILDROOT}/run; fi
if mountpoint ${BUILDROOT}/sys >/dev/null 2>&1; then umount ${BUILDROOT}/sys; fi
if mountpoint ${BUILDROOT}/proc >/dev/null 2>&1; then umount ${BUILDROOT}/proc; fi |
6eae06bc |
if mountpoint ${BUILDROOT}/dev >/dev/null 2>&1; then umount -R ${BUILDROOT}/dev; fi |
f8176e04 |
|
2689a7f2 |
cp /etc/resolv.conf ${BUILDROOT}/etc/
|
45e37dfb |
if [ ${EUID} -eq 0 ] ; then |
f4d17450 |
# Ommited in the filesystem.spec file - not needed for booting |
b87a6546 |
[ -e ${BUILDROOT}/dev/console ] || mknod -m 600 ${BUILDROOT}/dev/console c 5 1
[ -e ${BUILDROOT}/dev/null ] || mknod -m 666 ${BUILDROOT}/dev/null c 1 3
[ -e ${BUILDROOT}/dev/random ] || mknod -m 444 ${BUILDROOT}/dev/random c 1 8
[ -e ${BUILDROOT}/dev/urandom ] || mknod -m 444 ${BUILDROOT}/dev/urandom c 1 9 |
f4d17450 |
|
45e37dfb |
chown -R 0:0 ${BUILDROOT}/* || fail "${PRGNAME}: Changing ownership: ${BUILDROOT}: FAILURE" |
f4d17450 |
#
# Mount kernel filesystem
# |
6eae06bc |
if ! mountpoint ${BUILDROOT}/dev >/dev/null 2>&1; then mount --rbind /dev ${BUILDROOT}/dev; mount --make-rslave ${BUILDROOT}/dev; fi |
45e37dfb |
if ! mountpoint ${BUILDROOT}/proc >/dev/null 2>&1; then mount -t proc proc ${BUILDROOT}/proc; fi
if ! mountpoint ${BUILDROOT}/sys >/dev/null 2>&1; then mount -t sysfs sysfs ${BUILDROOT}/sys; fi
if ! mountpoint ${BUILDROOT}/run >/dev/null 2>&1; then mount -t tmpfs tmpfs ${BUILDROOT}/run; fi
if [ -h ${BUILDROOT}/dev/shm ]; then mkdir -pv ${BUILDROOT}/$(readlink ${BUILDROOT}/dev/shm); fi
fi
|
f4d17450 |
exit 0 |