summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2008-02-15 20:17:57 -0600
committerDan McGee <dan@archlinux.org>2008-04-26 11:30:12 -0500
commit30bdf94c2b444ff475a32e7b0c569e8c3cf05797 (patch)
tree408802e82996905879372deabee8123c5fa5d98e /lib/libalpm/sync.c
parentff9744aa1f9d3da380e722fd44a07b8c8a68d101 (diff)
downloadpacman-30bdf94c2b444ff475a32e7b0c569e8c3cf05797.tar.xz
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 <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c31
1 files changed, 13 insertions, 18 deletions
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