11 #define ZPM_HASH_STRLEN 64
14 #define ZPM_PATH_MAX PATH_MAX
16 #define ZPM_PATH_MAX 256
19 #define ZPM_PACKAGE_NAME_MAX 191
20 #define ZPM_PACKAGE_VERSION_MAX 58
21 #define ZPM_PACKAGE_RELEASE_MAX 4
22 #define ZPM_PACKAGE_ID_MAX 255
24 #define ZPM_TAG_MAX 15
30 char *path; /* path to db file */
34 struct zpm_package *current_package;
37 struct zpm_dependency {
38 char minpkg[ZPM_PACKAGE_ID_MAX+1];
39 char maxpkg[ZPM_PACKAGE_ID_MAX+1];
40 struct zpm_dependency *next;
44 char tag[ZPM_TAG_MAX+1];
52 /* char pointers are just pointers into the hash table */
53 /* integers/times and such are passed through atoi */
54 /* tags and licenses are trees, NULL if not fetched */
59 /* null if tags not collected */
60 //struct zpm_tree *tags;
64 char *status; /* integer code ? */
65 //struct zpm_tree *licenses;
68 char checksum[ZPM_HASH_STRLEN+1];
69 struct zpm_package *next;
72 int zpm_parse_package(char *pstr, char *name, char *ver, int *rel);
73 char *zpm_findpkg(struct zpm *zpm, char *pkgstr);
74 int zpm_quote(char *value, char *dest, size_t n);
77 char path[ZPM_PATH_MAX];
79 //struct zpm_tree *tags;
83 char hash[ZPM_HASH_STRLEN+1];
84 struct zpm_file *next; /* so you can make a linked list */
87 int zpm_open(struct zpm *pkg, char *path);
88 int zpm_init(struct zpm *pkg, char *path);
89 int zpm_pkgname(char *base, char *version, int release); /* construct a package file name */
91 /* flags for preserving mode, owner, etc */
92 /* puts hash of import in hash */
93 /* path can be a hash, with an "INTERNAL" flag, i.e. internally import */
97 #define ZPM_INTERNAL 0x8
98 #define ZPM_NOBLOB 0x10
99 /* don't run scripts on install */
100 #define ZPM_NOSCRIPTS 0x10
101 /* don't import file to a particular package */
102 #define ZPM_NOPACKAGE 0x20
104 int zpm_import(struct zpm *zp, char *path, uint32_t flags, char *hash);
106 /* tag a file. relative to "current package" */
107 int zpm_tag(struct zpm *zp, char *path, char *tags);
108 /* should this be broken up into separage functions ? */
109 int zpm_md(struct zpm *zp, char *path, int mode, char *owner, char *group, time_t mtime);
111 /* export hash to dest */
112 int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode);
114 /* export path to dest */
115 int zpm_export(struct zpm *zp, char *path, uint32_t flags, char *dest);
117 int zpm_close(struct zpm *zp);
119 /* attach a signature to a package */
120 int zpm_sign(struct zpm *z, size_t s, void *signature);
122 /* set the package info to the nth package, -1 to return count? */
123 /* further import/exports and such will be relative to this package */
124 int zpm_package(struct zpm *zp, int n);
126 /* get file information */
127 int zpm_stat(struct zpm *z, struct zpm_file *f, int n);
129 /* will also set the package context to the new package */
130 int zpm_newpkg(struct zpm *z, char *base, char *version, int release);
133 int zpm_begin(struct zpm *z);
134 int zpm_commit(struct zpm *z);
135 int zpm_rollback(struct zpm *z);
137 /* higher level operations */
139 /* install or uninstall the package */
140 /* flag for keeping the blobs in local */
141 /* what about tag filtering */
142 int zpm_install(struct zpm *z, struct zpm *local, uint32_t flags);
143 int zpm_uninstall(struct zpm *local);
145 /* slurp up the actual blobs */
146 /* what about versioning them if they change */
147 int zpm_preserve(struct zpm *local);
149 /* check file integrity */
150 int zpm_checkinstall(struct zpm *local);
152 int zpm_merge(struct zpm *z, struct zpm *src, uint32_t flags);
155 void uncompresslzma(void *buf, size_t bufsize, FILE *out);
156 void *compresslzma(void *buf, size_t bufsize, size_t *len);
159 #define SQLERROR(x) fprintf(stderr, "%s %d: %s\n", __func__, __LINE__, (x))
160 int zpm_hash(char *path, char *hash, uint32_t flags);
161 int zpm_readopts(struct zpm *pkg, int ac, char **av);
163 int zpm_vercmp(const char *a, const char *b);
165 /* add vercmp collation to db */
166 int zpm_addvercmp(struct zpm *pkg);
168 int zpm_exec(struct zpm *z, const char *sql, int(*callback)(void *, int, char **, char**), void *arg, char **errmsg);
170 int zpm_foreach_path(struct zpm *zpm, char *pkgid,
171 int (*callback)(void *f, int ncols, char **vals, char **cols),
172 void *data, char **errmsg);
174 int zpm_script_hash(struct zpm *zpm, char *pkgstr, char *phase, char *hash);
176 sqlite3_stmt *zpm_dbquery(struct zpm *zpm, char *query, ...);