aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarry Huang <huangxiangyu5@huawei.com>2018-11-05 16:39:11 +0800
committerHarry Huang <huangxiangyu5@huawei.com>2018-11-05 16:57:58 +0800
commita22c5801f865bd7fc5fa1c24d45a9b2db5691cce (patch)
treee722e8797823bf0c1c419f8a7c746d06b46ab867
parenta421c905989aaebe18ea961dd7d72368cb93ba86 (diff)
Modify build process
JIRA: - Remove sudo to avoid permisson issue when cleaning the environment Change-Id: I4b9f9d0c64b977fa5e3c186f52cc8ee7a7757d03 Signed-off-by: Harry Huang <huangxiangyu5@huawei.com>
-rwxr-xr-xbuild.sh12
-rw-r--r--build/parser.py43
2 files changed, 29 insertions, 26 deletions
diff --git a/build.sh b/build.sh
index d7118432..db1ce9fb 100755
--- a/build.sh
+++ b/build.sh
@@ -99,13 +99,13 @@ function download_packages()
function build_tar()
{
cd $CACHE_DIR
- sudo rm -rf compass_dists
+ sudo rm -rf compass_dists $TAR_DIR/$TAR_NAME
mkdir -p compass_dists
- sudo cp -f *.tar *.iso *.tgz compass_dists
- sudo cp $COMPASS_PATH/build/build*.yaml compass_dists
- sudo cp -rf $COMPASS_PATH/util/docker-compose ./
- sudo tar -zcf compass.tar.gz docker-compose compass_dists
- sudo mv compass.tar.gz $TAR_DIR/$TAR_NAME
+ cp -f *.tar *.iso *.tgz compass_dists
+ cp $COMPASS_PATH/build/build*.yaml compass_dists
+ cp -rf $COMPASS_PATH/util/docker-compose ./
+ tar -zcf compass.tar.gz docker-compose compass_dists
+ mv compass.tar.gz $TAR_DIR/$TAR_NAME
cd -
}
diff --git a/build/parser.py b/build/parser.py
index b0a87f93..971d2844 100644
--- a/build/parser.py
+++ b/build/parser.py
@@ -18,6 +18,14 @@ def load_env():
return cache_dir
+def exec_command(cmd, ignore_error=False):
+ rc = os.system(cmd)
+ if not ignore_error and rc != 0:
+ sys.exit(1)
+ else:
+ return rc
+
+
def get_from_cache(cache, package):
filename = package.get("name")
remotefile = list(package.get("url"))
@@ -25,13 +33,13 @@ def get_from_cache(cache, package):
localmd5file = localfile + ".md5"
print "removing local md5 file...."
cmd = "rm -f " + localmd5file
- os.system(cmd)
+ exec_command(cmd)
print "downloading remote md5 file to local...."
for file in remotefile:
remotemd5file = file + ".md5"
cmd = "curl --connect-timeout 10 -o {0} {1}".format(
localmd5file, remotemd5file)
- rc = os.system(cmd)
+ rc = exec_command(cmd, True)
if os.path.exists(localfile):
print "calculate md5sum of local file"
cmd = "md5sum " + localfile + "|cut -d ' ' -f 1"
@@ -45,43 +53,38 @@ def get_from_cache(cache, package):
if rc == 0:
break
print "downloading remote file to local...."
- cmd = "aria2c --max-connection-per-server=4 --allow-overwrite=true --dir={0} \
- --out={1} {2}".format(cache, filename, " ".join(remotefile))
+ cmd = "aria2c --max-tries 1 --max-connection-per-server=4 \
+ --allow-overwrite=true --dir={0} --out={1} {2}".format(
+ cache, filename, " ".join(remotefile))
print cmd
- rc = os.system(cmd)
- if rc != 0:
- sys.exit(1)
+ exec_command(cmd)
def get_from_git(cache, package):
localfile = cache + "/" + package.get("name")
cmd = "rm -rf " + localfile
print cmd
- os.system(cmd)
+ exec_command(cmd)
cmd = "git clone " + package.get("url") + " " + localfile
print cmd
- rc = os.system(cmd)
- if rc != 0:
- sys.exit(1)
+ exec_command(cmd)
def get_from_docker(cache, package):
+ package_ouput = cache+"/"+package.get("name")+".tar"
cmd = "sudo docker pull "+package.get("url")
- os.system(cmd)
- cmd = "sudo docker save "+package.get("url")+" -o "+cache+"/"
- cmd += package.get("name")+".tar"
- rc = os.system(cmd)
- if rc != 0:
- sys.exit(1)
+ exec_command(cmd)
+ cmd = "sudo docker save "+package.get("url")+" -o "+package_ouput
+ exec_command(cmd)
+ cmd = "user=$(whoami); sudo chown -R $user:$user "+package_ouput
+ exec_command(cmd)
def get_from_curl(cache, package):
cmd = "curl --connect-timeout 10 -o " + cache + "/"
cmd += package.get("name") + " " + package.get("url")
print cmd
- rc = os.system(cmd)
- if rc != 0:
- sys.exit(1)
+ exec_command(cmd)
def usage():