Commit dac30d50 authored by Paul Spooren's avatar Paul Spooren Committed by Timo Teräs

database: automatically create missing cache dir

On some systems the `/var/` dir is mounted in a tmpfs which is reseted
after each reboot. For that reason no post-install script can handle the
creation of the cache dir at `/var/cache/apk`.

Check on database opnening if the folder is available, if not create it.
Fixes #10715Signed-off-by: Paul Spooren's avatarPaul Spooren <mail@aparcar.org>
parent 7c2a3657
Pipeline #51684 passed with stage
in 40 seconds
......@@ -1660,6 +1660,12 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
if (fd >= 0) close(fd);
db->cache_dir = apk_static_cache_dir;
db->cache_fd = openat(db->root_fd, db->cache_dir, O_RDONLY | O_CLOEXEC);
if (db->cache_fd < 0) {
mkdirat(db->root_fd, "var/cache", 0755);
mkdirat(db->root_fd, "var/cache/apk", 0755);
db->cache_fd = openat(db->root_fd, db->cache_dir, O_RDONLY | O_CLOEXEC);
if (db->cache_fd < 0) goto ret_errno;
}
}
db->keys_fd = openat(db->root_fd,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment