forked from openstack-archive/fuel-main
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-build-env.sh
executable file
·125 lines (109 loc) · 4.42 KB
/
prepare-build-env.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
#!/bin/bash -x
# Copyright 2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# This script will install all the required packages necessary for
# building a Fuel ISO.
# - We need not try to install rubygems on trusty, because it doesn't exists
# - We also should use multistrap version 2.1.6 from devops mirror
DISTRO=$(lsb_release -c -s)
case "${DISTRO}" in
trusty)
GEMPKG="ruby ruby-dev"
# we need multistrap version 2.1.6, let's install it from devops mirror
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D5A05778
echo "deb http://mirror.fuel-infra.org/devops/ubuntu/ ./" | sudo tee /etc/apt/sources.list.d/fuel-devops.list
# be sure, that we will not update multistrap in future
sudo tee /etc/apt/preferences.d/fuel-pin-300 <<EOF
Package: *multistrap*
Pin: version 2.1.6*
Pin-Priority: 1000
EOF
sudo apt-get update && sudo apt-get -y install nodejs nodejs-legacy npm
;;
precise)
GEMPKG="ruby ruby-dev rubygems"
# be sure, we will use nodejs from chris-lea
sudo tee /etc/apt/preferences.d/fuel-pin-300 <<EOF
Package: *nodejs*
Pin: release o=LP-PPA-chris-lea-node.js
Pin-Priority: 1000
EOF
# we need to use add-apt-repository command
sudo apt-get -y install software-properties-common python-software-properties
if hash nodejs 2> /dev/null; then
echo "Nodejs found, checking if it has proper version"
# Install correct nodejs from chris-lea
if ! dpkg-query -W -f='${Version}\n' nodejs | grep -q "1chl1"; then
# we don't have nodejs from chris-lea, need remove previous version
sudo apt-get -y remove nodejs npm
# install chris-lea repo, the package itself will be installed later
sudo add-apt-repository -y ppa:chris-lea/node.js
fi
else
# just add repository, package nodejs will be installed from
sudo add-apt-repository -y ppa:chris-lea/node.js
fi
sudo apt-get update && sudo apt-get -y install nodejs
;;
*)
echo "We currently doesn't support building on your distribution ${DISTRO}"
exit 1;
esac
# Check if docker is installed
if hash docker 2>/dev/null; then
echo "Docker binary found, checking if service is running..."
ps cax | grep docker > /dev/null
if [ $? -eq 0 ]; then
echo "Docker is running."
else
echo "Process is not running, starting it..."
sudo service docker start
fi
else
# Install docker repository
# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
sudo apt-get update
sudo apt-get -y install -y apt-transport-https
fi
# Add the repository to APT sources
echo deb http://mirror.yandex.ru/mirrors/docker/ docker main | sudo tee /etc/apt/sources.list.d/docker.list
# Import the repository key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# Install docker
sudo apt-get update
sudo apt-get -y install lxc-docker
fi
# Install software
sudo apt-get update
sudo apt-get -y install build-essential make git $GEMPKG debootstrap createrepo \
python-setuptools yum yum-utils libmysqlclient-dev isomd5sum bc \
python-nose libvirt-bin python-ipaddr python-paramiko python-yaml \
python-pip kpartx extlinux unzip genisoimage multistrap \
lrzip python-daemon python-dev
sudo gem install bundler -v 1.2.1
sudo gem install builder
sudo pip install xmlbuilder jinja2 pbr
sudo npm install -g grunt-cli
sudo chown -R `whoami`.`id -gn` `npm config get cache`
# Add account to sudoers
if sudo grep "`whoami` ALL=(ALL) NOPASSWD: ALL" /etc/sudoers; then
echo "Required /etc/sudoers record found"
else
echo "Required /etc/sudoers record not found, adding it..."
echo "`whoami` ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers
fi
# Fix tmp folder ownership
[ -d ~/tmp ] && sudo chown -R `whoami`.`id -gn` ~/tmp || mkdir ~/tmp
echo "Dependency check completed, please proceed with 'make iso' command"