Handle missing apt lists

On a newly imaged system, /var/lib/apt/lists may not exist. Check for
this case before comparing dates to the sources.
This commit is contained in:
contradict 2021-10-30 16:03:25 -07:00
parent 560374a686
commit aec8c665d7

View file

@ -34,7 +34,7 @@ apt_opts="-o Acquire::AllowReleaseInfoChange::Suite=true -o Acquire::AllowReleas
# run 'apt-get update' if anything in /etc/apt is newer then /var/lib/apt/lists
# it will be run a second time on error as a redundancy messure to success
cat << DONE
if find /etc/apt -mindepth 1 -cnewer /var/lib/apt/lists | grep . > /dev/null; then
if [ ! -d /var/lib/apt/lists ] || { find /etc/apt -mindepth 1 -cnewer /var/lib/apt/lists | grep . > /dev/null; }; then
apt-get $apt_opts update || apt-get $apt_opts update
fi
DONE