Files

95 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -e
SELFDIR=`dirname "$0"`
SELFDIR=`cd "$SELFDIR" && pwd`
source "$SELFDIR/../shared/library.sh"
RUNTIME_DIR=
ARCHITECTURE=
INITIALIZE=true
function usage()
{
echo "Usage: ./setup-runtime [options] <RUNTIME DIR>"
echo "Sets up the Traveling Ruby build system's runtime."
echo
echo "Options:"
echo " -a NAME Architecture to setup (x86, x86_64)"
echo " -r VERSION Ruby version to setup"
echo " -i Only initialize chroot environment"
echo " -I Do not initialize chroot environment"
echo " -h Show this help"
}
function parse_options()
{
local OPTIND=1
local opt
while getopts "a:r:iIh" opt; do
case "$opt" in
a)
ARCHITECTURE=$OPTARG
;;
r)
RUBY_VERSION=$OPTARG
;;
i)
INITIALIZE=true
DOWNLOAD_RUBY=false
;;
I)
INITIALIZE=false
;;
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
if [[ "$ARCHITECTURE" = "" ]]; then
echo "ERROR: please specify an architecture with -a."
exit 1
fi
if [[ "$RUBY_VERSION" = "" ]]; then
echo "ERROR: please specify a Ruby version with -r."
exit 1
fi
}
parse_options "$@"
RUNTIME_DIR=`cd "$RUNTIME_DIR" && pwd`
header "Preparing"
run mkdir -p "$RUNTIME_DIR/mock"
exec docker run \
--rm \
--privileged \
-v "$SELFDIR/internal:/system:ro" \
-v "$SELFDIR/../shared:/system_shared:ro" \
-v "$RUNTIME_DIR/mock:/var/lib/mock" \
-e "ARCHITECTURE=$ARCHITECTURE" \
-e "RUBY_VERSION=$RUBY_VERSION" \
-e "INITIALIZE=$INITIALIZE" \
phusion/traveling-ruby-builder \
/system/my_init --quiet --skip-runit --skip-startup-files -- \
/system/setup-runtime