blob: 7ca2b185b98d01c83eb94ac2327206dcc88b8ba0 (
plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# Copyright (c) 2017-2019 Cisco and/or its affiliates.
# 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.
#!/bin/bash
set -euxo pipefail
SCRIPT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
APT_PATH=`which apt-get` || true
apt_get=${APT_PATH:-"/usr/local/bin/apt-get"}
PACKAGECLOUD_RELEASE_REPO_DEB="https://packagecloud.io/install/repositories/fdio/release/script.deb.sh"
PACKAGECLOUD_RELEASE_REPO_RPM="https://packagecloud.io/install/repositories/fdio/release/script.rpm.sh"
VPP_GIT_REPO="https://git.fd.io/vpp"
VPP_BRANCH="stable/1901"
VPP_VERSION_DEB="19.01-release"
VPP_VERSION_RPM="19.01-release.x86_64"
BUILD_TOOLS_UBUNTU="build-essential doxygen"
LIBSSL_LIBEVENT_UBUNTU="libevent-dev libssl-dev"
DEPS_UBUNTU="libparc-dev libasio-dev vpp-dev=${VPP_VERSION_DEB} vpp-lib=${VPP_VERSION_DEB}"
# BUILD_TOOLS_GROUP_CENTOS="'Development Tools'"
DEPS_CENTOS="vpp-devel-${VPP_VERSION_RPM} vpp-lib-${VPP_VERSION_RPM} libparc-devel asio-devel centos-release-scl devtoolset-7"
LATEST_EPEL_REPO="http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm"
install_cmake() {
if ! grep -q "8.8.8.8" /etc/resolv.conf; then
echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf
fi
cat /etc/resolv.conf
CMAKE_INSTALL_SCRIPT_URL="https://cmake.org/files/v3.8/cmake-3.8.0-Linux-x86_64.sh"
CMAKE_INSTALL_SCRIPT="/tmp/install_cmake.sh"
curl ${CMAKE_INSTALL_SCRIPT_URL} > ${CMAKE_INSTALL_SCRIPT}
sudo mkdir -p /opt/cmake
sudo bash ${CMAKE_INSTALL_SCRIPT} --skip-license --prefix=/opt/cmake
export PATH=/opt/cmake/bin:${PATH}
}
# Parameters:
# $1 = Distribution id
# $2 = Distribution codename
#
setup_fdio_repo() {
DISTRIB_ID=${1}
if [ "${DISTRIB_ID}" == "ubuntu" ]; then
curl -s ${PACKAGECLOUD_RELEASE_REPO_DEB} | sudo bash
elif [ "${DISTRIB_ID}" == "centos" ]; then
curl -s ${PACKAGECLOUD_RELEASE_REPO_RPM} | sudo bash
curl ${LATEST_EPEL_REPO} > epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm || true
rm epel-release-latest-7.noarch.rpm
else
echo "Distribution ${DISTRIB_ID} is not supported"
exit -1
fi
}
MEMIF_HOME=""
build_libmemif_static() {
git clone ${VPP_GIT_REPO} -b ${VPP_BRANCH} vpp
pushd vpp
sed 's/SHARED/STATIC/g' src/cmake/library.cmake -i
mkdir -p build-root/build-libmemif && pushd build-root/build-libmemif
cmake ../../extras/libmemif/ -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_INSTALL_PREFIX=.
make install
MEMIF_HOME="$(pwd)"
popd
popd
}
setup() {
# Figure out what system we are running on
if [ -f /etc/os-release ]; then
. /etc/os-release
else
echo "ERROR: System configuration not recognized. Build failed"
exit -1
fi
DISTRIB_ID=${ID}
echo DISTRIBUTION: ${PRETTY_NAME}
echo ARCHITECTURE: $(uname -m)
install_cmake
setup_fdio_repo ${DISTRIB_ID}
if [ "${DISTRIB_ID}" == "ubuntu" ]; then
sudo ${apt_get} update || true
fi
# Install dependencies
if [ ${DISTRIB_ID} == "ubuntu" ]; then
echo ${BUILD_TOOLS_UBUNTU} ${DEPS_UBUNTU} | xargs sudo ${apt_get} install -y --allow-unauthenticated --no-install-recommends
elif [ ${DISTRIB_ID} == "centos" ]; then
# echo ${BUILD_TOOLS_GROUP_CENTOS} | xargs sudo yum groupinstall -y --nogpgcheck
echo ${DEPS_CENTOS} | xargs sudo yum install -y --nogpgcheck
sudo yum install devtoolset-7
scl enable devtoolset-7 bash
c++ --version
CXX_COMPILER="/opt/rh/devtoolset-7/root/usr/bin/c++"
CC_COMPILER="/opt/rh/devtoolset-7/root/usr/bin/cc"
${CXX_COMPILER} --version
${CC_COMPILER} --version
export CC=${CC_COMPILER} CXX=${CXX_COMPILER}
build_libmemif_static
fi
# do nothing but check compiler version
c++ --version
}
# Parameters:
# $1 = Package name
#
build_package() {
setup
echo "*******************************************************************"
echo "********************* STARTING PACKAGE BUILD **********************"
echo "*******************************************************************"
# Make the package
mkdir -p build && pushd build
pwd
rm -rf *
cmake -DCMAKE_INSTALL_PREFIX=/usr ${SCRIPT_PATH}/..
make package
rm -rf libtransport
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_HICNPLUGIN=ON \
-DBUILD_LIBTRANSPORT=ON \
-DLIBMEMIF_HOME=${MEMIF_HOME} \
${SCRIPT_PATH}/..
make package
find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
rm *Unspecified*
# Make the doc
cmake -DBUILD_HICNPLUGIN=OFF \
-DBUILD_LIBTRANSPORT=OFF \
-DBUILD_UTILS=OFF \
-DBUILD_HICNLIGHT=OFF \
${SCRIPT_PATH}/..
make doc
popd
echo "*******************************************************************"
echo "***************** BUILD COMPLETED SUCCESSFULLY *******************"
echo "*******************************************************************"
}
push_doc() {
DOCS_REPO_URL=${DOCS_REPO_URL:-"https://nexus.fd.io/content/sites/site"}
PROJECT_PATH=${PROJECT_PATH:-"io/fd/hicn"}
DOC_FILE=${DOC_FILE:-"hicn.docs.zip"}
DOC_DIR=${DOC_DIR:-"build/lib/doc/html"}
SITE_DIR=${SITE_DIR:-"build/doc/deploy-site/"}
RESOURCES_DIR=${RESOURCES_DIR:-${SITE_DIR}/src/site/resources}
MVN=${MVN:-"/opt/apache/maven/bin/mvn"}
VERSION=${VERSION:-$(git describe --abbrev=0 | egrep -o "([0-9]{1,}\.)+[0-9]{1,}")}
echo "Current directory: $(pwd)"
ls -la
. /etc/os-release
# if [[ ${JOB_NAME} == *merge* ]]; then
if [[ ${JOB_NAME} == *merge* ]] && [[ ${ID} == "ubuntu" ]] && [[ ${UBUNTU_CODENAME} == "xenial" ]]; then
mkdir -p $(dirname ${RESOURCES_DIR})
mv -f ${DOC_DIR} ${RESOURCES_DIR}
cd ${SITE_DIR}
find . -type f '(' -name '*.md5' -o -name '*.dot' -o -name '*.map' ')' -delete
cat > pom.xml << EOF
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.fd.hicn</groupId>
<artifactId>docs</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<properties>
<generateReports>false</generateReports>
</properties>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>2.9</version>
</extension>
</extensions>
</build>
<distributionManagement>
<site>
<id>fdio-site</id>
<url>dav:${DOCS_REPO_URL}/${PROJECT_PATH}/${VERSION}</url>
</site>
</distributionManagement>
</project>
EOF
${MVN} site:site site:deploy -gs "${GLOBAL_SETTINGS_FILE}" -s "${SETTINGS_FILE}" -T 4C
cd -
fi
}
build_package
push_doc
exit 0
|