-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.sh
executable file
·131 lines (111 loc) · 4.25 KB
/
bootstrap.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
# Install standard tools
sudo apt update
sudo apt install -y \
apache2 \
apt-transport-https \
build-essential \
ca-certificates \
curl \
gcc-arm-linux-gnueabihf \
git \
vim
# Install golang
mkdir /tmp/golang
wget --progress=bar:force https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz -P /tmp/golang
sudo tar -C /usr/local -xzf /tmp/golang/go1.11.2.linux-amd64.tar.gz
{
echo ''
echo '# Add golang path'
echo 'export PATH=$PATH:/usr/local/go/bin'
} | sudo tee --append /etc/profile > /dev/null
# Install nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
###################################
# Platform specific configurations
###################################
# Install debian keys required for ubuntu xenial
if [ `lsb_release -c -s` == 'xenial' ]; then
sudo apt-get -y install debian-archive-keyring
fi
###################################
# Build environment configurations
###################################
# Configure for vagrant build environment
if [ "$USER" == 'vagrant' ]; then
echo 'Vagrant environment detected'
# Set source directory to path in synced folder
echo 'Setting source directory to Synced Folder at /vagrant/src'
SOURCE_DIR=/vagrant/src
# Set local directory for build artifacts to synced folder
echo 'Setting local directory for build artifacts at /vagrant/output'
{
echo ''
echo '# Set local directory for build artifacts'
echo 'export BUILD_ARTIFACTS_DIR=/vagrant/output'
} | sudo tee --append /etc/profile > /dev/null
# Copy github release publishing configurations
if [ -f /vagrant/.github_publish ]; then
. /vagrant/.github_publish
echo "Setting GitHub Release version to $GITHUB_RELEASE_VERSION"
{
echo ''
echo '# GitHub Release publishing configurations'
echo "export GITHUB_USERNAME=$GITHUB_USERNAME"
echo "export GITHUB_REPOSITORY=$GITHUB_REPOSITORY"
echo "export GITHUB_TOKEN=$GITHUB_TOKEN"
echo "export GITHUB_RELEASE_VERSION=$GITHUB_RELEASE_VERSION"
} | sudo tee --append /etc/profile > /dev/null
fi
# Configure for travis build environment
elif [ "$USER" == 'travis' ]; then
echo 'Travis environment detected'
# Set source directory to path where travis clones repository
echo "Setting source directory to Travis build directory at $TRAVIS_BUILD_DIR/src"
SOURCE_DIR=$TRAVIS_BUILD_DIR/src
# Set local directory for build artifacts
echo "Setting local directory for build artifacts at $HOME/output"
{
echo ''
echo '# Set local directory for build artifacts'
echo "export BUILD_ARTIFACTS_DIR=$HOME/output"
} | sudo tee --append /etc/profile > /dev/null
# Set github release from travis publishing configurations
echo "Setting GitHub Release version to `$TRAVIS_TAG | sed 's/^v//'`"
{
echo ''
echo '# GitHub Release publishing configurations'
echo "export GITHUB_RELEASE_VERSION=`echo $TRAVIS_TAG | sed 's/^v//'`"
} | sudo tee --append /etc/profile > /dev/null
# Install tools required to cross-compile cjdns in travis environment
sudo apt install -y libc6-dev-armhf-cross
# Configure for local build environment
else
# Set source directory to local path relative to this script
echo "Setting source directory to local directory at `cd "$(dirname "${BASH_SOURCE[0]}")" && pwd`/src"
SOURCE_DIR=`cd "$(dirname "${BASH_SOURCE[0]}")" && pwd`/src
# Set local directory for build artifacts
echo "Setting local directory for build artifacts at `pwd`/output"
{
echo ''
echo '# Set local directory for build artifacts'
echo "export BUILD_ARTIFACTS_DIR=`pwd`/output"
} | sudo tee --append /etc/profile > /dev/null
# Copy github release publishing configurations
if [ -f .github_publish ]; then
. .github_publish
echo "Setting GitHub Release version to $GITHUB_RELEASE_VERSION"
{
echo ''
echo '# GitHub Release publishing configurations'
echo "export GITHUB_USERNAME=$GITHUB_USERNAME"
echo "export GITHUB_REPOSITORY=$GITHUB_REPOSITORY"
echo "export GITHUB_TOKEN=$GITHUB_TOKEN"
echo "export GITHUB_RELEASE_VERSION=$GITHUB_RELEASE_VERSION"
} | sudo tee --append /etc/profile > /dev/null
fi
fi
# Copy build scripts to user home
cp -r $SOURCE_DIR/* /home/$USER/
chown -R $USER:$USER /home/$USER/*