Skip to content

Commit

Permalink
Change from bash to sh (#5468)
Browse files Browse the repository at this point in the history
* Removes bash as a dependency
* Better compliance to POSIX
  • Loading branch information
j8r authored and RX14 committed Jan 2, 2018
1 parent 78ccf91 commit 80f94f3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.release
Expand Up @@ -11,4 +11,4 @@ RUN \

WORKDIR /opt/crystal

CMD ["bash"]
CMD ["sh"]
6 changes: 3 additions & 3 deletions Makefile
Expand Up @@ -29,8 +29,8 @@ SOURCES := $(shell find src -name '*.cr')
SPEC_SOURCES := $(shell find spec -name '*.cr')
FLAGS := $(if $(release),--release )$(if $(stats),--stats )$(if $(progress),--progress )$(if $(threads),--threads $(threads) )$(if $(debug),-d )$(if $(static),--static )
SPEC_FLAGS := $(if $(verbose),-v )$(if $(junit_output),--junit_output $(junit_output) )
EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=`pwd`/src)
SHELL = bash
EXPORTS := $(if $(release),,CRYSTAL_CONFIG_PATH=$PWD/src)
SHELL = sh
LLVM_CONFIG_FINDER := \
[ -n "$(LLVM_CONFIG)" ] && command -v "$(LLVM_CONFIG)" || \
command -v llvm-config-4.0 || command -v llvm-config40 || \
Expand Down Expand Up @@ -118,7 +118,7 @@ $(O)/crystal: $(DEPS) $(SOURCES)
$(BUILD_PATH) $(EXPORTS) ./bin/crystal build $(FLAGS) -o $@ src/compiler/crystal.cr -D without_openssl -D without_zlib

$(LLVM_EXT_OBJ): $(LLVM_EXT_DIR)/llvm_ext.cc
$(CXX) -c $(CXXFLAGS) -o $@ $< `$(LLVM_CONFIG) --cxxflags`
$(CXX) -c $(CXXFLAGS) -o $@ $< $(shell $(LLVM_CONFIG) --cxxflags)

$(LIB_CRYSTAL_TARGET): $(LIB_CRYSTAL_OBJS)
$(AR) -rcs $@ $^
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Expand Up @@ -15,7 +15,7 @@ Vagrant.configure("2") do |config|
c.vm.box = "ubuntu/#{box_name}"

c.vm.provision :shell, inline: %(
curl -s https://dist.crystal-lang.org/apt/setup.sh | bash
curl -s https://dist.crystal-lang.org/apt/setup.sh | sh
apt-get install -y crystal git libgmp3-dev zlib1g-dev libedit-dev libxml2-dev libssl-dev libyaml-dev libreadline-dev g++
curl -s https://crystal-lang.s3.amazonaws.com/llvm/llvm-3.5.0-1-linux-`uname -m`.tar.gz | tar xz -C /opt
echo 'export LIBRARY_PATH="/opt/crystal/embedded/lib"' > /etc/profile.d/crystal.sh
Expand Down
38 changes: 20 additions & 18 deletions bin/ci
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

fail() {
echo "${@}" >&2
Expand Down Expand Up @@ -90,8 +90,8 @@ build() {
}

deploy() {
export CURRENT_TAG=`git describe --tags --exact-match 2> /dev/null`
export GIT_VERSION=`git describe --tags --long --always 2>/dev/null`
export CURRENT_TAG=$(git describe --tags --exact-match 2> /dev/null)
export GIT_VERSION=$(git describe --tags --long --always 2>/dev/null)
on_deploy 'echo $GIT_VERSION > docs/revision.txt'

on_deploy aws s3 sync docs/ s3://crystal-api/api/$TRAVIS_BRANCH
Expand Down Expand Up @@ -162,32 +162,34 @@ with_build_env() {
on_linux docker run \
--rm -t \
-u $(id -u) \
-v $(pwd):/mnt \
-v $PWD:/mnt \
-w /mnt \
-e LIBRARY_PATH="${ARCH_LIBRARY_PATH:-/usr/lib/crystal/lib/}" \
-e CRYSTAL_CACHE_DIR="/tmp/crystal" \
"jhass/crystal-build-$ARCH" \
"$ARCH_CMD" /bin/bash -c "'$command'"
"$ARCH_CMD" /bin/sh -c "'$command'"

on_osx PATH="/usr/local/opt/llvm/bin:\$PATH" \
CRYSTAL_CACHE_DIR="/tmp/crystal" \
/bin/bash -c "'$command'"
/bin/sh -c "'$command'"

}

usage() {
echo -e "bin/ci [-h|--help] command [parameter ...]"
echo -e ""
echo -e "Helper script to prepare and run the testsuite on Travis CI."
echo -e ""
echo -e "Commands:"
echo -e " prepare_system setup any necessaries repositories etc."
echo -e " prepare_build download and extract any dependencies needed for the build"
echo -e " build run specs, build crystal, run format check, build samples, build the docs"
echo -e " deploy deploy the docs"
echo -e " with_build_env command run command in the build environment"
echo -e " help display this"
echo -e ""
cat <<EOF
bin/ci [-h|--help] command [parameter ...]
Helper script to prepare and run the testsuite on Travis CI.
Commands:
prepare_system setup any necessaries repositories etc.
prepare_build download and extract any dependencies needed for the build
build run specs, build crystal, run format check, build samples, build the docs
deploy deploy the docs
with_build_env command run command in the build environment
help display this
EOF
}

command="$1"
Expand Down
11 changes: 4 additions & 7 deletions bin/crystal
Expand Up @@ -37,7 +37,7 @@ _resolve_symlinks() {

local dir_context path
path=$(readlink -- "$1")
if [ $? -eq 0 ]; then
if [ $? = 0 ]; then
dir_context=$(dirname -- "$1")
_resolve_symlinks "$(_prepend_dir_context_if_necessary "$dir_context" "$path")" "$@"
else
Expand Down Expand Up @@ -141,16 +141,13 @@ CRYSTAL_DIR="$CRYSTAL_ROOT/.build"
export CRYSTAL_PATH=$CRYSTAL_ROOT/src:lib
export CRYSTAL_HAS_WRAPPER=true

if [ -x "$CRYSTAL_DIR/crystal" ]
then
if [ -x "$CRYSTAL_DIR/crystal" ]; then
__warning_msg "Using compiled compiler at \`.build/crystal'"
exec "$CRYSTAL_DIR/crystal" "$@"
elif ! command -v crystal > /dev/null
then
elif ! command -v crystal > /dev/null; then
__error_msg 'You need to have a crystal executable in your path!'
exit 1
elif [ "$(command -v crystal)" = "$SCRIPT_PATH" ] || [ "$(command -v crystal)" = "bin/crystal" ]
then
elif [ "$(command -v crystal)" = "$SCRIPT_PATH" ] || [ "$(command -v crystal)" = "bin/crystal" ]; then
export PATH="$(remove_path_item "$(remove_path_item "$PATH" "$SCRIPT_ROOT")" "bin")"
exec "$SCRIPT_PATH" "$@"
else
Expand Down

0 comments on commit 80f94f3

Please sign in to comment.