forked from trubygems/traveling-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.sh
More file actions
executable file
·68 lines (58 loc) · 1.23 KB
/
shell.sh
File metadata and controls
executable file
·68 lines (58 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
set -e
SELFDIR=`dirname "$0"`
SELFDIR=`cd "$SELFDIR" && pwd`
RUNTIME_DIR=
function usage()
{
echo "Usage: ./shell.sh [options] <RUNTIME DIR>"
echo "Open a shell for the specified runtime directory."
echo
echo "Options:"
echo " -h Show this help"
}
function parse_options()
{
local OPTIND=1
local opt
while getopts "h" opt; do
case "$opt" in
h)
usage
exit
;;
*)
return 1
;;
esac
done
(( OPTIND += 1 )) || true
shift $OPTIND || true
RUNTIME_DIR="$1"
if [[ "$RUNTIME_DIR" = "" ]]; then
usage
exit 1
fi
if [[ ! -e "$RUNTIME_DIR" ]]; then
echo "ERROR: $RUNTIME_DIR doesn't exist."
exit 1
fi
}
parse_options "$@"
RUNTIME_DIR=`cd "$RUNTIME_DIR" && pwd`
mkdir -p "$RUNTIME_DIR/mock"
echo "Within the shell, you can the mock environment with:"
if [[ -e "$RUNTIME_DIR/mock/epel-5-i386" ]]; then
echo " /usr/bin/mock -r epel-5-i386 --shell"
else
echo " /usr/bin/mock -r epel-5-x86_64 --shell"
fi
exec docker run \
--rm -t -i \
--cap-add SYS_ADMIN --cap-add SYS_CHROOT \
-v "$SELFDIR/internal:/system:ro" \
-v "$RUNTIME_DIR/mock:/var/lib/mock" \
-v "`pwd`:/host" \
phusion/traveling-ruby-builder \
/system/my_init --quiet --skip-runit --skip-startup-files -- \
/bin/bash -l