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 */
36 struct zpm_package *current_package;
39 struct zpm_dependency {
40 char minpkg[ZPM_PACKAGE_ID_MAX+1];
41 char maxpkg[ZPM_PACKAGE_ID_MAX+1];
42 struct zpm_dependency *next;
46 char tag[ZPM_TAG_MAX+1];
54 /* char pointers are just pointers into the hash table */
55 /* integers/times and such are passed through atoi */
56 /* tags and licenses are trees, NULL if not fetched */
61 /* null if tags not collected */
62 //struct zpm_tree *tags;
66 char *status; /* integer code ? */
67 //struct zpm_tree *licenses;
70 char checksum[ZPM_HASH_STRLEN+1];
71 struct zpm_package *next;
74 int zpm_parse_package(char *pstr, char *name, char *ver, int *rel);
75 char *zpm_findpkg(struct zpm *zpm, char *pkgstr);
76 int zpm_quote(char *value, char *dest, size_t n);
79 char path[ZPM_PATH_MAX];
81 //struct zpm_tree *tags;
85 char hash[ZPM_HASH_STRLEN+1];
86 struct zpm_file *next; /* so you can make a linked list */
89 int zpm_open(struct zpm *pkg, char *path);
90 int zpm_init(struct zpm *pkg, char *path);
91 int zpm_pkgname(char *base, char *version, int release); /* construct a package file name */
93 /* flags for preserving mode, owner, etc */
94 /* puts hash of import in hash */
95 /* path can be a hash, with an "INTERNAL" flag, i.e. internally import */
99 #define ZPM_INTERNAL 0x8
100 #define ZPM_NOBLOB 0x10
101 /* don't run scripts on install */
102 #define ZPM_NOSCRIPTS 0x10
103 /* don't import file to a particular package */
104 #define ZPM_NOPACKAGE 0x20
106 int zpm_import(struct zpm *zp, char *path, uint32_t flags, char *hash);
108 /* tag a file. relative to "current package" */
109 int zpm_tag(struct zpm *zp, char *path, char *tags);
110 /* should this be broken up into separage functions ? */
111 int zpm_md(struct zpm *zp, char *path, int mode, char *owner, char *group, time_t mtime);
113 /* export hash to dest */
114 int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode);
116 /* export path to dest */
117 int zpm_export(struct zpm *zp, char *path, uint32_t flags, char *dest);
119 int zpm_close(struct zpm *zp);
121 /* attach a signature to a package */
122 int zpm_sign(struct zpm *z, size_t s, void *signature);
124 /* set the package info to the nth package, -1 to return count? */
125 /* further import/exports and such will be relative to this package */
126 int zpm_package(struct zpm *zp, int n);
128 /* get file information */
129 int zpm_stat(struct zpm *z, struct zpm_file *f, int n);
131 /* will also set the package context to the new package */
132 int zpm_newpkg(struct zpm *z, char *base, char *version, int release);
135 int zpm_begin(struct zpm *z);
136 int zpm_commit(struct zpm *z);
137 int zpm_rollback(struct zpm *z);
139 /* higher level operations */
141 /* install or uninstall the package */
142 /* flag for keeping the blobs in local */
143 /* what about tag filtering */
144 int zpm_install(struct zpm *z, struct zpm *local, uint32_t flags);
145 int zpm_uninstall(struct zpm *local);
147 /* slurp up the actual blobs */
148 /* what about versioning them if they change */
149 int zpm_preserve(struct zpm *local);
151 /* check file integrity */
152 int zpm_checkinstall(struct zpm *local);
154 int zpm_merge(struct zpm *z, struct zpm *src, uint32_t flags);
157 void uncompresslzma(void *buf, size_t bufsize, FILE *out);
158 void *compresslzma(void *buf, size_t bufsize, size_t *len);
161 #define SQLERROR(x) fprintf(stderr, "%s %d: %s\n", __func__, __LINE__, (x))
162 int zpm_hash(char *path, char *hash, uint32_t flags);
163 int zpm_readopts(struct zpm *pkg, int ac, char **av);
165 int zpm_vercmp(const char *a, const char *b);
167 /* add vercmp collation to db */
168 int zpm_addvercmp(struct zpm *pkg);
170 int zpm_exec(struct zpm *z, const char *sql, int(*callback)(void *, int, char **, char**), void *arg, char **errmsg);
172 int zpm_foreach_path(struct zpm *zpm, char *pkgid,
173 int (*callback)(void *f, int ncols, char **vals, char **cols),
174 void *data, char **errmsg);
176 int zpm_script_hash(struct zpm *zpm, char *pkgstr, char *phase, char *hash);
178 sqlite3_stmt *zpm_dbquery(struct zpm *zpm, char *query, ...);
179 struct zpm *zpm_clearmem(struct zpm *zpm);