summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorQiLiang <liangqi1@huawei.com>2016-07-05 22:35:05 +0800
committerQiLiang <liangqi1@huawei.com>2016-07-06 19:44:12 +0800
commit0f53761bed746e2217e4d088d80b6cc5ddd75fd7 (patch)
treecd65853ab9ca127a495199a6c123f999cab91d7b /build
parent780256c594ade62a006b5bf740f868714a60ac8e (diff)
make_pip_repo auto download package dependency
JIRA: COMPASS-427 Change-Id: If62736cc9ee7ad3d44be6b688cc52d84cf94cd5d Signed-off-by: QiLiang <liangqi1@huawei.com>
Diffstat (limited to 'build')
-rw-r--r--build/build.conf7
-rwxr-xr-xbuild/make_repo.sh85
2 files changed, 85 insertions, 7 deletions
diff --git a/build/build.conf b/build/build.conf
index 6c1d3d30..9ad99add 100644
--- a/build/build.conf
+++ b/build/build.conf
@@ -39,7 +39,7 @@ export SPECIAL_DEBIAN_PACKAGE=${SPECIAL_DEBIAN_PACKAGE-$PACKAGE_URL/debian-packa
export KVMFORNFV=${kvmfornfv:-https://gerrit.opnfv.org/gerrit/p/kvmfornfv.git}
-export PIP_CONF="https://bootstrap.pypa.io/ez_setup.py \
+export SPECIAL_PIP_PACKAGE="https://bootstrap.pypa.io/ez_setup.py \
https://pypi.python.org/packages/source/s/setuptools/setuptools-18.2.zip \
https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz \
https://pypi.python.org/packages/source/a/ansible/ansible-1.9.2.tar.gz \
@@ -107,5 +107,8 @@ export PIP_CONF="https://bootstrap.pypa.io/ez_setup.py \
https://pypi.python.org/packages/41/40/0c951f9c78a9be150b432ff50700c3b8d1cd3ef1ec53f00d08b2a7ecc64e/oslo.concurrency-3.11.0.tar.gz \
https://pypi.python.org/packages/61/b9/74514d774df110799ff2b100979de6180ead1d5eec6fa15c52e6299361ea/oslo.service-1.12.0.tar.gz \
https://pypi.python.org/packages/9f/ec/d8bf0623d7d940c09052368ee859f726410e54b16b13f477ac0e70416de6/neutron-lib-0.2.0.tar.gz \
- https://pypi.python.org/packages/0d/af/8ccfb73834a6ddf9d57ecac61466557b7ca0722620bbb16d2d069ce312db/networking-odl-2.0.0.tar.gz \
https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.4.2.tar.gz "
+
+export PIP_PACKAGE="https://pypi.python.org/packages/0d/af/8ccfb73834a6ddf9d57ecac61466557b7ca0722620bbb16d2d069ce312db/networking-odl-2.0.0.tar.gz \
+ https://pypi.python.org/packages/90/4f/74b730294de1db393e3e82211b5d2115f9a763849abca7d014348a550d2a/oslosphinx-4.5.0.tar.gz"
+
diff --git a/build/make_repo.sh b/build/make_repo.sh
index c9c70d4c..55ffbf1c 100755
--- a/build/make_repo.sh
+++ b/build/make_repo.sh
@@ -167,18 +167,93 @@ function make_repo()
sudo docker rmi -f ${image_id}
}
+function _try_fetch_dependency()
+{
+ local dir_name=''
+ if [ -f $1 ];then
+ case $1 in
+ *.tar.bz2)
+ tar xjf $1
+ dir_name="$(basename $1 .tar.bz2)"
+ ;;
+ *.tar.gz)
+ tar xzf $1
+ dir_name="$(basename $1 .tar.gz)"
+ ;;
+ *.bz2)
+ bunzip2 $1
+ dir_name="$(basename $1 .bz2)"
+ ;;
+ *.rar)
+ unrar e $1
+ dir_name="$(basename $1 .rar)"
+ ;;
+ *.gz)
+ gunzip $1
+ dir_name="$(basename $1 .gz)"
+ ;;
+ *.tar)
+ tar xf $1
+ dir_name="$(basename $1 .tar)"
+ ;;
+ *.tbz2)
+ tar xjf $1
+ dir_name="$(basename $1 .tbz2)"
+ ;;
+ *.tgz)
+ tar xzf $1
+ dir_name="$(basename $1 .tgz)"
+ ;;
+ *.zip)
+ gunzip $1
+ dir_name="$(basename $1 .zip)"
+ ;;
+ *)
+ echo "'$1' cannot be extract()"
+ return -1
+ ;;
+ esac
+ else
+ echo "'$1' is not a valid file"
+ return -1
+ fi
+
+ if [ ! -f ${dir_name}/requirements.txt ]; then
+ echo "${dir_name}/requirements.txt does not exist"
+ return -1
+ fi
+
+ pip install --download=$2 -r ${dir_name}/requirements.txt
+
+ rm -rf $dir_name
+}
+
+function try_fetch_dependency()
+{
+ cd $3
+ _try_fetch_dependency $1/$2 $1
+ cd -
+}
+
function make_pip_repo()
{
source $WORK_PATH/build/build.conf
+ local pip_path=$WORK_PATH/work/repo/pip
+ local pip_tmp_path=$WORK_PATH/work/repo/pip_tmp
- if [[ $PIP_CONF == "" ]]; then
- return
- fi
+ for i in $SPECIAL_PIP_PACKAGE; do
+ curl --connect-timeout 10 -o $pip_path/`basename $i` $i
+ done
- for i in $PIP_CONF; do
- curl --connect-timeout 10 -o $WORK_PATH/work/repo/pip/`basename $i` $i
+ mkdir -p $pip_tmp_path
+
+ for i in $PIP_PACKAGE; do
+ curl --connect-timeout 10 -o $pip_path/$(basename $i) $i
+ try_fetch_dependency $pip_path $(basename $i) $pip_tmp_path
done
+ rm -rf $pip_tmp_path
+
cd $WORK_PATH/work/repo; tar -zcvf pip.tar.gz ./pip; cd -
}