summaryrefslogtreecommitdiffstats
path: root/ci/build_rpm
diff options
context:
space:
mode:
authorJulien <zhang.jun3g@zte.com.cn>2016-12-07 15:48:22 +0800
committerJulien <zhang.jun3g@zte.com.cn>2016-12-07 15:55:33 +0800
commit90d45232f1e1f16b5e6d57712782796ac55bc33d (patch)
tree351db05a536f89950c02235c775215a53cb17e85 /ci/build_rpm
parent9bdfb2ea2627ee597e392b6bb465feb03dc7ac42 (diff)
bash format
1. use 4 header spaces instead of 8 2. keep max line width less than 80 3. don't mix use header tab and header space according pep8 4. for we use -x debug switch, no necessary to echo debug info Change-Id: I1cb4adf0fcfdad3bc015213ae4ad9b822748dd82 Signed-off-by: Julien <zhang.jun3g@zte.com.cn>
Diffstat (limited to 'ci/build_rpm')
-rwxr-xr-xci/build_rpm/build_rpms.sh75
1 files changed, 36 insertions, 39 deletions
diff --git a/ci/build_rpm/build_rpms.sh b/ci/build_rpm/build_rpms.sh
index 2d5d23e0..279340cd 100755
--- a/ci/build_rpm/build_rpms.sh
+++ b/ci/build_rpm/build_rpms.sh
@@ -13,54 +13,51 @@ DAISYDIR=$1
OPNFV_ARTIFACT_VERSION=$2
function build_rpm_pkg {
- # Cleanup prev build resutls
- rm -rf $DAISYDIR/build_output
- mkdir -p $DAISYDIR/build_output
-
- sudo docker build -t daisy4nfv_rpm .
- sudo docker run --rm -v $DAISYDIR:/opt/daisy4nfv -v $CACHE_DIRECTORY:/home/cache -t daisy4nfv_rpm \
- /opt/daisy4nfv/ci/build_rpm/build_rpms_docker.sh $OPNFV_ARTIFACT_VERSION
-
- # Here to collect build result from $DAISYDIR/build_output
+ # Cleanup prev build resutls
+ rm -rf $DAISYDIR/build_output
+ mkdir -p $DAISYDIR/build_output
+
+ sudo docker build -t daisy4nfv_rpm .
+ sudo docker run --rm -v $DAISYDIR:/opt/daisy4nfv \
+ -v $CACHE_DIRECTORY:/home/cache \
+ -t daisy4nfv_rpm \
+ /opt/daisy4nfv/ci/build_rpm/build_rpms_docker.sh \
+ $OPNFV_ARTIFACT_VERSION
}
function cleanup_container {
- containers_to_kill=$(sudo docker ps --filter "label=daisy_image_version" \
- --format "{{.Names}}" -a)
-
- if [[ -z "$containers_to_kill" ]]; then
- echo "No containers to cleanup."
- else
- volumes_to_remove=$(sudo docker inspect -f \
- '{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}' \
- ${containers_to_kill} | egrep -v '(^\s*$)' | sort | uniq)
- echo "Stopping containers... $containers_to_kill"
- sudo docker stop -t 2 ${containers_to_kill} >/dev/null 2>&1
-
- echo "Removing containers... $containers_to_kill"
- sudo docker rm -v -f ${containers_to_kill} >/dev/null 2>&1
-
- if [[ -z "$volumes_to_remove" ]]; then
- echo "No volumes to cleanup."
- else
- echo "Removing volumes... $volumes_to_remove"
- sudo docker volume rm ${volumes_to_remove} >/dev/null 2>&1
- fi
+ containers_to_kill=$(sudo docker ps -a \
+ --filter "label=daisy_image_version" \
+ --format "{{.Names}}")
+
+ if [[ ! -z "$containers_to_kill" ]]; then
+ ops='{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}'
+ volumes_to_remove=$(sudo docker inspect -f \
+ $ops ${containers_to_kill} \
+ | egrep -v '(^\s*$)' \
+ | sort | uniq)
+
+ sudo docker stop -t 2 ${containers_to_kill} >/dev/null 2>&1
+ sudo docker rm -v -f ${containers_to_kill} >/dev/null 2>&1
+
+ if [[ ! -z "$volumes_to_remove" ]]; then
+ sudo docker volume rm ${volumes_to_remove} >/dev/null 2>&1
fi
+ fi
}
function cleanup_docker_image {
- images_to_delete=$(sudo docker images -a --filter "label=daisy_image_version" \
- --format "{{.ID}}")
-
- echo "Removing images... $images_to_delete"
- if [[ -z "$images_to_delete" ]]; then
- echo "No images to cleanup"
- else
- sudo docker rmi -f ${images_to_delete} >/dev/null 2>&1
- fi
+ images_to_delete=$(sudo docker images -a \
+ --format "{{.ID}}" \
+ --filter "label=daisy_image_version")
+
+ echo "Removing images... $images_to_delete"
+ if [[ ! -z "$images_to_delete" ]]; then
+ sudo docker rmi -f ${images_to_delete} >/dev/null 2>&1
+ fi
}
cleanup_container
build_rpm_pkg
cleanup_container
+