1 --- rpm-5.4.17/lib/rpmfc.c.orig 2018-06-10 09:52:43.111996936 +0200
2 +++ rpm-5.4.17/lib/rpmfc.c 2018-06-10 09:54:23.968662453 +0200
4 /* XXX "a /usr/bin/python -t script text executable" */
5 /* XXX "python 2.3 byte-compiled" */
6 { " /usr/bin/python", RPMFC_PYTHON|RPMFC_INCLUDE },
7 - { "python ", RPMFC_PYTHON|RPMFC_INCLUDE },
8 - { "Python script", RPMFC_PYTHON|RPMFC_INCLUDE },
10 { "libtool library ", RPMFC_LIBTOOL|RPMFC_INCLUDE },
11 { "pkgconfig ", RPMFC_PKGCONFIG|RPMFC_INCLUDE },
17 + const char * lastPycDir = NULL;
21 int skipProv = fc->skipProv;
22 @@ -1160,8 +1161,29 @@
23 if ((fn[0] == '3' && fn[1] == '2') ||
24 (fn[0] == '6' && fn[1] == '4'))
26 - if (!strncmp(fn, "/python", sizeof("/python")-1))
27 - fc->fcolor->vals[fc->ix] |= RPMFC_PYTHON;
28 + if (!strncmp(fn, "/python", sizeof("/python")-1)) {
30 + if (fn[l-4] == '.' && fn[l-3] == 'p' && fn[l-2] == 'y'
31 + && (fn[l-1] == 'c' || fn[l-1] == 'o')) {
32 + p = strchr(fn, '/');
34 + l = p - fc->fn[fc->ix];
35 + if (!lastPycDir || strncmp(lastPycDir, fc->fn[fc->ix], l)) {
36 + /* one pyc/pyo file per python library directory should be enough to get the dependency */
37 + fc->fcolor->vals[fc->ix] |= RPMFC_PYTHON;
38 + lastPycDir = fc->fn[fc->ix];
42 + else if (l > 17 && !strcmp(fn + l - 17, "egg-info/PKG-INFO")) {
43 + /* get all PKG-INFO files for egg-info data */
44 + fc->fcolor->vals[fc->ix] |= RPMFC_PYTHON;
46 + else if (l > 8 && !strcmp(fn + l - 8, "egg-info")) {
47 + /* get all .egg-info files too */
48 + fc->fcolor->vals[fc->ix] |= RPMFC_PYTHON;
51 else if (!strncmp(fn, "/ruby", sizeof("/ruby")-1)) {
52 fc->fcolor->vals[fc->ix] |= RPMFC_RUBY;
53 if ((strstr(fn, ".gemspec") || strstr(fn, "rbconfig.rb"))) {
54 @@ -1190,8 +1212,29 @@
55 fn = strstr(fc->fn[fc->ix], "/usr/share");
57 fn += sizeof("/usr/share")-1;
58 - if (!strncmp(fn, "/python", sizeof("/python")-1))
59 - fc->fcolor->vals[fc->ix] |= RPMFC_PYTHON;
60 + if (!strncmp(fn, "/python", sizeof("/python")-1)) {
62 + if (fn[l-4] == '.' && fn[l-3] == 'p' && fn[l-2] == 'y'
63 + && (fn[l-1] == 'c' || fn[l-1] == 'o')) {
64 + p = strchr(fn, '/');
66 + l = p - fc->fn[fc->ix];
67 + if (!lastPycDir || strncmp(lastPycDir, fc->fn[fc->ix], l)) {
68 + /* one pyc/pyo file per python library directory should be enough to get the dependency */
69 + fc->fcolor->vals[fc->ix] |= RPMFC_PYTHON;
70 + lastPycDir = fc->fn[fc->ix];
74 + else if (l > 17 && !strcmp(fn + l - 17, "egg-info/PKG-INFO")) {
75 + /* get all PKG-INFO files for egg-info data */
76 + fc->fcolor->vals[fc->ix] |= RPMFC_PYTHON;
78 + else if (l > 8 && !strcmp(fn + l - 8, "egg-info")) {
79 + /* get all .egg-info files too */
80 + fc->fcolor->vals[fc->ix] |= RPMFC_PYTHON;
83 else if (!strncmp(fn, "/ruby", sizeof("/ruby")-1) || !strncmp(fn, "/gems/specifications", sizeof("/gems/specifications")-1)) {
84 fc->fcolor->vals[fc->ix] |= RPMFC_RUBY;
85 /* XXX specification/{*.gemspec,rpmconfig.rb} should use rpmGlob/fnmatch. */