From: Michael Schroeder Date: Mon, 31 Mar 2014 13:13:28 +0000 (+0200) Subject: suppport RPM_ADD_FILTERED_FILELIST X-Git-Tag: 0.6.4~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6dfec0d0a5a873b7745903de7c530be8faaeee6f;p=thirdparty%2Flibsolv.git suppport RPM_ADD_FILTERED_FILELIST Probably only useful for distris that enforce filelist dependency policies, e.g. SUSE. --- diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c index d37d8b75..f6c8f0d2 100644 --- a/ext/repo_rpmdb.c +++ b/ext/repo_rpmdb.c @@ -717,8 +717,23 @@ adddudata(Repodata *data, Id handle, RpmHead *rpmhead, char **dn, unsigned int * solv_free(fkb); } +static int +is_filtered(const char *dir) +{ + if (!dir) + return 1; + /* the dirs always have a trailing / in rpm */ + if (strstr(dir, "bin/")) + return 0; + if (!strncmp(dir, "/etc/", 5)) + return 0; + if (!strcmp(dir, "/usr/lib/")) + return 2; + return 1; +} + static void -addfilelist(Repodata *data, Id handle, RpmHead *rpmhead) +addfilelist(Repodata *data, Id handle, RpmHead *rpmhead, int flags) { char **bn; char **dn; @@ -727,6 +742,7 @@ addfilelist(Repodata *data, Id handle, RpmHead *rpmhead) int i; Id lastdid = 0; unsigned int lastdii = -1; + int lastfiltered = 0; if (!data) return; @@ -765,14 +781,25 @@ addfilelist(Repodata *data, Id handle, RpmHead *rpmhead) { if (di[i] >= dnc) continue; /* corrupt entry */ - did = repodata_str2dir(data, dn[di[i]], 1); + lastdii = di[i]; + if ((flags & RPM_ADD_FILTERED_FILELIST) != 0) + { + lastfiltered = is_filtered(dn[di[i]]); + if (lastfiltered == 1) + continue; + } + did = repodata_str2dir(data, dn[lastdii], 1); if (!did) did = repodata_str2dir(data, "/", 1); lastdid = did; - lastdii = di[i]; } if (b && *b == '/') /* work around rpm bug */ b++; + if (lastfiltered) + { + if (lastfiltered != 2 || strcmp(b, "sendmail")) + continue; + } repodata_add_dirstr(data, handle, SOLVABLE_FILELIST, did, b); } solv_free(bn); @@ -994,7 +1021,7 @@ rpm2solv(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rpmhead, } } if ((flags & RPM_ADD_NO_FILELIST) == 0) - addfilelist(data, handle, rpmhead); + addfilelist(data, handle, rpmhead, flags); if ((flags & RPM_ADD_WITH_CHANGELOG) != 0) addchangelog(data, handle, rpmhead); } diff --git a/ext/repo_rpmdb.h b/ext/repo_rpmdb.h index a63d6f25..9e3bd0d4 100644 --- a/ext/repo_rpmdb.h +++ b/ext/repo_rpmdb.h @@ -24,6 +24,7 @@ extern Id repo_add_rpm(Repo *repo, const char *rpm, int flags); #define RPM_ADD_WITH_HDRID (1 << 15) #define RPM_ADD_WITH_LEADSIGID (1 << 16) #define RPM_ADD_WITH_CHANGELOG (1 << 17) +#define RPM_ADD_FILTERED_FILELIST (1 << 18) #define RPMDB_EMPTY_REFREPO (1 << 30) /* internal */ diff --git a/tools/rpms2solv.c b/tools/rpms2solv.c index 13b77b1a..7852b08d 100644 --- a/tools/rpms2solv.c +++ b/tools/rpms2solv.c @@ -71,8 +71,9 @@ main(int argc, char **argv) #ifdef SUSE int add_auto = 0; #endif + int filtered_filelist = 0; - while ((c = getopt(argc, argv, "0XkKb:m:")) >= 0) + while ((c = getopt(argc, argv, "0XkKb:m:F")) >= 0) { switch(c) { @@ -85,6 +86,9 @@ main(int argc, char **argv) case '0': manifest0 = 1; break; + case 'F': + filtered_filelist = 1; + break; #ifdef ENABLE_PUBKEY case 'k': pubkeys = 1; @@ -169,7 +173,7 @@ main(int argc, char **argv) continue; } #endif - if (repo_add_rpm(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE) == 0) + if (repo_add_rpm(repo, rpms[i], REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE|(filtered_filelist ? RPM_ADD_FILTERED_FILELIST : 0)) == 0) { fprintf(stderr, "rpms2solv: %s\n", pool_errstr(pool)); res = 1;