apk.static: --initdb without adding a package?
unlike apk add
, there is no --initdb
option in apk search
, apk fetch
, apk cache
etc. to initialize the db and directory structure in a fresh environment (different --root
or running apk.static on e.g. debian). not even apk fix
, apk update
or apk upgrade
help in this case. there is no top-level command to "(re-)initialize the apk environment idempotently" either.
so if we wanted to use search
, fetch
, cache
or any other command before the first add
, it is simply not possible(!?). the workaround is wasteful: add
some random package with --initdb
, then perform the desired action. otherwise, depending on the command, we are either greeted with:
ERROR: Unable to lock database: No such file or directory
ERROR: Failed to open apk database: No such file or directory
or
WARNING: opening from cache http://dl-cdn.alpinelinux.org/alpine/edge/main: cache not available
WARNING: opening from cache http://dl-cdn.alpinelinux.org/alpine/edge/community: cache not available