aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Rue <dan.rue@linaro.org>2017-12-01 10:40:07 -0600
committerChase Qi <chase.qi@linaro.org>2017-12-07 07:48:22 +0000
commitdccc54862120bdb9b368fc27c82aa97112bf8fac (patch)
tree9e339b5346a370c8a7fc6605dde906341d3953b9
parent3aa8c578aedb4846d8c0ac78504977891536aea3 (diff)
sh-test-lib: Don't run apt-get update every timeerp-18.01
Run apt-get update once per 6 hours, rather than every time dependencies are installed. Change-Id: I6eaa15ac47e6a3cc7d60a6ea45fa663183547ca4 Signed-off-by: Dan Rue <dan.rue@linaro.org> (cherry picked from commit 61c3a6499a253a8e2343d8c407fd75fcf9d16886)
-rwxr-xr-xautomated/lib/sh-test-lib9
1 files changed, 7 insertions, 2 deletions
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib
index ed0d96e2..bc6c65ee 100755
--- a/automated/lib/sh-test-lib
+++ b/automated/lib/sh-test-lib
@@ -193,8 +193,13 @@ install_deps() {
dist_name
case "${dist}" in
debian|ubuntu)
- # Use the default answers for all questions.
- DEBIAN_FRONTEND=noninteractive apt-get update -q -y
+ last_apt_time=/tmp/apt-get-updated.last
+ apt_cache_time=21600 # 6 hours
+ # Only run apt-get update if it hasn't been run in $apt_cache_time seconds
+ if [ ! -e ${last_apt_time} ] || \
+ [ "$(stat --format=%Y ${last_apt_time})" -lt $(( $(date +%s) - apt_cache_time )) ]; then
+ DEBIAN_FRONTEND=noninteractive apt-get update -q -y && touch ${last_apt_time}
+ fi
# shellcheck disable=SC2086
DEBIAN_FRONTEND=noninteractive apt-get install -q -y ${pkgs}
;;