diff -r 6e73f3f08309 -r ef9237601f24 librazor/razor.c --- a/librazor/razor.c Tue Aug 18 14:04:11 2009 +0100 +++ b/librazor/razor.c Thu Oct 01 19:54:03 2009 +0100 @@ -704,6 +704,32 @@ razor_file_iterator_destroy(fi); } +/* + * Package data can potentially come from two places. The so-called + * metadata (eg., from comps.xml) and from an RPM file. We consider + * a package which has additional data from an RPM file as "fixed". + * If a package needs fixing, then razor_transaction_fixup_package() + * will do so. When considering what packages to add and to remove + * we need to take this into account since we always want to add + * unfixed packages (otherwise we have a potential conflict between + * the existing package data and that present in the RPM). + */ +static int +razor_package_is_fixed(struct razor_set *set, struct razor_package *p) +{ + const char *preunprog, *preun, *postunprog, *postun; + + if (!p) + return 0; + razor_package_get_details(set, p, + RAZOR_DETAIL_PREUNPROG, &preunprog, + RAZOR_DETAIL_PREUN, &preun, + RAZOR_DETAIL_POSTUNPROG, &postunprog, + RAZOR_DETAIL_POSTUN, &postun, + RAZOR_DETAIL_LAST); + return *preunprog || *preun || *postunprog || *postun; +} + RAZOR_EXPORT void razor_set_diff(struct razor_set *set, struct razor_set *upstream, razor_diff_callback_t callback, void *data) @@ -711,7 +737,7 @@ struct razor_package_iterator *pi1, *pi2; struct razor_package *p1, *p2; const char *name1, *name2, *version1, *version2, *arch1, *arch2; - int res; + int res, is_fixed1, is_fixed2; assert (set != NULL); assert (upstream != NULL); @@ -724,17 +750,21 @@ RAZOR_DETAIL_VERSION, &version1, RAZOR_DETAIL_ARCH, &arch1, RAZOR_DETAIL_LAST); + is_fixed1 = razor_package_is_fixed(set, p1); razor_package_iterator_next(pi2, &p2, RAZOR_DETAIL_NAME, &name2, RAZOR_DETAIL_VERSION, &version2, RAZOR_DETAIL_ARCH, &arch2, RAZOR_DETAIL_LAST); + is_fixed2 = razor_package_is_fixed(upstream, p2); while (p1 || p2) { if (p1 && p2) { res = strcmp(name1, name2); if (res == 0) res = razor_versioncmp(version1, version2); + if (res == 0) + res = is_fixed1 - is_fixed2; } else { res = 0; } @@ -746,18 +776,22 @@ callback(RAZOR_DIFF_ACTION_ADD, p2, name2, version2, arch2, data); - if (p1 != NULL && res <= 0) + if (p1 != NULL && res <= 0) { razor_package_iterator_next(pi1, &p1, RAZOR_DETAIL_NAME, &name1, RAZOR_DETAIL_VERSION, &version1, RAZOR_DETAIL_ARCH, &arch1, RAZOR_DETAIL_LAST); - if (p2 != NULL && res >= 0) + is_fixed1 = razor_package_is_fixed(set, p1); + } + if (p2 != NULL && res >= 0) { razor_package_iterator_next(pi2, &p2, RAZOR_DETAIL_NAME, &name2, RAZOR_DETAIL_VERSION, &version2, RAZOR_DETAIL_ARCH, &arch2, RAZOR_DETAIL_LAST); + is_fixed2 = razor_package_is_fixed(upstream, p2); + } } razor_package_iterator_destroy(pi1);