]> git.proxmox.com Git - ceph.git/blame - ceph/qa/setup-chroot.sh
bump version to 18.2.2-pve1
[ceph.git] / ceph / qa / setup-chroot.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
2
3die() {
4 echo ${@}
5 exit 1
6}
7
8usage()
9{
10 cat << EOF
11$0: sets up a chroot environment for building the ceph server
12usage:
13-h Show this message
14
15-r [install_dir] location of the root filesystem to install to
16 example: -r /images/sepia/
17
18-s [src_dir] location of the directory with the source code
19 example: -s ./src/ceph
20EOF
21}
22
23cleanup() {
24 umount -l "${INSTALL_DIR}/mnt/tmp"
25 umount -l "${INSTALL_DIR}/proc"
26 umount -l "${INSTALL_DIR}/sys"
27}
28
29INSTALL_DIR=
30SRC_DIR=
31while getopts “hr:s:” OPTION; do
32 case $OPTION in
33 h) usage; exit 1 ;;
34 r) INSTALL_DIR=$OPTARG ;;
35 s) SRC_DIR=$OPTARG ;;
36 ?) usage; exit
37 ;;
38 esac
39done
40
41[ $EUID -eq 0 ] || die "This script uses chroot, which requires root permissions."
42
43[ -d "${INSTALL_DIR}" ] || die "No such directory as '${INSTALL_DIR}'. \
44You must specify an install directory with -r"
45
46[ -d "${SRC_DIR}" ] || die "no such directory as '${SRC_DIR}'. \
47You must specify a source directory with -s"
48
49readlink -f ${SRC_DIR} || die "readlink failed on ${SRC_DIR}"
50ABS_SRC_DIR=`readlink -f ${SRC_DIR}`
51
52trap cleanup INT TERM EXIT
53
54mount --bind "${ABS_SRC_DIR}" "${INSTALL_DIR}/mnt/tmp" || die "bind mount failed"
55mount -t proc none "${INSTALL_DIR}/proc" || die "mounting proc failed"
56mount -t sysfs none "${INSTALL_DIR}/sys" || die "mounting sys failed"
57
58echo "$0: starting chroot."
59echo "cd /mnt/tmp before building"
60echo
61chroot ${INSTALL_DIR} env HOME=/mnt/tmp /bin/bash
62
63echo "$0: exiting chroot."
64
65exit 0