1.1 --- a/librazor/razor.c Tue Aug 18 14:04:11 2009 +0100
1.2 +++ b/librazor/razor.c Thu Oct 01 19:54:03 2009 +0100
1.3 @@ -704,6 +704,32 @@
1.4 razor_file_iterator_destroy(fi);
1.5 }
1.6
1.7 +/*
1.8 + * Package data can potentially come from two places. The so-called
1.9 + * metadata (eg., from comps.xml) and from an RPM file. We consider
1.10 + * a package which has additional data from an RPM file as "fixed".
1.11 + * If a package needs fixing, then razor_transaction_fixup_package()
1.12 + * will do so. When considering what packages to add and to remove
1.13 + * we need to take this into account since we always want to add
1.14 + * unfixed packages (otherwise we have a potential conflict between
1.15 + * the existing package data and that present in the RPM).
1.16 + */
1.17 +static int
1.18 +razor_package_is_fixed(struct razor_set *set, struct razor_package *p)
1.19 +{
1.20 + const char *preunprog, *preun, *postunprog, *postun;
1.21 +
1.22 + if (!p)
1.23 + return 0;
1.24 + razor_package_get_details(set, p,
1.25 + RAZOR_DETAIL_PREUNPROG, &preunprog,
1.26 + RAZOR_DETAIL_PREUN, &preun,
1.27 + RAZOR_DETAIL_POSTUNPROG, &postunprog,
1.28 + RAZOR_DETAIL_POSTUN, &postun,
1.29 + RAZOR_DETAIL_LAST);
1.30 + return *preunprog || *preun || *postunprog || *postun;
1.31 +}
1.32 +
1.33 RAZOR_EXPORT void
1.34 razor_set_diff(struct razor_set *set, struct razor_set *upstream,
1.35 razor_diff_callback_t callback, void *data)
1.36 @@ -711,7 +737,7 @@
1.37 struct razor_package_iterator *pi1, *pi2;
1.38 struct razor_package *p1, *p2;
1.39 const char *name1, *name2, *version1, *version2, *arch1, *arch2;
1.40 - int res;
1.41 + int res, is_fixed1, is_fixed2;
1.42
1.43 assert (set != NULL);
1.44 assert (upstream != NULL);
1.45 @@ -724,17 +750,21 @@
1.46 RAZOR_DETAIL_VERSION, &version1,
1.47 RAZOR_DETAIL_ARCH, &arch1,
1.48 RAZOR_DETAIL_LAST);
1.49 + is_fixed1 = razor_package_is_fixed(set, p1);
1.50 razor_package_iterator_next(pi2, &p2,
1.51 RAZOR_DETAIL_NAME, &name2,
1.52 RAZOR_DETAIL_VERSION, &version2,
1.53 RAZOR_DETAIL_ARCH, &arch2,
1.54 RAZOR_DETAIL_LAST);
1.55 + is_fixed2 = razor_package_is_fixed(upstream, p2);
1.56
1.57 while (p1 || p2) {
1.58 if (p1 && p2) {
1.59 res = strcmp(name1, name2);
1.60 if (res == 0)
1.61 res = razor_versioncmp(version1, version2);
1.62 + if (res == 0)
1.63 + res = is_fixed1 - is_fixed2;
1.64 } else {
1.65 res = 0;
1.66 }
1.67 @@ -746,18 +776,22 @@
1.68 callback(RAZOR_DIFF_ACTION_ADD,
1.69 p2, name2, version2, arch2, data);
1.70
1.71 - if (p1 != NULL && res <= 0)
1.72 + if (p1 != NULL && res <= 0) {
1.73 razor_package_iterator_next(pi1, &p1,
1.74 RAZOR_DETAIL_NAME, &name1,
1.75 RAZOR_DETAIL_VERSION, &version1,
1.76 RAZOR_DETAIL_ARCH, &arch1,
1.77 RAZOR_DETAIL_LAST);
1.78 - if (p2 != NULL && res >= 0)
1.79 + is_fixed1 = razor_package_is_fixed(set, p1);
1.80 + }
1.81 + if (p2 != NULL && res >= 0) {
1.82 razor_package_iterator_next(pi2, &p2,
1.83 RAZOR_DETAIL_NAME, &name2,
1.84 RAZOR_DETAIL_VERSION, &version2,
1.85 RAZOR_DETAIL_ARCH, &arch2,
1.86 RAZOR_DETAIL_LAST);
1.87 + is_fixed2 = razor_package_is_fixed(upstream, p2);
1.88 + }
1.89 }
1.90
1.91 razor_package_iterator_destroy(pi1);