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"
24 function checking_compass_build() {
26 commit=`git rev-parse HEAD`
27 echo "commit id: $commit"
28 echo "Checking for presence of compass.conf in the current patch"
29 git diff-tree --no-commit-id --name-only -r ${commit} | grep compass.conf
30 result=`git diff-tree --no-commit-id --name-only -r ${commit} | grep compass.conf`
31 if [ -z "${result}" ]; then
32 echo "Does not include the file compass.conf"
35 source $WORKSPACE/ci/compass.conf
36 echo "Includes compass.conf"
44 echo "Usage --> $0 [-p package_type] [-o output_dir] [-h]"
45 echo " package_type : centos/ubuntu/both ; default is centos"
46 echo " output_dir : stores rpm and debian packages"
47 echo " -h : Help section"
57 if [ ${apex_build_flag} -eq 0 ];then
58 cd $WORKSPACE/ci/build_rpm
59 sudo docker build -t kvm_rpm .
60 sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_rpm \
61 /opt/kvmfornfv/ci/build_interface.sh $1
65 cp $WORKSPACE/ci/build_rpm/Dockerfile .
66 sudo docker build -t kvm_apex .
67 sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_apex \
68 /opt/kvmfornfv/ci/installer_build.sh build_output apex
72 if [ ${compass_build_flag} -eq 0 ]; then
73 cd $WORKSPACE/ci/build_deb
74 sudo docker build -t kvm_deb .
75 sudo docker run -v $WORKSPACE:/opt/kvmfornfv -t kvm_deb \
76 /opt/kvmfornfv/ci/build_interface.sh $1
80 cp $WORKSPACE/ci/build_deb/Dockerfile .
81 sudo docker build -t kvm_docker .
82 sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t kvm_docker \
83 /opt/kvmfornfv/ci/installer_build.sh build_output compass
86 *) echo "Not supported system"; exit 1;;
90 function build_package() {
94 echo "Build $choice Rpms/Debians"
98 echo "Build $choice Debians and Rpms"
103 echo "Invalid package option"
110 ## --- Parse command line arguments / parameters ---
111 while getopts ":o:p:h" option; do
120 echo "Option -$OPTARG requires an argument."
129 echo "Unknown option: $OPTARG."
134 echo "[WARNING] Unknown parameters!!!"
135 echo "Using default values for package generation & output"
144 if [[ -z "$output_dir" ]]
146 output_dir=$WORKSPACE/build_output
149 job_type=`echo $JOB_NAME | cut -d '-' -f 2`
152 echo "Building for $type package in $output_dir"
155 checking_compass_build
160 # Renaming the rpms in the format kvmfornfv-xxxxxxxx-apex-kernel-4.4.6_rt14.el7.centos.x86_64.rpm
161 if [ ${apex_build_flag} -eq 1 ];then
163 echo "Renaming the rpms"
164 source $WORKSPACE/ci/apex.conf
166 short_hash=`git rev-parse --short=8 ${commit_id}`
168 rename 's/^/kvmfornfv-'${short_hash}'-apex-/' kernel-*
169 variable=`ls kvmfornfv-* | grep "devel" | awk -F "_" '{print $3}' | awk -F "." '{print $1}'`
170 rename "s/${variable}/centos/" kvmfornfv-*
173 # Uploading rpms only for daily job
174 if [ $job_type == "verify" ]; then
175 if [ $type == "centos" ]; then
176 echo "Removing kernel-debuginfo rpm from output_dir"
177 rm -f ${output_dir}/kernel-debug*
178 echo "Checking packages in output_dir"
179 ls -lrth ${output_dir}
181 echo "Removing debug debian from output_dir"
182 rm -f ${output_dir}/*dbg*
183 echo "Checking packages in output_dir"
184 ls -lrth ${output_dir}