#ifndef ZPM_H_ #define ZPM_H_ 1 #include #include #include struct zpm { sqlite3 *db; char *path; /* path to package file */ char *version; int release; char *pkgname; time_t installed; /* install time, 0 for not installed */ }; struct zpm_file { char *path; int mode; char *tags; char *owner; char *group; time_t mtime; struct zpm_file *next; /* so you can make a linked list */ }; /* NULL? Create? */ int zpm_open(struct zpm *pkg, char *path); int zpm_pkgname(char *base, char *version, int release); /* construct a package file name */ /* flags for preserving mode, owner, etc */ /* puts hash of import in hash */ /* path can be a hash, with an "INTERNAL" flag, i.e. internally import */ #define ZPM_MODE 0x1 #define ZPM_OWNER 0x2 #define ZPM_MTIME 0x4 #define ZPM_INTERNAL 0x8 #define ZPM_NOBLOB 0x10 /* don't run scripts on install */ #define ZPM_NOSCRIPTS 0x10 /* don't import file to a particular package */ #define ZPM_NOPACKAGE 0x20 int zpm_import(struct zpm *zp, char *path, uint32_t flags, char *hash); /* tag a file. relative to "current package" */ int zpm_tag(struct zpm *zp, char *path, char *tags); /* should this be broken up into separage functions ? */ int zpm_md(struct zpm *zp, char *path, int mode, char *owner, char *group, time_t mtime); /* export hash to dest */ int zpm_extract(struct zpm *pkg, char *hash, char *path, int mode); /* export path to dest */ int zpm_export(struct zpm *zp, char *path, uint32_t flags, char *dest); int zpm_close(struct zpm *zp); /* attach a signature to a package */ int zpm_sign(struct zpm *z, size_t s, void *signature); /* set the package info to the nth package, -1 to return count? */ /* further import/exports and such will be relative to this package */ int zpm_package(struct zpm *zp, int n); /* get file information */ int zpm_stat(struct zpm *z, struct zpm_file *f, int n); /* will also set the package context to the new package */ int zpm_newpkg(struct zpm *z, char *base, char *version, int release); /* transactions */ int zpm_begin(struct zpm *z); int zpm_commit(struct zpm *z); int zpm_rollback(struct zpm *z); /* higher level operations */ /* install or uninstall the package */ /* flag for keeping the blobs in local */ /* what about tag filtering */ int zpm_install(struct zpm *z, struct zpm *local, uint32_t flags); int zpm_uninstall(struct zpm *local); /* slurp up the actual blobs */ /* what about versioning them if they change */ int zpm_preserve(struct zpm *local); /* check file integrity */ int zpm_checkinstall(struct zpm *local); int zpm_merge(struct zpm *z, struct zpm *src, uint32_t flags); void uncompresslzma(void *buf, size_t bufsize, FILE *out); void *compresslzma(void *buf, size_t bufsize, size_t *len); #define SQLERROR(x) fprintf(stderr, "%s %d: %s\n", __func__, __LINE__, (x)) int zpm_hash(char *path, char *hash, uint32_t flags); int zpm_readopts(struct zpm *pkg, int ac, char **av); #endif