2
0

060-add-find-command.patch 2.3 KB

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