packages: clean up the package folder
[openwrt.git] / package / system / opkg / patches / 060-add-find-command.patch
1 --- a/libopkg/opkg_cmd.c
2 +++ b/libopkg/opkg_cmd.c
3 @@ -594,7 +594,7 @@ opkg_download_cmd(int argc, char **argv)
4  
5  
6  static int
7 -opkg_list_cmd(int argc, char **argv)
8 +opkg_list_find_cmd(int argc, char **argv, int use_desc)
9  {
10       int i;
11       pkg_vec_t *available;
12 @@ -610,7 +610,8 @@ 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, conf->nocase))
17 +         if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase) &&
18 +             (!use_desc || !pkg->description || fnmatch(pkg_name, pkg->description, conf->nocase)))
19                continue;
20            print_pkg(pkg);
21       }
22 @@ -619,6 +620,18 @@ opkg_list_cmd(int argc, char **argv)
23       return 0;
24  }
25  
26 +static int
27 +opkg_list_cmd(int argc, char **argv)
28 +{
29 +       return opkg_list_find_cmd(argc, argv, 0);
30 +}
31 +
32 +static int
33 +opkg_find_cmd(int argc, char **argv)
34 +{
35 +       return opkg_list_find_cmd(argc, argv, 1);
36 +}
37 +
38  
39  static int
40  opkg_list_installed_cmd(int argc, char **argv)
41 @@ -1262,6 +1275,7 @@ static opkg_cmd_t cmds[] = {
42       {"configure", 0, (opkg_cmd_fun_t)opkg_configure_cmd, PFM_DESCRIPTION|PFM_SOURCE},
43       {"files", 1, (opkg_cmd_fun_t)opkg_files_cmd, PFM_DESCRIPTION|PFM_SOURCE},
44       {"search", 1, (opkg_cmd_fun_t)opkg_search_cmd, PFM_DESCRIPTION|PFM_SOURCE},
45 +     {"find", 1, (opkg_cmd_fun_t)opkg_find_cmd, PFM_SOURCE},
46       {"download", 1, (opkg_cmd_fun_t)opkg_download_cmd, PFM_DESCRIPTION|PFM_SOURCE},
47       {"compare_versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
48       {"compare-versions", 1, (opkg_cmd_fun_t)opkg_compare_versions_cmd, PFM_DESCRIPTION|PFM_SOURCE},
49 --- a/src/opkg-cl.c
50 +++ b/src/opkg-cl.c
51 @@ -246,6 +246,7 @@ usage()
52         printf("\tlist-changed-conffiles        List user modified configuration files\n");
53         printf("\tfiles <pkg>           List files belonging to <pkg>\n");
54         printf("\tsearch <file|regexp>  List package providing <file>\n");
55 +       printf("\tfind <regexp>         List packages whose name or description matches <regexp>\n");
56         printf("\tinfo [pkg|regexp]     Display all info for <pkg>\n");
57         printf("\tstatus [pkg|regexp]   Display all status for <pkg>\n");
58         printf("\tdownload <pkg>                Download <pkg> to current directory\n");