More robust checking of age of apt cache (#90)

This commit is contained in:
John Hughes 2023-02-12 06:36:46 +01:00 committed by GitHub
parent 270eae5fc9
commit 797d1a2f52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,7 +30,7 @@ manifest_main=""
log "Package list:" log "Package list:"
for package in ${normalized_packages}; do for package in ${normalized_packages}; do
read package_name package_ver < <(get_package_name_ver "${package}") read package_name package_ver < <(get_package_name_ver "${package}")
manifest_main="${manifest_main}${package_name}:${package_ver}," manifest_main="${manifest_main}${package_name}:${package_ver},"
log "- ${package_name}:${package_ver}" log "- ${package_name}:${package_ver}"
done done
write_manifest "main" "${manifest_main}" "${cache_dir}/manifest_main.log" write_manifest "main" "${manifest_main}" "${cache_dir}/manifest_main.log"
@ -45,12 +45,11 @@ log "done"
log_empty_line log_empty_line
log "Updating APT package list..." log "Updating APT package list..."
last_update_delta_s=$(($(date +%s) - $(date +%s -r /var/cache/apt/pkgcache.bin))) if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5)" ]]; then
if test $last_update_delta_s -gt 300; then
sudo apt-fast update > /dev/null sudo apt-fast update > /dev/null
log "done" log "done"
else else
log "skipped (fresh by ${last_update_delta_s} seconds)" log "skipped (fresh within at least 5 minutes)"
fi fi
log_empty_line log_empty_line