Compare commits

...

5 Commits

Author SHA1 Message Date
ander 50186d13c9
change find args 2021-11-02 11:33:57 +02:00
ander 4ddbf1e411
add comment about touching 2021-11-01 23:10:49 +02:00
ander e7d8fb874d
do not create it as file, it must be dir 2021-11-01 23:00:15 +02:00
ander e24165304c
touch /var/lib/apt/lists to make it newer 2021-11-01 22:58:12 +02:00
ander f74a06a257
POC: add smart index updating 2021-11-01 22:50:31 +02:00
2 changed files with 14 additions and 9 deletions

View File

@ -0,0 +1,9 @@
#!/bin/sh -e
if [ ! -d /var/lib/apt/lists ] \
|| [ -n "$( find /etc/apt -newer /var/lib/apt/lists )" ] \
|| [ ! -f /var/cache/apt/pkgcache.bin ] \
|| [ "$( stat --format %Y /var/cache/apt/pkgcache.bin )" -lt "$( date +%s -d '-1 day' )" ]
then
echo 'update'
fi

View File

@ -92,15 +92,11 @@ case "$state_should" in
# See more: ticket #861
# https://code.ungleich.ch/ungleich-public/cdist/-/issues/861
apt_opts="-o Acquire::AllowReleaseInfoChange::Suite=true -o Acquire::AllowReleaseInfoChange::Version=true"
# following is bit ugly, but important hack.
# due to how cdist config run works, there isn't
# currently better way to do it :(
cat << EOF
if [ ! -f /var/cache/apt/pkgcache.bin ] || [ "\$( stat --format %Y /var/cache/apt/pkgcache.bin )" -lt "\$( date +%s -d '-1 day' )" ]
then echo apt-get $apt_opts update > /dev/null 2>&1 || true
fi
EOF
if [ "$(cat "$__object/explorer/index")" = 'update' ]; then
# make /var/lib/apt/lists newer because apt-get update might not always do this
echo 'if [ -d /var/lib/apt/lists ]; then touch /var/lib/apt/lists; fi'
echo "apt-get $apt_opts update || true"
fi
if [ -n "$version" ]; then
name="${name}=${version}"
fi