1
0

260-add-print-package-size.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --- a/libopkg/opkg_conf.c
  2. +++ b/libopkg/opkg_conf.c
  3. @@ -69,6 +69,7 @@ opkg_option_t options[] = {
  4. { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd },
  5. { "proxy_user", OPKG_OPT_TYPE_STRING, &_conf.proxy_user },
  6. { "query-all", OPKG_OPT_TYPE_BOOL, &_conf.query_all },
  7. + { "size", OPKG_OPT_TYPE_BOOL, &_conf.size },
  8. { "tmp_dir", OPKG_OPT_TYPE_STRING, &_conf.tmp_dir },
  9. { "verbosity", OPKG_OPT_TYPE_INT, &_conf.verbosity },
  10. #if defined(HAVE_OPENSSL)
  11. --- a/libopkg/opkg_conf.h
  12. +++ b/libopkg/opkg_conf.h
  13. @@ -88,6 +88,7 @@ struct opkg_conf
  14. int query_all;
  15. int verbosity;
  16. int noaction;
  17. + int size;
  18. int download_only;
  19. char *cache;
  20. --- a/src/opkg-cl.c
  21. +++ b/src/opkg-cl.c
  22. @@ -52,6 +52,7 @@ enum {
  23. ARGS_OPT_AUTOREMOVE,
  24. ARGS_OPT_CACHE,
  25. ARGS_OPT_FORCE_SIGNATURE,
  26. + ARGS_OPT_SIZE,
  27. };
  28. static struct option long_options[] = {
  29. @@ -98,6 +99,7 @@ static struct option long_options[] = {
  30. {"offline-root", 1, 0, 'o'},
  31. {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH},
  32. {"add-dest", 1, 0, ARGS_OPT_ADD_DEST},
  33. + {"size", 0, 0, ARGS_OPT_SIZE},
  34. {"test", 0, 0, ARGS_OPT_NOACTION},
  35. {"tmp-dir", 1, 0, 't'},
  36. {"tmp_dir", 1, 0, 't'},
  37. @@ -212,6 +214,9 @@ args_parse(int argc, char *argv[])
  38. }
  39. free(tuple);
  40. break;
  41. + case ARGS_OPT_SIZE:
  42. + conf->size = 1;
  43. + break;
  44. case ARGS_OPT_NOACTION:
  45. conf->noaction = 1;
  46. break;
  47. @@ -315,6 +320,7 @@ usage()
  48. printf("\t--download-only No action -- download only\n");
  49. printf("\t--nodeps Do not follow dependencies\n");
  50. printf("\t--nocase Perform case insensitive pattern matching\n");
  51. + printf("\t--size Print package size when listing available packages\n");
  52. printf("\t--force-removal-of-dependent-packages\n");
  53. printf("\t Remove package and all dependencies\n");
  54. printf("\t--autoremove Remove packages that were installed\n");
  55. --- a/libopkg/opkg_cmd.c
  56. +++ b/libopkg/opkg_cmd.c
  57. @@ -47,10 +47,12 @@ static void
  58. print_pkg(pkg_t *pkg)
  59. {
  60. char *version = pkg_version_str_alloc(pkg);
  61. + printf("%s - %s", pkg->name, version);
  62. + if (conf->size)
  63. + printf(" - %lu", pkg->size);
  64. if (pkg->description)
  65. - printf("%s - %s - %s\n", pkg->name, version, pkg->description);
  66. - else
  67. - printf("%s - %s\n", pkg->name, version);
  68. + printf(" - %s", pkg->description);
  69. + printf("\n");
  70. free(version);
  71. }