3 # Common parameter parsing for kvmfornfv scripts
6 function checking_apex_build() {
8 commit=`git rev-parse HEAD`
9 echo "commit id: $commit"
10 echo "Checking for presence of apex.conf in the current patch"
11 git diff-tree --no-commit-id --name-only -r ${commit} | grep apex.conf
12 # result=`git show --name-only ${commit} | grep apex.conf`
13 result=`git diff-tree --no-commit-id --name-only -r ${commit} | grep apex.conf`
14 if [ -z "${result}" ]; then
15 echo "Does not include the file apex.conf"
18 source $WORKSPACE/ci/apex.conf
19 echo "Includes apex.conf"
27 echo "Usage --> $0 [-p package_type] [-o output_dir] [-h]"
28 echo " package_type : centos/ubuntu/both ; default is centos"
29 echo " output_dir : stores rpm and debian packages"
30 echo " -h : Help section"
40 if [ ${apex_build_flag} -eq 0 ];then
41 cd $WORKSPACE/ci/build_rpm
42 sudo docker build -t kvm_rpm .
43 sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_rpm \
44 /opt/kvmfornfv/ci/build_interface.sh $1
48 sudo docker build -t kvm_apex .
49 sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_apex \
50 /opt/kvmfornfv/ci/apex_build.sh build_output
54 cd $WORKSPACE/ci/build_deb
55 sudo docker build -t kvm_deb .
56 sudo docker run -v $WORKSPACE:/opt/kvmfornfv -t kvm_deb \
57 /opt/kvmfornfv/ci/build_interface.sh $1
59 *) echo "Not supported system"; exit 1;;
63 function build_package() {
67 echo "Build $choice Rpms/Debians"
71 echo "Build $choice Debians and Rpms"
76 echo "Invalid package option"
83 ## --- Parse command line arguments / parameters ---
84 while getopts ":o:p:h" option; do
93 echo "Option -$OPTARG requires an argument."
102 echo "Unknown option: $OPTARG."
107 echo "[WARNING] Unknown parameters!!!"
108 echo "Using default values for package generation & output"
117 if [[ -z "$output_dir" ]]
119 output_dir=$WORKSPACE/build_output
123 echo "Building for $type package in $output_dir"
130 # Renaming the rpms in the format kvmfornfv-xxxxxxxx-apex-kernel-4.4.6_rt14.el7.centos.x86_64.rpm
131 if [ ${apex_build_flag} -eq 1 ];then
133 echo "Renaming the rpms"
134 source $WORKSPACE/ci/apex.conf
136 short_hash=`git rev-parse --short=8 ${commit_id}`
138 rename 's/^/kvmfornfv-'${short_hash}'-apex-/' kernel-*
139 variable=`ls kvmfornfv-* | grep "devel" | awk -F "_" '{print $3}' | awk -F "." '{print $1}'`
140 rename "s/${variable}/centos/" kvmfornfv-*