aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiancong Wang <tcwang@google.com>2020-07-27 15:27:27 -0700
committerTiancong Wang <tcwang@google.com>2020-07-28 18:25:22 +0000
commitd81dc939e7a1778b1e93f16f022c8634f509c9a8 (patch)
tree2873bcf35299f4a4e464490bb266f052ed68f13f
parent92596836d539e53bb14e659cbaec5206d74f0c56 (diff)
downloadtoolchain-utils-d81dc939e7a1778b1e93f16f022c8634f509c9a8.tar.gz
afdo_tools: Update script to sort profiles by timestamp
Our update_kernel_afdo tries to get all the profiles with gsutil. However, the command gives results by sorting the profile name, so the last profile is not necessarily the newest. A counter example is: R86-13310.3-1594633089.gcov.xz appears after R86-13310.18-1595237847.gcov.xz So this patch sorts the results of gsutil by the timestamp and grep all the master profiles (otherwise we might get some beta/stable profiles). BUG=None TEST=Tool can be used to generate kernel_afdo.json CL Change-Id: I9c9f6ee2ab446f5e07ea577e11f0c3d562bff5e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2321122 Commit-Queue: Tiancong Wang <tcwang@google.com> Tested-by: Tiancong Wang <tcwang@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
-rwxr-xr-xafdo_tools/update_kernel_afdo11
1 files changed, 9 insertions, 2 deletions
diff --git a/afdo_tools/update_kernel_afdo b/afdo_tools/update_kernel_afdo
index aac891cb..64e5e477 100755
--- a/afdo_tools/update_kernel_afdo
+++ b/afdo_tools/update_kernel_afdo
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/bash
# Due to crbug.com/1081332, we need to update AFDO metadata
# manually. This script performs a few checks and generates a
@@ -24,6 +24,7 @@
#
set -eu
+set -o pipefail
GS_BASE=gs://chromeos-prebuilt/afdo-job/vetted/kernel
KVERS="3.18 4.4 4.14 4.19"
@@ -43,11 +44,17 @@ else
expected_time=$(date +%s -d "last Monday")
fi
+# Get the current master branch number (using beta + 1)
+beta=$(git ls-remote -h https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay | sed -n -e "s/^.*release-R\([0-9][0-9]*\).*$/\1/p" | sort -g | tail -1)
+master="$(($beta + 1))"
+
json="{"
sep=""
for kver in $KVERS
do
- latest=$(gsutil ls -l "$GS_BASE/$kver/" | tail -n 2 | head -n 1)
+ # Sort the gs output by timestamp (default ordering is by name, so
+ # R86-13310.3-1594633089.gcov.xz goes after R86-13310.18-1595237847.gcov.xz)
+ latest=$(gsutil ls -l "$GS_BASE/$kver/" | sort -k2 | grep "R${master}" | tail -1)
# Verify that the file has the expected date.
file_time=$(echo "$latest" | awk '{print $2}')