Merge lp:~linaro-automation/linaro-ci/one-time-submission-job into lp:linaro-ci

Proposed by Deepti B. Kalakeri
Status: Merged
Merged at revision: 39
Proposed branch: lp:~linaro-automation/linaro-ci/one-time-submission-job
Merge into: lp:linaro-ci
Diff against target: 122 lines (+118/-0)
1 file modified
jenkins_maintainers_kernel_build_inst (+118/-0)
To merge this branch: bzr merge lp:~linaro-automation/linaro-ci/one-time-submission-job
Reviewer Review Type Date Requested Status
Alexander Sack (community) Needs Resubmitting
Review via email: mp+80222@code.launchpad.net

Description of the change

Adding script for one time job submission.

To post a comment you must log in.
Revision history for this message
Alexander Sack (asac) wrote :

1. + if test -z "$git_branch_ref" ; then
 => I think this and all other sanity checks of input parameters should be moved to the top.

2. since we have quite a few variables and input parameters here itmight make sense to use special syntax for input parameters (like all uppercase, or param_... prefix etc.)

3. + git remote rm "$remote_tree_alias_name"
 => I think this cleanup should be moved to a block that gets always executed (even in case of error). there is a signal syntax to catch errors and jump to a cleanup code block in sh we could use.

4. i am not sure if the cleanup code should be going back to master branch; I dont think it is always the right thing; there can be trees that have no master branch etc. iirc jenkins creates its own branch names. check what branch you are on if you enter the script and switch back to that maybe.

5. I feel we duplicate loads of code here that could be reused from the "normal" kenrel CI job; either refactor things now, or add a blueprint about code-reuse-effort-for-jenkins-scripts.

review: Needs Resubmitting
Revision history for this message
Alexander Sack (asac) wrote :

>
> 3. + git remote rm "$remote_tree_alias_name"
> => I think this cleanup should be moved to a block that gets always executed
> (even in case of error). there is a signal syntax to catch errors and jump to
> a cleanup code block in sh we could use.

here background on this: http://steve-parker.org/sh/trap.shtml

we wantt he cleanup code to be run in case of error and if things go smooth.

Revision history for this message
Alexander Sack (asac) wrote :

haven't checked one by one, but all the parameters provided by the kernel job should be submitted to the dashboard too.

Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

>
> 1. + if test -z "$git_branch_ref" ; then
> => I think this and all other sanity checks of input parameters should be
> moved to the top.
>
> 2. since we have quite a few variables and input parameters here itmight make
> sense to use special syntax for input parameters (like all uppercase, or
> param_... prefix etc.)
>
> 3. + git remote rm "$remote_tree_alias_name"
> => I think this cleanup should be moved to a block that gets always executed
> (even in case of error). there is a signal syntax to catch errors and jump to
> a cleanup code block in sh we could use.
>

Added a cleanup function using the trap command.
> 4. i am not sure if the cleanup code should be going back to master branch; I
> dont think it is always the right thing; there can be trees that have no
> master branch etc. iirc jenkins creates its own branch names. check what
> branch you are on if you enter the script and switch back to that maybe.
>
DONE
> 5. I feel we duplicate loads of code here that could be reused from the
> "normal" kenrel CI job; either refactor things now, or add a blueprint about
> code-reuse-effort-for-jenkins-scripts.

I would prefer a BP on this and would like this to be done in 2011.11.

40. By Deepti B. Kalakeri

