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