This patch includes building of the kernel rpm's for the commit id 73/29473/20
authorRajithaY <rajithax.yerrumsetty@intel.com>
Mon, 6 Mar 2017 13:18:31 +0000 (18:48 +0530)
committerNavya Bathula <navyax.bathula@intel.com>
Fri, 10 Mar 2017 17:53:01 +0000 (17:53 +0000)
provided in apex.conf file and renaming of the kernel rpm's in the format
kvmfornfv-commitid-apex-kernel-[devel/header]-4.4.6_rt14_centos.x86_64.rpm

Change-Id: Id36eec6a577ac92b436a68f975fc1293c04ab97d
Co-Authored by: Navya Bathula <navyax.bathula@intel.com>
Signed-off-by:RajithaY<rajithax.yerrumsetty@intel.com>

ci/Dockerfile [new file with mode: 0644]
ci/apex.conf [new file with mode: 0644]
ci/apex_build.sh [new file with mode: 0755]
ci/build.sh
ci/cyclicTestTrigger.sh
ci/envs/utils.sh

diff --git a/ci/Dockerfile b/ci/Dockerfile
new file mode 100644 (file)
index 0000000..d39f15d
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+FROM centos
+RUN yum -y update && yum -y install \
+  git \
+  gcc \
+  gcc-c++ \
+  zlib-devel \
+  gtk2-devel \
+  glib2-devel \
+  make \
+  gettext \
+  bc \
+  bison\
+  flex\
+  rpm \
+  rpm-build
\ No newline at end of file
diff --git a/ci/apex.conf b/ci/apex.conf
new file mode 100644 (file)
index 0000000..a5232e3
--- /dev/null
@@ -0,0 +1,2 @@
+branch=master
+commit_id=e1a58e17cf85b14c61c2389588ed7bf5da88fd53
diff --git a/ci/apex_build.sh b/ci/apex_build.sh
new file mode 100755 (executable)
index 0000000..5b81840
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+function checkout_commit() {
+build_dir=/opt/kvmfornfv/
+mkdir -p /tmp/kvmfornfv
+SRC=/tmp/kvmfornfv
+source ${build_dir}/ci/apex.conf
+cd $SRC
+#Cloning into /tmp/kvmfornfv from local repository
+git clone $build_dir $SRC
+if [ "$branch" == "master" ] || [ "$branch" == "danube" ];then
+   echo "Checking out on $branch branch"
+   echo "Commit-id is ${commit_id}"
+   git checkout -f ${commit_id}
+fi
+mkdir ${output_dir}
+}
+
+output_dir="$1"
+checkout_commit
+
+kernel_src_dir=$SRC/kernel
+rpmbuild_dir=$SRC/kvmfornfv_rpmbuild.$$
+artifact_dir=${rpmbuild_dir}/RPMS/x86_64
+mkdir -p $artifact_dir
+config_file="${kernel_src_dir}/arch/x86/configs/opnfv.config"
+
+usage () {
+    echo "usage: ${0} output_dir"
+    exit 1
+}
+
+
+if [[ -z "$@" ]]; then
+    usage
+fi
+
+if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
+    echo "${0}: Output directory '${output_dir}' does not exist or cannot \
+          be written"
+    exit 1
+fi
+
+if [ ! -d ${kernel_src_dir} ] ; then
+    echo "${0}: Directory '${kernel_src_dir}' does not exist, run this script \
+          from the root of kvmfornfv source tree"
+    exit 1
+fi
+
+if [ ! -f ${config_file} ] ; then
+    echo "${0}: ${config_file} does not exist"
+    exit 1
+fi
+
+echo
+echo "Build"
+echo
+
+cp -f ${config_file} "${kernel_src_dir}/.config"
+
+# Make timestamp part of version string for automated kernel boot verification
+date "+-%y%m%d%H%M" > "${kernel_src_dir}/localversion-zzz"
+
+(cd ${kernel_src_dir}; make RPMOPTS="--define '_topdir ${rpmbuild_dir}'" rpm-pkg)
+if [ ${?} -ne 0 ] ; then
+    echo "${0}: Kernel build failed"
+    rm -rf ${rpmbuild_dir}
+    exit 1
+fi
+
+cp -f ${artifact_dir}/* ${output_dir}
+mv ${output_dir}/* ${build_dir}/build_output/
+
+rm -rf ${rpmbuild_dir}
+#cleaning the /tmp
+rm -rf ${SRC}
index 918e3ca..ef06a71 100755 (executable)
@@ -3,6 +3,25 @@
 # Common parameter parsing for kvmfornfv scripts
 #
 
+function checking_apex_build() {
+    echo ""
+    commit=`git rev-parse HEAD`
+    echo "commit id: $commit"
+    echo "Checking for presence of apex.conf in the current patch"
+    git diff-tree --no-commit-id --name-only -r ${commit} | grep apex.conf
+#    result=`git show --name-only ${commit} | grep apex.conf`
+    result=`git diff-tree --no-commit-id --name-only -r ${commit} | grep apex.conf`
+    if [ -z "${result}" ]; then
+       echo "Does not include the file apex.conf"
+       apex_build_flag=0
+    else
+       source $WORKSPACE/ci/apex.conf
+       echo "Includes apex.conf"
+       apex_build_flag=1
+    fi
+}
+
+
 function usage() {
     echo ""
     echo "Usage --> $0 [-p package_type] [-o output_dir] [-h]"
@@ -18,10 +37,18 @@ type=""
 function run() {
    case $1 in
       centos)
-         cd $WORKSPACE/ci/build_rpm
-         sudo docker build -t kvm_rpm .
-         sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t  kvm_rpm \
-                      /opt/kvmfornfv/ci/build_interface.sh $1
+         if [ ${apex_build_flag} -eq 0 ];then
+            cd $WORKSPACE/ci/build_rpm
+            sudo docker build -t kvm_rpm .
+            sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t  kvm_rpm \
+                         /opt/kvmfornfv/ci/build_interface.sh $1
+         else
+            cd $WORKSPACE/ci/
+            echo $output_dir
+            sudo docker build -t kvm_apex .
+            sudo docker run --privileged=true -v $WORKSPACE:/opt/kvmfornfv -t  kvm_apex  \
+                         /opt/kvmfornfv/ci/apex_build.sh build_output
+         fi
       ;;
       ubuntu)
          cd $WORKSPACE/ci/build_deb
@@ -96,5 +123,19 @@ echo ""
 echo "Building for $type package in $output_dir"
 echo ""
 
+checking_apex_build
 mkdir -p $output_dir
 build_package $type
+
+# Renaming the rpms in the format kvmfornfv-xxxxxxxx-apex-kernel-4.4.6_rt14.el7.centos.x86_64.rpm
+if [ ${apex_build_flag} -eq 1 ];then
+    cd ${output_dir}
+    echo "Renaming the rpms"
+    source $WORKSPACE/ci/apex.conf
+    echo "${commit_id}"
+    short_hash=`git rev-parse --short=8 ${commit_id}`
+    echo "$short_hash"
+    rename 's/^/kvmfornfv-'${short_hash}'-apex-/' kernel-*
+    variable=`ls kvmfornfv-* | grep "devel" | awk -F "_" '{print $3}' | awk -F "." '{print $1}'`
+    rename "s/${variable}/centos/" kvmfornfv-*
+fi
index 7ec3616..4315aab 100755 (executable)
@@ -14,6 +14,9 @@ testName=$4
 
 source $WORKSPACE/ci/envs/utils.sh
 source $WORKSPACE/ci/envs/host-config
+
+checkRPMNames
+
 KERNELRPM_VERSION=$( getKernelVersion )
 QEMURPM_VERSION=$( getQemuVersion )
 
index 89df273..5e4f1c4 100755 (executable)
@@ -39,4 +39,16 @@ function getQemuVersion {
    fi
    echo ${RPMVERSION}
 }
-
+#Check RPM names to continue the execution of testcases
+function checkRPMNames {
+  rpm_dir="/root/workspace/rpm"
+  if [ -d "$WORKSPACE" ];then
+     cd $WORKSPACE/build_output 2>/dev/null;RPMCOUNT=`ls kvmfornfv-* | wc -l`
+        if [ $RPMCOUNT -ne 0 ];then
+           echo "Testcases are not executed for apex_build"
+           exit 0
+        else
+           echo "Continue test execution"
+        fi
+  fi
+}