Addressing review comments on script for one time job submission

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'jenkins_maintainers_kernel_build_inst'
2--- jenkins_maintainers_kernel_build_inst 1970-01-01 00:00:00 +0000
3+++ jenkins_maintainers_kernel_build_inst 2011-10-25 13:56:23 +0000
4@@ -0,0 +1,118 @@
5+#! /bin/sh
6+# Example env variables and its values
7+# kernel_config='omap2plus_defconfig'
8+# export board_type='panda'
9+# kernel_flavour='omap4'
10+# rootfs_type='nano'
11+set -xe
12+
13+trap cleanup EXIT
14+
15+cleanup()
16+{
17+
18+if test "$matching_remote_trees" = "$remote_tree_alias_name" ; then
19+ # Cleaning up remote tree that was added
20+ git remote rm "$remote_tree_alias_name"
21+fi
22+if test "$matching_remote_branch" = "$remote_branch_name" ; then
23+ # Cleaning up remote branch that was added
24+ git checkout $GIT_BRANCH
25+ git branch -D $remote_branch_name
26+fi
27+}
28+
29+if test -z "$GIT_REMOTE_URL" ; then
30+ echo "Please specify the GIT_REMOTE_URL"
31+ exit 1
32+fi
33+if test -z "$GIT_REMOTE_REF" ; then
34+ echo "Please specify the GIT_REMOTE_REF"
35+ exit 1
36+fi
37+if test -z "$rootfs_type"; then
38+ rootfs_type='nano'
39+fi
40+
41+remote_tree_name=`basename $GIT_REMOTE_URL | awk -F '.git' '{print $1}'`
42+remote_tree_alias_name="$remote_tree_name-alias"
43+remote_branch_name="$remote_tree_name-branch"
44+git remote add "$remote_tree_alias_name" $GIT_REMOTE_URL
45+git fetch $remote_tree_alias_name
46+matching_remote_trees=`git remote -v | grep "$remote_tree_alias_name" | awk '{ print $1}' | uniq`
47+git checkout -b $remote_branch_name $GIT_REMOTE_REF
48+matching_remote_branch=`git branch | grep "$remote_branch_name" | awk -F ' ' '{ print $2}'`
49+
50+bundle_stream_name=`echo $JOB_NAME | sed -e 's/_.*//' -e 's/\./_/g'`
51+kernel_config_name=`echo ${kernel_config} | sed -e 's/_defconfig//g'`
52+kernel_version=`git describe --match='v*' | sed -e 's/^v//'``echo -${kernel_config_name}-linaro-${kernel_flavour} | sed -e 's/_/-/g'`
53+
54+# Below is the list of values that will be used in the json files
55+log_info=$BUILD_URL"consoleText"
56+bundle_stream_name_path="/anonymous/ci-$bundle_stream_name/"
57+echo > hwpack_info # start with empty
58+echo KERNEL_CONFIG=$kernel_config >> hwpack_info
59+echo OS_INFO=`cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | cut -d '=' -f 2` >> hwpack_info
60+echo LOG=$log_info >> hwpack_info
61+echo BUILD_ID=$BUILD_NUMBER >> hwpack_info
62+echo GCC_VERSION=`dpkg -s gcc | grep Version | cut -d ' ' -f2` >> hwpack_info
63+echo GCC_CROSS_COMPILER=`dpkg -s gcc-arm-linux-gnueabi | grep Version | cut -d ' ' -f2` >> hwpack_info
64+echo BOARD_TYPE=$board_type >> hwpack_info
65+echo HWPACK_TYPE=$hwpack_type >> hwpack_info
66+echo ROOTFS_TYPE=$rootfs_type >> hwpack_info
67+echo BUNDLE_STREAM_NAME=$bundle_stream_name_path >> hwpack_info
68+echo JOB_URL=http://ci.linaro.org/kernel_hwpack/ >> hwpack_info
69+echo KERNEL_VERSION=`git describe --match='v*'` >> hwpack_info
70+echo KERNEL_GIT=$git_remote_url >> hwpack_info
71+echo KERNEL_COMMIT=`git rev-parse HEAD` >> hwpack_info
72+echo COMMIT_TIME=`git show -s --format=%cD HEAD` >> hwpack_info
73+echo KERNEL_NAME=$bundle_stream_name >> hwpack_info
74+echo SUBMIT_LAVA_JOB=$submit_job >> hwpack_info
75+echo KERNEL_BUILD_URL=$BUILD_URL >> hwpack_info
76+echo KERNEL_BRANCH=`git branch | grep -e '*' | cut -d '*' -f 2` >> hwpack_info
77+echo KERNEL_JOB_NAME=$JOB_NAME >> hwpack_info
78+echo GIT_LOG=`git log -n1 --pretty=oneline` >> hwpack_info
79+
80+rm -f *.deb
81+cp scripts/package/builddeb scripts/package/builddeb.orig
82+cp builddeb scripts/package/builddeb
83+cpu_count=`cat /proc/cpuinfo | grep processor | wc -l`
84+if test x$cpu_count = x; then
85+ cpu_count=1
86+fi
87+j_count=`expr $cpu_count '*' 2`
88+
89+pkg_dir=$kernel_version"_output_dir"
90+rm -rf $pkg_dir
91+mkdir $pkg_dir
92+
93+echo "DEBUG: The remote branch: $remote_branch_name will be built now for the commit id $KERNEL_VERSION"
94+START=$(date +%s)
95+make ARCH=arm clean mrproper
96+make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- $kernel_config
97+yes "" | make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- oldconfig
98+
99+# Enabling the THUMB2 kernel option as the THUMB kernel does not seem to work
100+# well with THUMB2 userspace. This fixes the reboot issue(bug: 860556) we have seen
101+# for THUMB Kernel working with THUMB2 userspace.
102+
103+echo "CONFIG_ARCH_OMAP2=n" >> $WORKSPACE/$pkg_dir/.config
104+echo "CONFIG_THUMB2_KERNEL=y" >> $WORKSPACE/$pkg_dir/.config
105+yes "" | make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- oldconfig
106+make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- -j$j_count uImage
107+make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- -j$j_count modules
108+make ARCH=arm O=$pkg_dir KERNELVERSION="$kernel_version" KERNELRELEASE="$kernel_version" CROSS_COMPILE=arm-linux-gnueabi- KBUILD_DEBARCH=armel V=1 deb-pkg
109+END=$(date +%s)
110+EXECUTION_TIME_IN_SEC=$(( $END - $START ))
111+
112+latest_kernel=`python lci-build-tools/get_latest_slo_hwpack`
113+latest_hwpack_name=`basename $latest_kernel`
114+wget -c $latest_kernel
115+rm -rf linaro-image-tools
116+bzr branch lp:linaro-image-tools
117+new_hwpack_name=`python linaro-image-tools/linaro-hwpack-replace -t $latest_hwpack_name -p ./linux-image*${kernel_version}*.deb -r linux-image -n $BUILD_NUMBER`
118+use_hwpack_name=`basename $new_hwpack_name`
119+echo HWPACK_NAME=$use_hwpack_name >> hwpack_info
120+echo URL=$JENKINS_HOME/jobs/$JOB_NAME/workspace/$use_hwpack_name >> hwpack_info
121+echo EXECUTION_TIME_IN_SEC=$(( $END - $START )) >> hwpack_info
122+echo HWPACK_BUILD_DATE=`echo $use_hwpack_name | cut -d '_' -f3` >>hwpack_info

Subscribers

People subscribed via source and target branches