12 #include <lib/jsw/jsw_atree.h>
14 #define ZPM_HASH_STRLEN 64
17 #define ZPM_PATH_MAX PATH_MAX
19 #define ZPM_PATH_MAX 256
22 #define ZPM_LOCAL_DB "/var/lib/zpm/local.db"
24 #define ZPM_PACKAGE_NAME_MAX 191
25 #define ZPM_PACKAGE_VERSION_MAX 58
26 #define ZPM_PACKAGE_RELEASE_MAX 4
27 #define ZPM_PACKAGE_ID_MAX 255
29 #define ZPM_TAG_MAX 15
35 char *path; /* path to db file */
41 struct zpm_package *current_package;
44 struct zpm_dependency {
45 char minpkg[ZPM_PACKAGE_ID_MAX+1];
46 char maxpkg[ZPM_PACKAGE_ID_MAX+1];
47 struct zpm_dependency *next;
51 char tag[ZPM_TAG_MAX+1];
57 struct jsw_hash_t *ht;
59 /* char pointers are just pointers into the hash table */
60 /* integers/times and such are passed through atoi */
61 /* tags and licenses are trees, NULL if not fetched */
66 /* null if tags not collected */
67 //struct zpm_tree *tags;
71 char *status; /* integer code ? */
72 //struct zpm_tree *licenses;
75 char checksum[ZPM_HASH_STRLEN+1];
76 struct zpm_package *next;
79 int zpm_parse_package(char *pstr, char *name, char *ver, int *rel);
80 char *zpm_findpkg(struct zpm *zpm, char *pkgstr, char *where);
81 int zpm_findhash(struct zpm *zpm, char *find, char *dest);
82 char *zpm_findlib(struct zpm *zpm, char *soname, char *where);
83 int zpm_libraries_needed(struct zpm *zpm, char *pkgid, jsw_atree_t *list);
84 int zpm_quote(char *value, char *dest, size_t n);
87 char path[ZPM_PATH_MAX];
89 //struct zpm_tree *tags;
93 char hash[ZPM_HASH_STRLEN+1];
94 struct zpm_file *next; /* so you can make a linked list */
97 int zpm_open(struct zpm *pkg, char *path);
98 int zpm_init(struct zpm *pkg, char *path);
99 int zpm_pkgname(char *base, char *version, int release); /* construct a package file name */
101 /* flags for preserving mode, owner, etc */
102 /* puts hash of import in hash */
103 /* path can be a hash, with an "INTERNAL" flag, i.e. internally import */
105 #define ZPM_OWNER 0x2
106 #define ZPM_MTIME 0x4
107 #define ZPM_INTERNAL 0x8
108 #define ZPM_NOBLOB 0x10
109 /* don't run scripts on install */
110 #define ZPM_NOSCRIPTS 0x10
111 /* don't import file to a particular package */
112 #define ZPM_NOPACKAGE 0x20
114 int zpm_import(struct zpm *zp, char *path, uint32_t flags, char *hash);
116 /* tag a file. relative to "current package" */
117 int zpm_tag(struct zpm *zp, char *path, char *tags);
118 /* should this be broken up into separage functions ? */
119 int zpm_md(struct zpm *zp, char *path, int mode, char *owner, char *group, time_t mtime);
121 /* export hash to dest */
122 int zpm_extract(struct zpm *pkg, char *hash, char *path, mode_t mode);
124 /* export path to dest */
125 int zpm_export(struct zpm *zp, char *path, uint32_t flags, char *dest);
127 int zpm_close(struct zpm *zp);
129 /* attach a signature to a package */
130 int zpm_sign(struct zpm *z, size_t s, void *signature);
132 /* set the package info to the nth package, -1 to return count? */
133 /* further import/exports and such will be relative to this package */
134 int zpm_package(struct zpm *zp, int n);
136 /* get file information */
137 int zpm_stat(struct zpm *z, struct zpm_file *f, int n);
139 /* will also set the package context to the new package */
140 int zpm_newpkg(struct zpm *z, char *base, char *version, int release);
143 int zpm_begin(struct zpm *z);
144 int zpm_commit(struct zpm *z);
145 int zpm_rollback(struct zpm *z);
147 /* higher level operations */
149 /* install or uninstall the package */
150 /* flag for keeping the blobs in local */
151 /* what about tag filtering */
152 int zpm_install(struct zpm *z, struct zpm *local, uint32_t flags);
153 int zpm_uninstall(struct zpm *local);
155 /* slurp up the actual blobs */
156 /* what about versioning them if they change */
157 int zpm_preserve(struct zpm *local);
159 /* check file integrity */
160 int zpm_checkinstall(struct zpm *local);
162 int zpm_merge(struct zpm *z, struct zpm *src, uint32_t flags);
164 ssize_t uncompresslzma(void *buf, size_t bufsize, int outfd);
165 void *compresslzma(void *buf, size_t bufsize, size_t *len);
167 #define SQLERROR(x) fprintf(stderr, "%s %d: %s\n", __func__, __LINE__, (x))
168 int zpm_hash(char *path, char *hash, uint32_t flags);
169 int zpm_readopts(struct zpm *pkg, int ac, char **av);
171 int zpm_vercmp(const char *a, const char *b);
173 /* add vercmp collation to db */
174 int zpm_addvercmp(struct zpm *pkg);
176 int zpm_exec(struct zpm *z, const char *sql, int(*callback)(void *, int, char **, char**), void *arg, char **errmsg);
178 int zpm_foreach_path(struct zpm *zpm, char *pkgid, char *where,
179 int (*callback)(void *f, int ncols, char **vals, char **cols),
180 void *data, char **errmsg);
181 int zpm_foreach_package(struct zpm *zpm, char *where,
182 int (*callback)(void *cbdata, int ncols, char **vals, char **cols),
183 void *data, char **errmsg);
185 int zpm_script_hash(struct zpm *zpm, char *pkgstr, char *phase, char *hash);
186 int zpm_script_set(struct zpm *zpm, char *pkgstr, char *phase, char *hash);
187 int zpm_foreach_script(struct zpm *zpm, char *pkgstr, char *stage, void *cbd,
188 int (*cb)(void *ud, const char *pkg, const char *stage, const char *hash));
190 int zpm_package_hash(struct zpm *zpm, char *pkgid, char *hash);
191 int zpm_package_sethash(struct zpm *zpm, char *pkgid, char *hash);
193 sqlite3_stmt *zpm_dbqueryv(struct zpm *zpm, char *query, va_list args);
194 sqlite3_stmt *zpm_dbquery(struct zpm *zpm, char *query, ...);
195 char *zpm_db_string(struct zpm *zpm, char *query, ...);
196 int zpm_db_int(struct zpm *zpm, char *query, ...);
197 void zpm_db_run(struct zpm *zpm, char *query, ...);
198 void zpm_seterror(struct zpm *zpm, char *msgfmt, ...);
200 struct zpm *zpm_clearmem(struct zpm *zpm);
204 time_t ts; /* or timespec */
213 void zpm_note_ack(struct zpm *zpm, int64_t note);
214 void zpm_note_unack(struct zpm *zpm, int64_t note);
215 void zpm_note_del(struct zpm *zpm, int64_t note);
216 int64_t zpm_note(struct zpm *zpm, struct zpm_note *n, unsigned int flags);
217 void zpm_note_free(struct zpm_note *n);
218 int zpm_notes(struct zpm *zpm, int n, struct zpm_note *note);
219 int64_t zpm_note_next(struct zpm *zpm, struct zpm_note *n);
220 int64_t zpm_note_add(struct zpm *zpm, char *pkgid, char *path, char *filehash,
222 int zpm_notes_available(struct zpm *zpm, int flags);