]> pd.if.org Git - zpackage/blob - zpm.h
add zpm-hash program
[zpackage] / zpm.h
1 #include <stdint.h>
2 #include <time.h>
3 #include <sqlite3.h>
4
5 struct zpm {
6         sqlite3 *db;
7         char *path; /* path to package file */
8         char *version;
9         int release;
10         char *pkgname;
11         time_t installed; /* install time, 0 for not installed */
12 };
13
14 struct zpm_file {
15         char *path;
16         int mode;
17         char *tags;
18         char *owner;
19         char *group;
20         time_t mtime;
21         struct zpm_file *next; /* so you can make a linked list */
22 };
23
24 /* NULL?  Create? */
25 int zpm_open(struct zpm *pkg, char *path);
26 int zpm_pkgname(char *base, char *version, int release); /* construct a package file name */
27
28 /* flags for preserving mode, owner, etc */
29 /* puts hash of import in hash */
30 /* path can be a hash, with an "INTERNAL" flag, i.e. internally import */
31 #define ZPM_MODE 0x1
32 #define ZPM_OWNER 0x2
33 #define ZPM_MTIME 0x4
34 #define ZPM_INTERNAL 0x8
35 #define ZPM_NOBLOB 0x10
36 /* don't run scripts on install */
37 #define ZPM_NOSCRIPTS 0x10
38 /* don't import file to a particular package */
39 #define ZPM_NOPACKAGE 0x20
40
41 int zpm_import(struct zpm *zp, char *path, uint32_t flags, char *hash);
42
43 /* tag a file.  relative to "current package" */
44 int zpm_tag(struct zpm *zp, char *path, char *tags);
45 /* should this be broken up into separage functions ? */
46 int zpm_md(struct zpm *zp, char *path, int mode, char *owner, char *group, time_t mtime);
47
48 /* export hash to dest */
49 int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode);
50
51 /* export path to dest */
52 int zpm_export(struct zpm *zp, char *path, uint32_t flags, char *dest);
53
54 int zpm_close(struct zpm *zp);
55
56 /* attach a signature to a package */
57 int zpm_sign(struct zpm *z, size_t s, void *signature);
58
59 /* set the package info to the nth package, -1 to return count? */
60 /* further import/exports and such will be relative to this package */
61 int zpm_package(struct zpm *zp, int n);
62
63 /* get file information */
64 int zpm_stat(struct zpm *z, struct zpm_file *f, int n);
65
66 /* will also set the package context to the new package */
67 int zpm_newpkg(struct zpm *z, char *base, char *version, int release);
68
69 /* transactions */
70 int zpm_begin(struct zpm *z);
71 int zpm_commit(struct zpm *z);
72 int zpm_rollback(struct zpm *z);
73
74 /* higher level operations */
75
76 /* install or uninstall the package */
77 /* flag for keeping the blobs in local */
78 /* what about tag filtering */
79 int zpm_install(struct zpm *z, struct zpm *local, uint32_t flags);
80 int zpm_uninstall(struct zpm *local);
81
82 /* slurp up the actual blobs */
83 /* what about versioning them if they change */
84 int zpm_preserve(struct zpm *local);
85
86 /* check file integrity */
87 int zpm_checkinstall(struct zpm *local);
88
89 int zpm_merge(struct zpm *z, struct zpm *src, uint32_t flags);
90
91 void uncompresslzma(void *buf, size_t bufsize, FILE *out);
92 void *compresslzma(void *buf, size_t bufsize, size_t *len);
93 #define SQLERROR(x) fprintf(stderr, "%s %d: %s\n", __func__, __LINE__, (x))
94 int zpm_hash(char *path, char *hash, uint32_t flags);