]> git.ipfire.org Git - pakfire.git/blob - src/libpakfire/include/pakfire/pakfire.h
Make pakfire non-interactive by default
[pakfire.git] / src / libpakfire / include / pakfire / pakfire.h
1 /*#############################################################################
2 # #
3 # Pakfire - The IPFire package management system #
4 # Copyright (C) 2017 Pakfire development team #
5 # #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
18 # #
19 #############################################################################*/
20
21 #ifndef PAKFIRE_PAKFIRE_H
22 #define PAKFIRE_PAKFIRE_H
23
24 #include <stdarg.h>
25 #include <stddef.h>
26 #include <stdio.h>
27 #include <sys/stat.h>
28 #include <time.h>
29
30 struct pakfire;
31
32 enum pakfire_digests {
33 PAKFIRE_DIGEST_NONE = 0,
34 PAKFIRE_DIGEST_SHA1 = 1 << 0,
35 PAKFIRE_DIGEST_SHA256 = 1 << 1,
36 PAKFIRE_DIGEST_SHA512 = 1 << 2,
37 };
38
39 #include <pakfire/key.h>
40 #include <pakfire/packagelist.h>
41 #include <pakfire/parser.h>
42 #include <pakfire/repo.h>
43 #include <pakfire/repolist.h>
44
45 enum pakfire_flags {
46 PAKFIRE_FLAGS_INTERACTIVE = (1 << 0),
47 PAKFIRE_FLAGS_OFFLINE = (1 << 1),
48 PAKFIRE_FLAGS_BUILD = (1 << 2),
49 PAKFIRE_FLAGS_DISABLE_CCACHE = (1 << 3),
50 PAKFIRE_FLAGS_DISABLE_SNAPSHOT = (1 << 4),
51 PAKFIRE_FLAGS_DISABLE_RAMDISK = (1 << 5),
52 };
53
54 // Callbacks
55
56 struct pakfire_callbacks {
57 void* data;
58
59 // Logging
60 void (*log)(void* data, int priority, const char* file,
61 int line, const char* fn, const char* format, va_list args);
62
63 // Status, Progress & Speed
64 void (*status)(void* data, const char* message);
65 void (*progress)(void* data, int progress);
66 void (*speed)(void* data, const char* speed);
67 };
68
69 int pakfire_create(struct pakfire** pakfire, const char* path, const char* arch,
70 const char* conf, int flags, const struct pakfire_callbacks* callbacks);
71
72 struct pakfire* pakfire_ref(struct pakfire* pakfire);
73 struct pakfire* pakfire_unref(struct pakfire* pakfire);
74
75 const char* pakfire_get_path(struct pakfire* pakfire);
76
77 int pakfire_clean(struct pakfire* pakfire, int flags);
78 int pakfire_refresh(struct pakfire* pakfire, int flags);
79
80 int pakfire_bind(struct pakfire* pakfire, const char* src, const char* dst, int flags);
81
82 int pakfire_list_keys(struct pakfire* pakfire, struct pakfire_key*** keys);
83
84 int pakfire_copy_in(struct pakfire* pakfire, const char* src, const char* dst);
85 int pakfire_copy_out(struct pakfire* pakfire, const char* src, const char* dst);
86
87 const char* pakfire_get_arch(struct pakfire* pakfire);
88
89 int pakfire_version_compare(struct pakfire* pakfire, const char* evr1, const char* evr2);
90
91 struct pakfire_repolist* pakfire_get_repos(struct pakfire* pakfire);
92 struct pakfire_repo* pakfire_get_repo(struct pakfire* pakfire, const char* name);
93
94 int pakfire_whatprovides(struct pakfire* pakfire, const char* what, int flags,
95 struct pakfire_packagelist** list);
96 int pakfire_whatrequires(struct pakfire* pakfire, const char* what, int flags,
97 struct pakfire_packagelist** list);
98
99 // Search
100
101 enum pakfire_search_flags {
102 PAKFIRE_SEARCH_NAME_ONLY = (1 << 0),
103 };
104
105 int pakfire_search(struct pakfire* pakfire, const char* what, int flags,
106 struct pakfire_packagelist** list);
107
108 // Logging
109
110 int pakfire_log_get_priority(struct pakfire* pakfire);
111 void pakfire_log_set_priority(struct pakfire* pakfire, int priority);
112
113 // Install/Erase/Update
114
115 int pakfire_install(struct pakfire* pakfire, int solver_flags, const char** packages,
116 const char** locks, int job_flags, int* changed);
117 int pakfire_erase(struct pakfire* pakfire, int solver_flags, const char** packages,
118 const char** locks, int job_flags, int* changed);
119 int pakfire_update(struct pakfire* pakfire, int solver_flags, const char** packages,
120 const char** locks, int jobs_flags, int* changed);
121
122 // Check
123
124 int pakfire_check(struct pakfire* pakfire);
125
126 // Sync
127
128 int pakfire_sync(struct pakfire* pakfire, int solver_flags, int flags, int* changed);
129
130 #ifdef PAKFIRE_PRIVATE
131
132 #include <gpgme.h>
133 #include <solv/pool.h>
134
135 #include <pakfire/config.h>
136
137 int pakfire_on_root(struct pakfire* pakfire);
138
139 void pakfire_log(struct pakfire* pakfire, int priority, const char *file,
140 int line, const char *fn, const char *format, ...)
141 __attribute__((format(printf, 6, 7)));
142
143 int pakfire_has_flag(struct pakfire* pakfire, int flag);
144
145 struct pakfire_config* pakfire_get_config(struct pakfire* pakfire);
146 int pakfire_is_mountpoint(struct pakfire* pakfire, const char* path);
147
148 void pakfire_call_status_callback(struct pakfire* pakfire, const char* message, ...);
149 void pakfire_call_progress_callback(struct pakfire* pakfire, int progress);
150
151 gpgme_ctx_t pakfire_get_gpgctx(struct pakfire* pakfire);
152
153 const char* pakfire_get_distro_name(struct pakfire* pakfire);
154 const char* pakfire_get_distro_id(struct pakfire* pakfire);
155 const char* pakfire_get_distro_vendor(struct pakfire* pakfire);
156 const char* pakfire_get_distro_version(struct pakfire* pakfire);
157 const char* pakfire_get_distro_version_id(struct pakfire* pakfire);
158
159 const char* pakfire_get_keystore_path(struct pakfire* pakfire);
160
161 #define pakfire_make_path(pakfire, dst, path) \
162 __pakfire_make_path(pakfire, dst, sizeof(dst) - 1, path)
163 int __pakfire_make_path(struct pakfire* pakfire, char* dst, size_t length, const char* path);
164
165 #define pakfire_make_cache_path(pakfire, path, format, ...) \
166 __pakfire_make_cache_path(pakfire, path, sizeof(path) - 1, format, __VA_ARGS__)
167
168 int __pakfire_make_cache_path(struct pakfire* pakfire, char* path, size_t length,
169 const char* format, ...) __attribute__((format(printf, 4, 5)));
170
171 void pakfire_pool_has_changed(struct pakfire* pakfire);
172 void pakfire_pool_internalize(struct pakfire* pakfire);
173
174 Pool* pakfire_get_solv_pool(struct pakfire* pakfire);
175
176 struct pakfire_repo* pakfire_get_installed_repo(struct pakfire* pakfire);
177
178 // Archive helpers
179 struct archive* pakfire_make_archive_disk_reader(struct pakfire* pakfire, int internal);
180 struct archive* pakfire_make_archive_disk_writer(struct pakfire* pakfire);
181
182 // Build Stuff
183 int pakfire_build_setup(struct pakfire* pakfire);
184
185 #endif
186
187 #endif /* PAKFIRE_PAKFIRE_H */