Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
Jin Qian | 712517a | 2016-05-17 17:52:40 -0700 | [diff] [blame] | 4 | manual_mode=false |
Jin Qian | 7f0cd93 | 2017-10-27 12:30:35 -0700 | [diff] [blame] | 5 | version=3.18 |
Jin Qian | 712517a | 2016-05-17 17:52:40 -0700 | [diff] [blame] | 6 | |
Jin Qian | ed83461 | 2017-04-17 14:19:49 -0700 | [diff] [blame] | 7 | while 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 |
| 19 | done |
| 20 | |
| 21 | if [[ "$version" != "3.10" && "$version" != "3.18" ]] |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 22 | then |
Jin Qian | ed83461 | 2017-04-17 14:19:49 -0700 | [diff] [blame] | 23 | echo "kernel version must be 3.10 or 3.18" |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 24 | exit 1 |
| 25 | fi |
| 26 | |
Jin Qian | b038765 | 2017-09-11 16:51:59 -0700 | [diff] [blame] | 27 | abcmd_lkgb='/google/data/ro/projects/android/ab lkgb --target kernel --branch' |
| 28 | fetch_artifact='/google/data/ro/projects/android/fetch_artifact --request_timeout_secs 60 --target kernel' |
| 29 | |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 30 | branch_prefix='kernel-n-dev-android-goldfish-' |
| 31 | |
| 32 | # kernel_img[branch]="build_server_output local_file_name" |
| 33 | declare -A kernel_img |
| 34 | |
Jin Qian | a3fcc92 | 2017-08-03 13:17:20 -0700 | [diff] [blame] | 35 | kernel_img[3.10-arm]="zImage arm/3.10/kernel-qemu" |
| 36 | kernel_img[3.10-arm64]="Image arm64/3.10/kernel-qemu" |
Miodrag Dinic | c804699 | 2017-08-23 11:28:34 +0200 | [diff] [blame] | 37 | kernel_img[3.10-mips]="vmlinux mips/3.10/kernel-qemu" |
| 38 | kernel_img[3.10-mips64]="vmlinux mips64/3.10/kernel-qemu" |
Jin Qian | a3fcc92 | 2017-08-03 13:17:20 -0700 | [diff] [blame] | 39 | kernel_img[3.10-x86]="bzImage x86/3.10/kernel-qemu" |
| 40 | kernel_img[3.10-x86_64]="bzImage x86_64/3.10/kernel-qemu" |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 41 | kernel_img[3.10-x86_64-qemu1]="bzImage x86_64/kernel-qemu" |
Jin Qian | c2d2a29 | 2016-10-31 14:15:38 -0700 | [diff] [blame] | 42 | kernel_img[3.18-arm]="zImage arm/3.18/kernel-qemu2" |
| 43 | kernel_img[3.18-arm64]="Image arm64/3.18/kernel-qemu2" |
| 44 | kernel_img[3.18-mips]="vmlinux mips/3.18/kernel-qemu2" |
| 45 | kernel_img[3.18-mips64]="vmlinux mips64/3.18/kernel-qemu2" |
| 46 | kernel_img[3.18-x86]="bzImage x86/3.18/kernel-qemu2" |
| 47 | kernel_img[3.18-x86_64]="bzImage x86_64/3.18/kernel-qemu2" |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 48 | |
Jin Qian | ed83461 | 2017-04-17 14:19:49 -0700 | [diff] [blame] | 49 | printf "Upgrade emulator kernels $version\n\n" > emu_kernel.commitmsg |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 50 | |
| 51 | for key in "${!kernel_img[@]}" |
| 52 | do |
Jin Qian | ed83461 | 2017-04-17 14:19:49 -0700 | [diff] [blame] | 53 | if [[ $key != $version* ]] |
| 54 | then |
| 55 | continue |
| 56 | fi |
| 57 | |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 58 | branch=$branch_prefix$key |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 59 | |
| 60 | # Find the latest build by searching for highest build number since |
| 61 | # build server doesn't provide the "latest" link. |
Jin Qian | b038765 | 2017-09-11 16:51:59 -0700 | [diff] [blame] | 62 | build=`$abcmd_lkgb $branch | cut -d' ' -f3 | head -n 1` |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 63 | |
| 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 Qian | b038765 | 2017-09-11 16:51:59 -0700 | [diff] [blame] | 76 | $fetch_artifact --bid $build ${file_info[0]} ${file_info[1]} |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 77 | |
| 78 | git add ${file_info[1]} |
| 79 | |
| 80 | printf "$branch - build: $build\n" >> emu_kernel.commitmsg |
| 81 | done |
| 82 | |
Jin Qian | ed83461 | 2017-04-17 14:19:49 -0700 | [diff] [blame] | 83 | last_commit=`git log | \ |
| 84 | sed -rn "s/.*Upgrade $version kernel images to ([a-z0-9]+).*/\1/p" | \ |
Jin Qian | c2d2a29 | 2016-10-31 14:15:38 -0700 | [diff] [blame] | 85 | head -n 1` |
| 86 | |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 87 | if [ ! -d goldfish_cache ] |
| 88 | then |
| 89 | mkdir goldfish_cache |
| 90 | git clone https://android.googlesource.com/kernel/goldfish goldfish_cache |
| 91 | fi |
| 92 | |
| 93 | pushd goldfish_cache |
| 94 | |
| 95 | git fetch origin |
| 96 | |
Jin Qian | ed83461 | 2017-04-17 14:19:49 -0700 | [diff] [blame] | 97 | git checkout remotes/origin/android-goldfish-$version |
| 98 | tot_commit=`git log --oneline -1 | cut -d' ' -f1` |
| 99 | printf "\nUpgrade $version kernel images to ${tot_commit}\n" >> ../emu_kernel.commitmsg |
Jin Qian | 7f0cd93 | 2017-10-27 12:30:35 -0700 | [diff] [blame] | 100 | |
| 101 | line_count=`git log --oneline HEAD...${last_commit} | wc -l` |
| 102 | if [ "$line_count" -gt "6" ] |
| 103 | then |
| 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 |
| 107 | else |
| 108 | git log --oneline --no-decorate HEAD...${last_commit} >> ../emu_kernel.commitmsg |
| 109 | fi |
Jin Qian | c2d2a29 | 2016-10-31 14:15:38 -0700 | [diff] [blame] | 110 | |
Jin Qian | a09060a | 2016-04-04 18:11:07 -0700 | [diff] [blame] | 111 | popd |
| 112 | |
| 113 | git commit -t emu_kernel.commitmsg |
| 114 | |
| 115 | rm emu_kernel.commitmsg |
| 116 | |