<commit_before>#!/bin/bash
set -e
ROOTDIR=`dirname "$0"`
ROOTDIR=`cd "$ROOTDIR/../.." && pwd`
source "$ROOTDIR/internal/lib/library.sh"

COMPILE_CONCURRENCY=${COMPILE_CONCURRENCY:-2}

if ls /output/*enterprise* >/dev/null 2>/dev/null; then
	if [[ ! -e /etc/passenger-enterprise-license ]]; then
		echo "ERROR: please set a Passenger Enterprise license key with -e."
		exit 1
	fi
fi

echo
header "Installing packages..."
# Allows installing passenger-doc
echo '%_excludedocs 0' > /etc/rpm/macros.imgcreate
run sed -i 's/nodocs//' /etc/yum.conf
run yum install -y /output/*.x86_64.rpm /output/*.noarch.rpm

echo
header "Preparing Passenger source code..."
# /passenger is mounted read-only, but 'rake' may have to create files, e.g.
# to generate documentation files. So we copy it to a temporary directory
# which is writable.
run rm -rf /tmp/passenger
if [[ -e /passenger/.git ]]; then
	run setuser app mkdir /tmp/passenger
	echo "+ cd /passenger"
	cd /passenger
	echo "+ Git copying to /tmp/passenger"
	(
		set -o pipefail
		git archive --format=tar HEAD | setuser app tar -C /tmp/passenger -x
		submodules=`git submodule status | awk '{ print $2 }'`
		for submodule in $submodules; do
			echo "+ Git copying submodule $submodule"
			pushd $submodule >/dev/null
			mkdir -p /tmp/passenger/$submodule
			git archive --format=tar HEAD | setuser app tar -C /tmp/passenger/$submodule -x
			popd >/dev/null
		done
	)
	if [[ $? != 0 ]]; then
		exit 1
	fi
else
	run setuser app cp -R /passenger /tmp/passenger
fi
echo "+ cd /tmp/passenger"
cd /tmp/passenger

echo
header "Preparing system..."
export PATH=/usr/lib64/ccache:$PATH
export CCACHE_DIR=/cache/test-$DISTRIBUTION/ccache
export CCACHE_COMPRESS=1
export CCACHE_COMPRESS_LEVEL=3
run setuser app mkdir -p $CCACHE_DIR
echo "+ Updating /etc/hosts"
cat /system/internal/test/misc/hosts.conf >> /etc/hosts
APACHE_VERSION=`rpm -qi httpd | grep Version | awk '{ print $3 }'`
if ruby -e 'exit(ARGV[0] >= ARGV[1])' "$APACHE_VERSION" 2.4; then
	run cp /system/internal/test/apache/apache-24.conf /etc/httpd/conf.d/
	run chmod 644 /etc/httpd/conf.d/apache-24.conf
else
	run cp /system/internal/test/apache/apache-pre-24.conf /etc/httpd/conf.d/<commit_msg>Fix Node.js integration tests on generic_app_support branch<commit_after>#!/bin/bash
set -e
ROOTDIR=`dirname "$0"`
ROOTDIR=`cd "$ROOTDIR/../.." && pwd`
source "$ROOTDIR/internal/lib/library.sh"

COMPILE_CONCURRENCY=${COMPILE_CONCURRENCY:-2}

if ls /output/*enterprise* >/dev/null 2>/dev/null; then
	if [[ ! -e /etc/passenger-enterprise-license ]]; then
		echo "ERROR: please set a Passenger Enterprise license key with -e."
		exit 1
	fi
fi

echo
header "Installing packages..."
# Allows installing passenger-doc
echo '%_excludedocs 0' > /etc/rpm/macros.imgcreate
run sed -i 's/nodocs//' /etc/yum.conf
run yum install -y /output/*.x86_64.rpm /output/*.noarch.rpm

echo
header "Preparing Passenger source code..."
# /passenger is mounted read-only, but 'rake' may have to create files, e.g.
# to generate documentation files. So we copy it to a temporary directory
# which is writable.
run rm -rf /tmp/passenger
if [[ -e /passenger/.git ]]; then
	run setuser app mkdir /tmp/passenger
	echo "+ cd /passenger"
	cd /passenger
	echo "+ Git copying to /tmp/passenger"
	(
		set -o pipefail
		git archive --format=tar HEAD | setuser app tar -C /tmp/passenger -x
		submodules=`git submodule status | awk '{ print $2 }'`
		for submodule in $submodules; do
			echo "+ Git copying submodule $submodule"
			pushd $submodule >/dev/null
			mkdir -p /tmp/passenger/$submodule
			git archive --format=tar HEAD | setuser app tar -C /tmp/passenger/$submodule -x
			popd >/dev/null
		done
	)
	if [[ $? != 0 ]]; then
		exit 1
	fi
else
	run setuser app cp -R /passenger /tmp/passenger
fi
echo "+ cd /tmp/passenger"
cd /tmp/passenger

echo
header "Preparing system..."
export PATH=/usr/lib64/ccache:$PATH
export CCACHE_DIR=/cache/test-$DISTRIBUTION/ccache
export CCACHE_COMPRESS=1
export CCACHE_COMPRESS_LEVEL=3
export PASSENGER_TEST_NODE_MODULES_DIR=/tmp/passenger/node_modules
run setuser app mkdir -p $CCACHE_DIR
echo "+ Updating /etc/hosts"
cat /system/internal/test/misc/hosts.conf >> /etc/hosts
APACHE_VERSION=`rpm -qi httpd | grep Version | awk '{ print $3 }'`
if ruby -e 'exit(ARGV[0] >= ARGV[1])' "$APACHE_VERSION" 2.4; then
	run cp /system/internal/test/apache/apache-24.conf /etc/httpd/conf.d/
	run chmod 644 /etc/httpd/conf.d/apache-24.conf
else
	run cp /system/internal/test/apache/apache-pre-24.conf /etc/httpd/conf.d/
{'fraction_non_alphanumeric': 0.13790806129247168, 'fraction_numerical': 0.013324450366422385, 'mean_word_length': 3.6673575129533678, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5177829', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1627, 'n_words': 477}