summaryrefslogtreecommitdiff
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 15:44:51 +0800
commit61c3a6499a253a8e2343d8c407fd75fcf9d16886 (patch)
tree494aea5ae19daa579c1d3c98287bba20446650fd
parent3173e26d58b07a5833bbe8edff08e31e3802a108 (diff)
sh-test-lib: Don't run apt-get update every time
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>
-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 ed0d96e..bc6c65e 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}
;;