050-add-case-insensitive-flag.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. --- a/libopkg/opkg_cmd.c
  2. +++ b/libopkg/opkg_cmd.c
  3. @@ -436,7 +436,7 @@ opkg_configure_packages(char *pkg_name)
  4. for(i = 0; i < ordered->len; i++) {
  5. pkg = ordered->pkgs[i];
  6. - if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
  7. + if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
  8. continue;
  9. if (pkg->state_status == SS_UNPACKED) {
  10. @@ -610,7 +610,7 @@ opkg_list_cmd(int argc, char **argv)
  11. for (i=0; i < available->len; i++) {
  12. pkg = available->pkgs[i];
  13. /* if we have package name or pattern and pkg does not match, then skip it */
  14. - if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
  15. + if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
  16. continue;
  17. print_pkg(pkg);
  18. }
  19. @@ -637,7 +637,7 @@ opkg_list_installed_cmd(int argc, char *
  20. for (i=0; i < available->len; i++) {
  21. pkg = available->pkgs[i];
  22. /* if we have package name or pattern and pkg does not match, then skip it */
  23. - if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
  24. + if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
  25. continue;
  26. print_pkg(pkg);
  27. }
  28. @@ -666,7 +666,7 @@ opkg_list_changed_conffiles_cmd(int argc
  29. for (i=0; i < available->len; i++) {
  30. pkg = available->pkgs[i];
  31. /* if we have package name or pattern and pkg does not match, then skip it */
  32. - if (pkg_name && fnmatch(pkg_name, pkg->name, 0))
  33. + if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase))
  34. continue;
  35. if (nv_pair_list_empty(&pkg->conffiles))
  36. continue;
  37. @@ -722,7 +722,7 @@ opkg_info_status_cmd(int argc, char **ar
  38. for (i=0; i < available->len; i++) {
  39. pkg = available->pkgs[i];
  40. - if (pkg_name && fnmatch(pkg_name, pkg->name, 0)) {
  41. + if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase)) {
  42. continue;
  43. }
  44. @@ -792,7 +792,7 @@ opkg_remove_cmd(int argc, char **argv)
  45. for (i=0; i<argc; i++) {
  46. for (a=0; a<available->len; a++) {
  47. pkg = available->pkgs[a];
  48. - if (fnmatch(argv[i], pkg->name, 0)) {
  49. + if (fnmatch(argv[i], pkg->name, conf->nocase)) {
  50. continue;
  51. }
  52. if (conf->restrict_to_default_dest) {
  53. @@ -926,7 +926,7 @@ opkg_depends_cmd(int argc, char **argv)
  54. for (j=0; j<available_pkgs->len; j++) {
  55. pkg = available_pkgs->pkgs[j];
  56. - if (fnmatch(argv[i], pkg->name, 0) != 0)
  57. + if (fnmatch(argv[i], pkg->name, conf->nocase) != 0)
  58. continue;
  59. depends_count = pkg->depends_count +
  60. @@ -1147,9 +1147,9 @@ opkg_what_provides_replaces_cmd(enum wha
  61. ((what_field_type == WHATPROVIDES)
  62. ? pkg->provides[k]
  63. : pkg->replaces[k]);
  64. - if (fnmatch(target, apkg->name, 0) == 0) {
  65. + if (fnmatch(target, apkg->name, conf->nocase) == 0) {
  66. opkg_msg(NOTICE, " %s", pkg->name);
  67. - if (strcmp(target, apkg->name) != 0)
  68. + if ((conf->nocase ? strcasecmp(target, apkg->name) : strcmp(target, apkg->name)) != 0)
  69. opkg_msg(NOTICE, "\t%s %s\n",
  70. rel_str, apkg->name);
  71. opkg_message(NOTICE, "\n");
  72. @@ -1200,7 +1200,7 @@ opkg_search_cmd(int argc, char **argv)
  73. for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
  74. installed_file = (char *)iter->data;
  75. - if (fnmatch(argv[0], installed_file, 0)==0)
  76. + if (fnmatch(argv[0], installed_file, conf->nocase)==0)
  77. print_pkg(pkg);
  78. }
  79. --- a/libopkg/opkg_conf.c
  80. +++ b/libopkg/opkg_conf.c
  81. @@ -62,6 +62,7 @@ opkg_option_t options[] = {
  82. { "noaction", OPKG_OPT_TYPE_BOOL, &_conf.noaction },
  83. { "download_only", OPKG_OPT_TYPE_BOOL, &_conf.download_only },
  84. { "nodeps", OPKG_OPT_TYPE_BOOL, &_conf.nodeps },
  85. + { "nocase", OPKG_OPT_TYPE_BOOL, &_conf.nocase },
  86. { "offline_root", OPKG_OPT_TYPE_STRING, &_conf.offline_root },
  87. { "overlay_root", OPKG_OPT_TYPE_STRING, &_conf.overlay_root },
  88. { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd },
  89. --- a/libopkg/opkg_conf.h
  90. +++ b/libopkg/opkg_conf.h
  91. @@ -24,6 +24,7 @@ extern opkg_conf_t *conf;
  92. #include "config.h"
  93. #include <stdarg.h>
  94. +#include <fnmatch.h> /* FNM_CASEFOLD */
  95. #include "hash_table.h"
  96. #include "pkg_src_list.h"
  97. @@ -79,6 +80,7 @@ struct opkg_conf
  98. int force_remove;
  99. int check_signature;
  100. int nodeps; /* do not follow dependencies */
  101. + int nocase; /* perform case insensitive matching */
  102. char *offline_root;
  103. char *overlay_root;
  104. int query_all;
  105. --- a/src/opkg-cl.c
  106. +++ b/src/opkg-cl.c
  107. @@ -47,6 +47,7 @@ enum {
  108. ARGS_OPT_NOACTION,
  109. ARGS_OPT_DOWNLOAD_ONLY,
  110. ARGS_OPT_NODEPS,
  111. + ARGS_OPT_NOCASE,
  112. ARGS_OPT_AUTOREMOVE,
  113. ARGS_OPT_CACHE,
  114. };
  115. @@ -86,6 +87,7 @@ static struct option long_options[] = {
  116. {"noaction", 0, 0, ARGS_OPT_NOACTION},
  117. {"download-only", 0, 0, ARGS_OPT_DOWNLOAD_ONLY},
  118. {"nodeps", 0, 0, ARGS_OPT_NODEPS},
  119. + {"nocase", 0, 0, ARGS_OPT_NOCASE},
  120. {"offline", 1, 0, 'o'},
  121. {"offline-root", 1, 0, 'o'},
  122. {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH},
  123. @@ -107,7 +109,7 @@ args_parse(int argc, char *argv[])
  124. char *tuple, *targ;
  125. while (1) {
  126. - c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV::",
  127. + c = getopt_long_only(argc, argv, "Ad:f:ino:p:t:vV::",
  128. long_options, &option_index);
  129. if (c == -1)
  130. break;
  131. @@ -122,6 +124,9 @@ args_parse(int argc, char *argv[])
  132. case 'f':
  133. conf->conf_file = xstrdup(optarg);
  134. break;
  135. + case 'i':
  136. + conf->nocase = FNM_CASEFOLD;
  137. + break;
  138. case 'o':
  139. conf->offline_root = xstrdup(optarg);
  140. break;
  141. @@ -176,6 +181,9 @@ args_parse(int argc, char *argv[])
  142. case ARGS_OPT_NODEPS:
  143. conf->nodeps = 1;
  144. break;
  145. + case ARGS_OPT_NOCASE:
  146. + conf->nocase = FNM_CASEFOLD;
  147. + break;
  148. case ARGS_OPT_ADD_ARCH:
  149. case ARGS_OPT_ADD_DEST:
  150. tuple = xstrdup(optarg);
  151. @@ -287,6 +295,7 @@ usage()
  152. printf("\t--noaction No action -- test only\n");
  153. printf("\t--download-only No action -- download only\n");
  154. printf("\t--nodeps Do not follow dependencies\n");
  155. + printf("\t--nocase Perform case insensitive pattern matching\n");
  156. printf("\t--force-removal-of-dependent-packages\n");
  157. printf("\t Remove package and all dependencies\n");
  158. printf("\t--autoremove Remove packages that were installed\n");