2020-10-05 15:52:51 +00:00
|
|
|
/* apk_context.h - Alpine Package Keeper (APK)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Timo Teräs <timo.teras@iki.fi>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef APK_CONTEXT_H
|
|
|
|
#define APK_CONTEXT_H
|
|
|
|
|
|
|
|
#include "apk_print.h"
|
2020-10-09 10:40:14 +00:00
|
|
|
#include "apk_trust.h"
|
2020-10-09 09:44:32 +00:00
|
|
|
#include "apk_io.h"
|
|
|
|
#include "adb.h"
|
2020-10-05 15:52:51 +00:00
|
|
|
|
|
|
|
#define APK_SIMULATE BIT(0)
|
|
|
|
#define APK_CLEAN_PROTECTED BIT(1)
|
|
|
|
#define APK_RECURSIVE BIT(2)
|
|
|
|
#define APK_ALLOW_UNTRUSTED BIT(3)
|
|
|
|
#define APK_PURGE BIT(4)
|
|
|
|
#define APK_INTERACTIVE BIT(5)
|
|
|
|
#define APK_NO_NETWORK BIT(6)
|
|
|
|
#define APK_OVERLAY_FROM_STDIN BIT(7)
|
|
|
|
#define APK_NO_SCRIPTS BIT(8)
|
|
|
|
#define APK_NO_CACHE BIT(9)
|
|
|
|
#define APK_NO_COMMIT_HOOKS BIT(10)
|
|
|
|
|
|
|
|
#define APK_FORCE_OVERWRITE BIT(0)
|
|
|
|
#define APK_FORCE_OLD_APK BIT(1)
|
|
|
|
#define APK_FORCE_BROKEN_WORLD BIT(2)
|
|
|
|
#define APK_FORCE_REFRESH BIT(3)
|
|
|
|
#define APK_FORCE_NON_REPOSITORY BIT(4)
|
|
|
|
#define APK_FORCE_BINARY_STDOUT BIT(5)
|
|
|
|
|
2020-10-09 09:44:32 +00:00
|
|
|
struct apk_database;
|
|
|
|
|
|
|
|
#define APK_OPENF_READ 0x0001
|
|
|
|
#define APK_OPENF_WRITE 0x0002
|
|
|
|
#define APK_OPENF_CREATE 0x0004
|
|
|
|
#define APK_OPENF_NO_INSTALLED 0x0010
|
|
|
|
#define APK_OPENF_NO_SCRIPTS 0x0020
|
|
|
|
#define APK_OPENF_NO_WORLD 0x0040
|
|
|
|
#define APK_OPENF_NO_SYS_REPOS 0x0100
|
|
|
|
#define APK_OPENF_NO_INSTALLED_REPO 0x0200
|
|
|
|
#define APK_OPENF_CACHE_WRITE 0x0400
|
|
|
|
#define APK_OPENF_NO_AUTOUPDATE 0x0800
|
|
|
|
|
|
|
|
#define APK_OPENF_NO_REPOS (APK_OPENF_NO_SYS_REPOS | \
|
|
|
|
APK_OPENF_NO_INSTALLED_REPO)
|
|
|
|
#define APK_OPENF_NO_STATE (APK_OPENF_NO_INSTALLED | \
|
|
|
|
APK_OPENF_NO_SCRIPTS | \
|
|
|
|
APK_OPENF_NO_WORLD)
|
|
|
|
|
2020-10-05 15:52:51 +00:00
|
|
|
struct apk_ctx {
|
|
|
|
unsigned int flags, force, lock_wait;
|
|
|
|
struct apk_out out;
|
|
|
|
struct apk_progress progress;
|
|
|
|
unsigned int cache_max_age;
|
|
|
|
unsigned long open_flags;
|
|
|
|
const char *root;
|
|
|
|
const char *arch;
|
|
|
|
const char *keys_dir;
|
|
|
|
const char *cache_dir;
|
|
|
|
const char *repositories_file;
|
|
|
|
struct apk_string_array *repository_list;
|
|
|
|
struct apk_string_array *private_keys;
|
2020-10-09 09:44:32 +00:00
|
|
|
|
2020-10-09 10:40:14 +00:00
|
|
|
struct apk_trust trust;
|
2020-10-09 09:44:32 +00:00
|
|
|
struct apk_id_cache id_cache;
|
|
|
|
struct apk_database *db;
|
2020-10-09 10:40:14 +00:00
|
|
|
int root_fd;
|
2020-10-05 15:52:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void apk_ctx_init(struct apk_ctx *ac);
|
|
|
|
void apk_ctx_free(struct apk_ctx *ac);
|
2020-10-09 09:44:32 +00:00
|
|
|
int apk_ctx_prepare(struct apk_ctx *ac);
|
|
|
|
|
2020-10-09 10:40:14 +00:00
|
|
|
struct apk_trust *apk_ctx_get_trust(struct apk_ctx *ac);
|
2020-10-09 09:44:32 +00:00
|
|
|
struct apk_id_cache *apk_ctx_get_id_cache(struct apk_ctx *ac);
|
|
|
|
|
|
|
|
static inline int apk_ctx_fd_root(struct apk_ctx *ac) { return ac->root_fd; }
|
|
|
|
static inline time_t apk_ctx_since(struct apk_ctx *ac, time_t since) {
|
|
|
|
return (ac->force & APK_FORCE_REFRESH) ? APK_ISTREAM_FORCE_REFRESH : since;
|
|
|
|
}
|
2020-10-05 15:52:51 +00:00
|
|
|
|
|
|
|
#endif
|