summaryrefslogtreecommitdiffstats
path: root/build/make_repo.sh
diff options
context:
space:
mode:
authorshuai chen <chenshuai@huawei.com>2016-07-07 03:45:29 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-07-07 03:45:29 +0000
commit86a45414358a9e6f36467621e5f0c24437433896 (patch)
tree9c95d901ee6c91b57287218c06d73516021cb5dd /build/make_repo.sh
parentff20b4011edfe706bcc605ca30d1f618a889a027 (diff)
parent0f53761bed746e2217e4d088d80b6cc5ddd75fd7 (diff)
Merge "make_pip_repo auto download package dependency"
Diffstat (limited to 'build/make_repo.sh')
-rwxr-xr-xbuild/make_repo.sh85
1 files changed, 80 insertions, 5 deletions
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 -
}