diff options
author | Chase Qi <chase.qi@linaro.org> | 2017-12-07 07:48:00 +0000 |
---|---|---|
committer | Linaro Code Review <review@review.linaro.org> | 2017-12-07 07:48:00 +0000 |
commit | 574e7f2b6dc253b17cf1b129c18425a80c56a7f5 (patch) | |
tree | 92864e9b81caf43bf78f313706899421b7eb04db /automated/lib | |
parent | fef7fb5f87174d850d60c654481e8fad92d3fc16 (diff) | |
parent | 61c3a6499a253a8e2343d8c407fd75fcf9d16886 (diff) |
Merge "sh-test-lib: Don't run apt-get update every time"
Diffstat (limited to 'automated/lib')
-rwxr-xr-x | automated/lib/sh-test-lib | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib index a948e7a..95ff3f2 100755 --- a/automated/lib/sh-test-lib +++ b/automated/lib/sh-test-lib @@ -204,8 +204,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} ;; |