__package_update_index does not update on new installations if --maxage given
By setup new lxc containers, some default manifests are run (which also runs every time a container gets reconfigured). In these manifests,
__package_update_index --maxage $((60 * 60 * 24)) and several
__package types get called.
These fail because the package index is not up to date (up to this, no
__package_update_index got really executed). By debugging this, the currage explorer echos
0 if it does not find the specific file to stat. After creating a brand new lxc container, the specific file do not exist. Therefor, the
gencode-remote exists, because the explorer returned a lower value than the maxage parameter.
In the lxc container installation, no package index update was done, so there is no cache file to stat. In such case, the type should rather assume no index update was done and do an update.
I think this can be solved several ways (but don't know the best):
- echoing a "max integer" constant which will always be higher than the maxage parameter (does this exist in a shell env?)
- thread the value
0special and make an index update; theoretical, the type could be executed again as fast as the time difference is still
0, which would be a false positive
- echoing a special non-numeric case to indicate this problem (also, this could be
-1, which is a slightly better solution than 2.); the
gencode-remotemust then first check if this case happened before comparing both values as integers