From 30bdf94c2b444ff475a32e7b0c569e8c3cf05797 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 15 Feb 2008 20:17:57 -0600 Subject: Rework delta struct and modify code accordingly Start to move the delta struct away from an assumed package name scheme and towards something that is package (or even filename) agnostic. This will allow us much greater flexibility in the usage of deltas (maybe even sync DBs some day) as well as allowing code outside of delta.h/delta.c to be much cleaner with less of a need for snprintf() calls. Signed-off-by: Dan McGee --- lib/libalpm/sync.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'lib/libalpm/sync.c') diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index decd52b5..5146a994 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -717,7 +717,6 @@ static int apply_deltas(pmtrans_t *trans, alpm_list_t *patches) pmpkg_t *pkg; pmdelta_t *d; char command[PATH_MAX], fname[PATH_MAX]; - char pkgfilename[PATH_MAX]; pkg = alpm_list_getdata(p); p = alpm_list_next(p); @@ -742,26 +741,23 @@ static int apply_deltas(pmtrans_t *trans, alpm_list_t *patches) /* build the patch command */ snprintf(command, PATH_MAX, - "xdelta patch" /* the command */ - " %s/%s" /* the delta */ - " %s/%s-%s-%s" PKGEXT /* the 'from' package */ - " %s/%s-%s-%s" PKGEXT, /* the 'to' package */ - cachedir, d->filename, - cachedir, pkg->name, d->from, pkg->arch, - cachedir, pkg->name, d->to, pkg->arch); + "xdelta patch" /* the command */ + " %s/%s" /* the delta */ + " %s/%s" /* the 'from' package */ + " %s/%s", /* the 'to' package */ + cachedir, d->delta, + cachedir, d->from, + cachedir, d->to); _alpm_log(PM_LOG_DEBUG, _("command: %s\n"), command); - snprintf(pkgfilename, PATH_MAX, "%s-%s-%s" PKGEXT, - pkg->name, d->to, pkg->arch); - - EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_START, pkgfilename, d->filename); + EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_START, d->to, d->delta); if(system(command) == 0) { EVENT(trans, PM_TRANS_EVT_DELTA_PATCH_DONE, NULL, NULL); /* delete the delta file */ - snprintf(fname, PATH_MAX, "%s/%s", cachedir, d->filename); + snprintf(fname, PATH_MAX, "%s/%s", cachedir, d->delta); unlink(fname); /* Delete the 'from' package but only if it is an intermediate @@ -769,8 +765,7 @@ static int apply_deltas(pmtrans_t *trans, alpm_list_t *patches) * as if deltas were not used. Delete the package file if the * previous iteration of the loop used the same package. */ if(pkg == lastpkg) { - snprintf(fname, PATH_MAX, "%s/%s-%s-%s" PKGEXT, - cachedir, pkg->name, d->from, pkg->arch); + snprintf(fname, PATH_MAX, "%s/%s", cachedir, d->from); unlink(fname); } else { lastpkg = pkg; @@ -864,12 +859,12 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data) for(dlts = delta_path; dlts; dlts = alpm_list_next(dlts)) { pmdelta_t *d = (pmdelta_t *)alpm_list_getdata(dlts); - char *fpath2 = _alpm_filecache_find(d->filename); + char *fpath2 = _alpm_filecache_find(d->delta); if(!fpath2) { /* add the delta filename to the download list if - * it's not in the cache*/ - files = alpm_list_add(files, strdup(d->filename)); + * it's not in the cache */ + files = alpm_list_add(files, strdup(d->delta)); } /* save the package and delta so that the xdelta patch -- cgit v1.2.3-54-g00ecf