blob: a89f63c3b643bf15f61c15fc719836e2c0874bad [file] [log] [blame]
Jin Qiana09060a2016-04-04 18:11:07 -07001#!/bin/bash
2set -e
3
Jin Qian712517a2016-05-17 17:52:40 -07004manual_mode=false
Jin Qian7f0cd932017-10-27 12:30:35 -07005version=3.18
Jin Qian712517a2016-05-17 17:52:40 -07006
Jin Qianed834612017-04-17 14:19:49 -07007while getopts "mv:" opt; do
8 case $opt in
9 m) manual_mode=true
10 ;;
11 v) version=$OPTARG
12 ;;
13 ?) echo "Usage: $0 [-m] [-v version]"
14 echo " -m: manually specify build numbers"
15 echo " -v: specify kernel version [default 3.10]"
16 exit 1
17 ;;
18 esac
19done
20
21if [[ "$version" != "3.10" && "$version" != "3.18" ]]
Jin Qiana09060a2016-04-04 18:11:07 -070022then
Jin Qianed834612017-04-17 14:19:49 -070023 echo "kernel version must be 3.10 or 3.18"
Jin Qiana09060a2016-04-04 18:11:07 -070024 exit 1
25fi
26
Jin Qianb0387652017-09-11 16:51:59 -070027abcmd_lkgb='/google/data/ro/projects/android/ab lkgb --target kernel --branch'
28fetch_artifact='/google/data/ro/projects/android/fetch_artifact --request_timeout_secs 60 --target kernel'
29
Jin Qiana09060a2016-04-04 18:11:07 -070030branch_prefix='kernel-n-dev-android-goldfish-'
31
32# kernel_img[branch]="build_server_output local_file_name"
33declare -A kernel_img
34
Jin Qiana3fcc922017-08-03 13:17:20 -070035kernel_img[3.10-arm]="zImage arm/3.10/kernel-qemu"
36kernel_img[3.10-arm64]="Image arm64/3.10/kernel-qemu"
Miodrag Dinicc8046992017-08-23 11:28:34 +020037kernel_img[3.10-mips]="vmlinux mips/3.10/kernel-qemu"
38kernel_img[3.10-mips64]="vmlinux mips64/3.10/kernel-qemu"
Jin Qiana3fcc922017-08-03 13:17:20 -070039kernel_img[3.10-x86]="bzImage x86/3.10/kernel-qemu"
40kernel_img[3.10-x86_64]="bzImage x86_64/3.10/kernel-qemu"
Jin Qiana09060a2016-04-04 18:11:07 -070041kernel_img[3.10-x86_64-qemu1]="bzImage x86_64/kernel-qemu"
Jin Qianc2d2a292016-10-31 14:15:38 -070042kernel_img[3.18-arm]="zImage arm/3.18/kernel-qemu2"
43kernel_img[3.18-arm64]="Image arm64/3.18/kernel-qemu2"
44kernel_img[3.18-mips]="vmlinux mips/3.18/kernel-qemu2"
45kernel_img[3.18-mips64]="vmlinux mips64/3.18/kernel-qemu2"
46kernel_img[3.18-x86]="bzImage x86/3.18/kernel-qemu2"
47kernel_img[3.18-x86_64]="bzImage x86_64/3.18/kernel-qemu2"
Jin Qiana09060a2016-04-04 18:11:07 -070048
Jin Qianed834612017-04-17 14:19:49 -070049printf "Upgrade emulator kernels $version\n\n" > emu_kernel.commitmsg
Jin Qiana09060a2016-04-04 18:11:07 -070050
51for key in "${!kernel_img[@]}"
52do
Jin Qianed834612017-04-17 14:19:49 -070053 if [[ $key != $version* ]]
54 then
55 continue
56 fi
57
Jin Qiana09060a2016-04-04 18:11:07 -070058 branch=$branch_prefix$key
Jin Qiana09060a2016-04-04 18:11:07 -070059
60 # Find the latest build by searching for highest build number since
61 # build server doesn't provide the "latest" link.
Jin Qianb0387652017-09-11 16:51:59 -070062 build=`$abcmd_lkgb $branch | cut -d' ' -f3 | head -n 1`
Jin Qiana09060a2016-04-04 18:11:07 -070063
64 if $manual_mode
65 then
66 read -p "Enter build number for $branch: [$build]" input
67 build="${input:-$build}"
68 fi
69
70 echo Fetching build $build from branch $branch
71
72 # file_info[0] - kernel image on build server
73 # file_info[1] - kernel image in local tree
74 file_info=(${kernel_img[$key]})
75
Jin Qianb0387652017-09-11 16:51:59 -070076 $fetch_artifact --bid $build ${file_info[0]} ${file_info[1]}
Jin Qiana09060a2016-04-04 18:11:07 -070077
78 git add ${file_info[1]}
79
80 printf "$branch - build: $build\n" >> emu_kernel.commitmsg
81done
82
Jin Qianed834612017-04-17 14:19:49 -070083last_commit=`git log | \
84 sed -rn "s/.*Upgrade $version kernel images to ([a-z0-9]+).*/\1/p" | \
Jin Qianc2d2a292016-10-31 14:15:38 -070085 head -n 1`
86
Jin Qiana09060a2016-04-04 18:11:07 -070087if [ ! -d goldfish_cache ]
88then
89 mkdir goldfish_cache
90 git clone https://android.googlesource.com/kernel/goldfish goldfish_cache
91fi
92
93pushd goldfish_cache
94
95git fetch origin
96
Jin Qianed834612017-04-17 14:19:49 -070097git checkout remotes/origin/android-goldfish-$version
98tot_commit=`git log --oneline -1 | cut -d' ' -f1`
99printf "\nUpgrade $version kernel images to ${tot_commit}\n" >> ../emu_kernel.commitmsg
Jin Qian7f0cd932017-10-27 12:30:35 -0700100
101line_count=`git log --oneline HEAD...${last_commit} | wc -l`
102if [ "$line_count" -gt "6" ]
103then
104 git log --oneline --no-decorate -3 >> ../emu_kernel.commitmsg
105 echo "..." >> ../emu_kernel.commitmsg
106 git log --oneline --no-decorate HEAD...${last_commit} | tail -n 3 >> ../emu_kernel.commitmsg
107else
108 git log --oneline --no-decorate HEAD...${last_commit} >> ../emu_kernel.commitmsg
109fi
Jin Qianc2d2a292016-10-31 14:15:38 -0700110
Jin Qiana09060a2016-04-04 18:11:07 -0700111popd
112
113git commit -t emu_kernel.commitmsg
114
115rm emu_kernel.commitmsg
116