4dce356e67ffa6d31ead99a4c33da79da7ccf660
[openwrt/openwrt.git] / package / system / opkg / patches / 260-add-print-package-size.patch
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
21 --- a/src/opkg-cl.c
22 +++ b/src/opkg-cl.c
23 @@ -52,6 +52,7 @@ enum {
24 ARGS_OPT_AUTOREMOVE,
25 ARGS_OPT_CACHE,
26 ARGS_OPT_FORCE_SIGNATURE,
27 + ARGS_OPT_SIZE,
28 };
29
30 static struct option long_options[] = {
31 @@ -98,6 +99,7 @@ static struct option long_options[] = {
32 {"offline-root", 1, 0, 'o'},
33 {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH},
34 {"add-dest", 1, 0, ARGS_OPT_ADD_DEST},
35 + {"size", 0, 0, ARGS_OPT_SIZE},
36 {"test", 0, 0, ARGS_OPT_NOACTION},
37 {"tmp-dir", 1, 0, 't'},
38 {"tmp_dir", 1, 0, 't'},
39 @@ -212,6 +214,9 @@ args_parse(int argc, char *argv[])
40 }
41 free(tuple);
42 break;
43 + case ARGS_OPT_SIZE:
44 + conf->size = 1;
45 + break;
46 case ARGS_OPT_NOACTION:
47 conf->noaction = 1;
48 break;
49 @@ -315,6 +320,7 @@ usage()
50 printf("\t--download-only No action -- download only\n");
51 printf("\t--nodeps Do not follow dependencies\n");
52 printf("\t--nocase Perform case insensitive pattern matching\n");
53 + printf("\t--size Print package size when listing available packages\n");
54 printf("\t--force-removal-of-dependent-packages\n");
55 printf("\t Remove package and all dependencies\n");
56 printf("\t--autoremove Remove packages that were installed\n");
57 --- a/libopkg/opkg_cmd.c
58 +++ b/libopkg/opkg_cmd.c
59 @@ -47,10 +47,12 @@ static void
60 print_pkg(pkg_t *pkg)
61 {
62 char *version = pkg_version_str_alloc(pkg);
63 + printf("%s - %s", pkg->name, version);
64 + if (conf->size)
65 + printf(" - %lu", pkg->size);
66 if (pkg->description)
67 - printf("%s - %s - %s\n", pkg->name, version, pkg->description);
68 - else
69 - printf("%s - %s\n", pkg->name, version);
70 + printf(" - %s", pkg->description);
71 + printf("\n");
72 free(version);
73 }
74