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