File: setup-host

package info (click to toggle)
passenger 6.1.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 50,788 kB
  • sloc: cpp: 589,292; ruby: 43,761; ansic: 27,742; javascript: 5,948; python: 1,158; sh: 1,012; makefile: 51
file content (65 lines) | stat: -rwxr-xr-x 2,103 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash
set -eo pipefail

SELFDIR=$(dirname "$0")
SELFDIR=$(cd "$SELFDIR" && pwd)
PASSENGER_ROOT=$(cd "$SELFDIR/../.." && pwd)
# shellcheck source=lib/functions.sh
source "$SELFDIR/lib/functions.sh"
cd "$PASSENGER_ROOT"

header "Setting up stuff on the host"

autodetect_environment
sanity_check_environment
echo

if [[ "$OS" = macos && "$1" = "" ]]; then
	echo "Usage: ./dev/ci/setup-host <TEST NAME>" >&2
	exit 1
fi

if [ "${CI:-false}" = "true" ]; then
	# Relax permissions. Necessary for unit tests which test permissions.
	header2 "Relaxing file permissions"
	echo "+ Setting umask"
	umask u=rwx,g=rx,o=rx
	run chmod g+rx,o+rx .
	echo "+ chmodding files"
	find ./* -type f -print0 | xargs -0 -n 512 chmod g+r,o+r
	echo "+ chmodding directories"
	find ./* -type d -print0 | xargs -0 -n 512 chmod g+rx,o+rx

	# Create this file now because otherwise it would be owned by root,
	# which CI runner cannot remove.
	run touch test/test.log

        if [ "${GITHUB_ACTIONS:-false}" = "true" ] && [ "$OS" = "macos" ]; then
            brew update
            brew install ccache
            sudo security authorizationdb write com.apple.trust-settings.admin allow
            sudo security add-trusted-cert -d -r trustRoot -p codeSign -k /Library/Keychains/System.keychain "$PASSENGER_ROOT/dev/ci/Certificates.cer"
            sudo security import "$PASSENGER_ROOT/dev/ci/Developer.key" -k /Library/Keychains/System.keychain -t priv -A
            sudo security import "$PASSENGER_ROOT/dev/ci/Developer.pub" -k /Library/Keychains/System.keychain -t pub -A
        fi

	echo
fi

header2 "Creating cache directories"
run mkdir -p "$CACHE_DIR"
run mkdir -p "$CACHE_DIR/bundle"
run mkdir -p "$CACHE_DIR/ccache"
run mkdir -p "$CACHE_DIR/npm"
echo

# Directory must exist so that workflow can upload artifacts.
header2 "Creating buildout directory"
run mkdir -p buildout buildout/testlogs
echo

if [[ "$OS" = macos ]]; then
	export CI_COMMAND="./dev/ci/setup-host $*"
	exec "$PASSENGER_ROOT/dev/ci/scripts/debug-console-wrapper.sh" \
		"$PASSENGER_ROOT/dev/ci/scripts/setup-host-natively.sh" "$@"
fi