blob: b36624ba636336b63133e1dd5e734a6d66c20eb7 [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
5
6if [ $# == 1 ] && [ $1 == '-m' ]
Jin Qiana09060a2016-04-04 18:11:07 -07007then
8 manual_mode=true
Jin Qian712517a2016-05-17 17:52:40 -07009elif [ $# != 0 ]
Jin Qiana09060a2016-04-04 18:11:07 -070010then
11 echo Usage: $0 [-m]
12 echo " -m: manually specify build numbers"
13 exit 1
14fi
15
Jin Qian958dbb92016-12-08 12:49:43 -080016fetchtool='sso_client -location -connect_timeout 60 -request_timeout 60 -url'
Jin Qiana09060a2016-04-04 18:11:07 -070017build_server='https://android-build-uber.corp.google.com'
18branch_prefix='kernel-n-dev-android-goldfish-'
19
20# kernel_img[branch]="build_server_output local_file_name"
21declare -A kernel_img
22
Jin Qian958dbb92016-12-08 12:49:43 -080023#kernel_img[3.4-arm]="zImage arm/kernel-qemu-armv7"
24#kernel_img[3.4-mips]="vmlinux mips/kernel-qemu"
25#kernel_img[3.4-x86]="bzImage x86/kernel-qemu"
Jin Qian712517a2016-05-17 17:52:40 -070026kernel_img[3.10-arm]="zImage arm/ranchu/kernel-qemu"
Jin Qiana09060a2016-04-04 18:11:07 -070027kernel_img[3.10-arm64]="Image arm64/kernel-qemu"
Jin Qian332b4f42016-08-11 15:06:29 -070028kernel_img[3.10-mips]="vmlinux mips/ranchu/kernel-qemu"
29kernel_img[3.10-mips64]="vmlinux mips64/kernel-qemu"
Jin Qiana09060a2016-04-04 18:11:07 -070030kernel_img[3.10-x86]="bzImage x86/ranchu/kernel-qemu"
31kernel_img[3.10-x86_64]="bzImage x86_64/ranchu/kernel-qemu"
32kernel_img[3.10-x86_64-qemu1]="bzImage x86_64/kernel-qemu"
Jin Qianc2d2a292016-10-31 14:15:38 -070033kernel_img[3.18-arm]="zImage arm/3.18/kernel-qemu2"
34kernel_img[3.18-arm64]="Image arm64/3.18/kernel-qemu2"
35kernel_img[3.18-mips]="vmlinux mips/3.18/kernel-qemu2"
36kernel_img[3.18-mips64]="vmlinux mips64/3.18/kernel-qemu2"
37kernel_img[3.18-x86]="bzImage x86/3.18/kernel-qemu2"
38kernel_img[3.18-x86_64]="bzImage x86_64/3.18/kernel-qemu2"
Jin Qiana09060a2016-04-04 18:11:07 -070039
40printf "Upgrade emulator kernels\n\n" > emu_kernel.commitmsg
41
42for key in "${!kernel_img[@]}"
43do
44 branch=$branch_prefix$key
45 branch_url=$build_server/builds/$branch-linux-kernel
46
47 # Find the latest build by searching for highest build number since
48 # build server doesn't provide the "latest" link.
49 build=`$fetchtool $branch_url | \
50 sed -rn "s/<li><a href=".*">([0-9]+)<\/a><\/li>/\1/p" | \
51 sort -nr | head -n 1`
52
53 if $manual_mode
54 then
55 read -p "Enter build number for $branch: [$build]" input
56 build="${input:-$build}"
57 fi
58
59 echo Fetching build $build from branch $branch
60
61 # file_info[0] - kernel image on build server
62 # file_info[1] - kernel image in local tree
63 file_info=(${kernel_img[$key]})
64
65 $fetchtool $branch_url/$build/${file_info[0]} > ${file_info[1]}
66
67 git add ${file_info[1]}
68
69 printf "$branch - build: $build\n" >> emu_kernel.commitmsg
70done
71
72last_3_4_commit=`git log | \
73 sed -rn "s/.*Upgrade 3.4 kernel images to ([a-z0-9]+).*/\1/p" | \
74 head -n 1`
75
76last_3_10_commit=`git log | \
77 sed -rn "s/.*Upgrade 3.10 kernel images to ([a-z0-9]+).*/\1/p" | \
78 head -n 1`
79
Jin Qianc2d2a292016-10-31 14:15:38 -070080last_3_18_commit=`git log | \
81 sed -rn "s/.*Upgrade 3.18 kernel images to ([a-z0-9]+).*/\1/p" | \
82 head -n 1`
83
Jin Qiana09060a2016-04-04 18:11:07 -070084if [ ! -d goldfish_cache ]
85then
86 mkdir goldfish_cache
87 git clone https://android.googlesource.com/kernel/goldfish goldfish_cache
88fi
89
90pushd goldfish_cache
91
92git fetch origin
93
94git checkout remotes/origin/android-goldfish-3.4
95tot_3_4_commit=`git log --oneline -1 | cut -d' ' -f1`
96printf "\nUpgrade 3.4 kernel images to ${tot_3_4_commit}\n" >> ../emu_kernel.commitmsg
97git log --oneline HEAD...${last_3_4_commit} >> ../emu_kernel.commitmsg
98
99git checkout remotes/origin/android-goldfish-3.10
100tot_3_10_commit=`git log --oneline -1 | cut -d' ' -f1`
101printf "\nUpgrade 3.10 kernel images to ${tot_3_10_commit}\n" >> ../emu_kernel.commitmsg
102git log --oneline HEAD...${last_3_10_commit} >> ../emu_kernel.commitmsg
103
Jin Qianc2d2a292016-10-31 14:15:38 -0700104git checkout remotes/origin/android-goldfish-3.18
105tot_3_18_commit=`git log --oneline -1 | cut -d' ' -f1`
106printf "\nUpgrade 3.18 kernel images to ${tot_3_18_commit}\n" >> ../emu_kernel.commitmsg
107git log --oneline HEAD...${last_3_18_commit} >> ../emu_kernel.commitmsg
108
Jin Qiana09060a2016-04-04 18:11:07 -0700109popd
110
111git commit -t emu_kernel.commitmsg
112
113rm emu_kernel.commitmsg
114