fuel-plugin-mellanox/pre_build_hook

83 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2015 Mellanox Technologies, Ltd
#
# 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.
readonly PLUGIN_DIR="$(dirname $0)"
readonly DEFAULT_REPOSITORY_HOST="10.212.14.8" #TODO: Change to MLNX public repo
if [ -z "$REPOSITORY_HOST" ]; then
REPOSITORY_HOST=$DEFAULT_REPOSITORY_HOST
fi
function download {
FILE_TYPE=$1
FILE_NAME=$2
case ${FILE_TYPE} in
'bootstrap')
PREFIX_URL=mellanox_plugin/bootstrap
BUILD_DIR=bootstrap
;;
'rpm')
PREFIX_URL=mellanox_plugin/repositories/centos/Packages
BUILD_DIR=repositories/centos/Packages
;;
'deb')
PREFIX_URL=mellanox_plugin/repositories/ubuntu
BUILD_DIR=repositories/ubuntu
;;
*)
echo "Can't download ${FILE_NAME}. File of type ${FILE_TYPE} is not supported."
exit 1
esac
URL="http://${REPOSITORY_HOST}/${PREFIX_URL}/${FILE_NAME}"
DEST_DIR="${PLUGIN_DIR}/${BUILD_DIR}"
wget ${URL} -P ${DEST_DIR}
if [ $? -ne 0 ]; then
echo "Failed fetching package from: ${URL} to ${DEST_DIR}" >&2
fi
}
function get_packages() {
file_type=$1
directory=$2
files=$3
rm -rf $directory
mkdir $directory
for f in $files; do
download $file_type $f
done
}
rpm_dir="${PLUGIN_DIR}/repositories/centos/Packages/"
rpm_files="cirros-testvm-mellanox-0.3.2-3.el6.x86_64.rpm
eswitchd-0.11-3.el6.x86_64.rpm
mlnx-ofed-fuel-2.3-2.0.6.el6.x86_64.rpm
redhat-rpm-config-9.0.3-42.el6.centos.noarch.rpm"
get_packages "rpm" "$rpm_dir" "$rpm_files"
deb_dir="${PLUGIN_DIR}/repositories/ubuntu/"
deb_files="cirros-testvm-mellanox_0.3.2-ubuntu3_amd64.deb
eswitchd_0.10-3_amd64.deb
mlnx-ofed-fuel_2.3-2.0.6_amd64.deb"
get_packages "deb" "$deb_dir" "$deb_files"
bootstrap_dir="${PLUGIN_DIR}/bootstrap/"
bootstrap_files="initramfs.img
linux
.ofed
.kernel"
get_packages "bootstrap" "$bootstrap_dir" "$bootstrap_files"