aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build-packages.sh128
1 files changed, 128 insertions, 0 deletions
diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh
index ae775aca9..6101e93fa 100644
--- a/scripts/build-packages.sh
+++ b/scripts/build-packages.sh
@@ -11,4 +11,132 @@
# 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"
+
+BUILD_TOOLS_UBUNTU="build-essential doxygen"
+LIBSSL_LIBEVENT_UBUNTU="libevent-dev libssl-dev"
+DEPS_UBUNTU="libparc-dev libasio-dev"
+
+# BUILD_TOOLS_GROUP_CENTOS="'Development Tools'"
+DEPS_CENTOS="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() {
+ cat /etc/resolv.conf
+ echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf
+ 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
+ else
+ echo "Distribution ${DISTRIB_ID} is not supported"
+ exit -1
+ fi
+}
+
+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}
+ 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 ${SCRIPT_PATH}/../build && pushd ${SCRIPT_PATH}/../build
+
+ rm -rf *
+ cmake -DCMAKE_INSTALL_PREFIX=/usr ..
+ make package
+
+ find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true
+
+ popd
+
+ echo "*******************************************************************"
+ echo "***************** BUILD COMPLETED SUCCESSFULLY *******************"
+ echo "*******************************************************************"
+
+ exit 0
+}
+
+pushd ${SCRIPT_PATH}/..
+build_package
+popd
+
exit 0 \ No newline at end of file