From patchwork Sun Aug 30 14:37:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannu Nyman X-Patchwork-Id: 512231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E902C1401E7 for ; Mon, 31 Aug 2015 00:38:14 +1000 (AEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id E86122810B2; Sun, 30 Aug 2015 16:37:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 61DA92800FA for ; Sun, 30 Aug 2015 16:37:01 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .iki. - helo: .filtteri1.pp.htv. - helo-domain: .htv.) FROM/MX_MATCHES_NOT_HELO(DOMAIN)=1; rate: -5.5 Received: from filtteri1.pp.htv.fi (filtteri1.pp.htv.fi [213.243.153.184]) by arrakis.dune.hu (Postfix) with ESMTP for ; Sun, 30 Aug 2015 16:37:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by filtteri1.pp.htv.fi (Postfix) with ESMTP id B511621B6A7 for ; Sun, 30 Aug 2015 17:37:56 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp4.welho.com ([213.243.153.38]) by localhost (filtteri1.pp.htv.fi [213.243.153.184]) (amavisd-new, port 10024) with ESMTP id DeojXZa00T42 for ; Sun, 30 Aug 2015 17:37:52 +0300 (EEST) Received: from [192.168.1.180] (87-92-23-160.bb.dnainternet.fi [87.92.23.160]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by smtp4.welho.com (Postfix) with ESMTPS id DFDEF5BC012 for ; Sun, 30 Aug 2015 17:37:52 +0300 (EEST) To: OpenWrt Development List From: Hannu Nyman Message-ID: <55E31540.3050600@iki.fi> Date: Sun, 30 Aug 2015 17:37:52 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Thunderbird/42.0a2 MIME-Version: 1.0 Subject: [OpenWrt-Devel] [PATCH] opkg: Extend 'opkg list' command to optionally display package size X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 'opkg list' command only displays the available packages' name, version and description. It would be useful to also see the approximate size of the available package. This patch extends "opkg list" command with "--size" to optionally show also the *.ipk size in the listing. * Default behaviour is to print the list of available packages as earlier: "name - version - description" * with "--size" the output of is "name - version - size - description". All current functionality should continue working without any change. Luci might be extended to utilize the new options to e.g. answer https://github.com/openwrt/luci/issues/19 Signed-off-by: Hannu Nyman < hannu.nyman@iki.fi> --- Tested with ar71xx / WNDR3700: opkg package size increase is minimal: root@OpenWrt2:~# ls -l /bin/opkg -rwxr-xr-x 1 root root 101532 Aug 29 23:05 /bin/opkg root@OpenWrt2:~# opkg install /tmp/opkg_9c97d5ecd795709c8584e972bfdf3aee3a5b846d-9_ar71xx.ipk Upgrading opkg on root from 9c97d5ecd795709c8584e972bfdf3aee3a5b846d-8 to 9c97d5ecd795709c8584e972bfdf3aee3a5b846d-9... Configuring opkg. root@OpenWrt2:~# ls -l /bin/opkg -rwxr-xr-x 1 root root 101548 Aug 29 23:05 /bin/opkg --size works as expected: (packages not from "packages" feed have been removed for clarity) root@OpenWrt2:/tmp# opkg list j* jansson - 2.7-1 - Jansson is a C library for encoding, decoding and manipulating JSON data joe - 4.0-4 - Joe is world-famous Wordstar like text editor, that also features Emacs and Pico emulation jpeg-tools - 9a-1 - The Independent JPEG Group's JPEG manipulation tools json4lua - 0.9.53-1 - JSON and JSONRPC for Lua root@OpenWrt2:/tmp# opkg list --size j* jansson - 2.7-1 - 19182 - Jansson is a C library for encoding, decoding and manipulating JSON data joe - 4.0-4 - 173911 - Joe is world-famous Wordstar like text editor, that also features Emacs and Pico emulation jpeg-tools - 9a-1 - 31188 - The Independent JPEG Group's JPEG manipulation tools json4lua - 0.9.53-1 - 7205 - JSON and JSONRPC for Lua ------------- https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/packages/packages/ jansson_2.7-1_ar71xx.ipk 26-Aug-2015 05:20 19182 joe_4.0-4_ar71xx.ipk 26-Aug-2015 05:20 173911 jpeg-tools_9a-1_ar71xx.ipk 26-Aug-2015 00:04 31188 json4lua_0.9.53-1_ar71xx.ipk 26-Aug-2015 05:21 7205 Index: package/system/opkg/Makefile =================================================================== --- package/system/opkg/Makefile (revision 46751) +++ package/system/opkg/Makefile (working copy) @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2014 OpenWrt.org +# Copyright (C) 2006-2015 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -12,7 +12,7 @@ PKG_NAME:=opkg PKG_REV:=9c97d5ecd795709c8584e972bfdf3aee3a5b846d PKG_VERSION:=$(PKG_REV) -PKG_RELEASE:=8 +PKG_RELEASE:=9 PKG_SOURCE_PROTO:=git PKG_SOURCE_VERSION:=$(PKG_REV) Index: package/system/opkg/patches/250-add-print-package-size.patch =================================================================== --- package/system/opkg/patches/250-add-print-package-size.patch (revision 0) +++ package/system/opkg/patches/250-add-print-package-size.patch (working copy) @@ -0,0 +1,74 @@ +--- a/libopkg/opkg_conf.c ++++ b/libopkg/opkg_conf.c +@@ -69,6 +69,7 @@ opkg_option_t options[] = { + { "proxy_passwd", OPKG_OPT_TYPE_STRING, &_conf.proxy_passwd }, + { "proxy_user", OPKG_OPT_TYPE_STRING, &_conf.proxy_user }, + { "query-all", OPKG_OPT_TYPE_BOOL, &_conf.query_all }, ++ { "size", OPKG_OPT_TYPE_BOOL, &_conf.size }, + { "tmp_dir", OPKG_OPT_TYPE_STRING, &_conf.tmp_dir }, + { "verbosity", OPKG_OPT_TYPE_INT, &_conf.verbosity }, + #if defined(HAVE_OPENSSL) +--- a/libopkg/opkg_conf.h ++++ b/libopkg/opkg_conf.h +@@ -88,6 +88,7 @@ struct opkg_conf + int query_all; + int verbosity; + int noaction; ++ int size; + int download_only; + char *cache; + +--- a/src/opkg-cl.c ++++ b/src/opkg-cl.c +@@ -52,6 +52,7 @@ enum { + ARGS_OPT_AUTOREMOVE, + ARGS_OPT_CACHE, + ARGS_OPT_FORCE_SIGNATURE, ++ ARGS_OPT_SIZE, + }; + + static struct option long_options[] = { +@@ -98,6 +99,7 @@ static struct option long_options[] = { + {"offline-root", 1, 0, 'o'}, + {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH}, + {"add-dest", 1, 0, ARGS_OPT_ADD_DEST}, ++ {"size", 0, 0, ARGS_OPT_SIZE}, + {"test", 0, 0, ARGS_OPT_NOACTION}, + {"tmp-dir", 1, 0, 't'}, + {"tmp_dir", 1, 0, 't'}, +@@ -207,6 +209,9 @@ args_parse(int argc, char *argv[]) + } + free(tuple); + break; ++ case ARGS_OPT_SIZE: ++ conf->size = 1; ++ break; + case ARGS_OPT_NOACTION: + conf->noaction = 1; + break; +@@ -310,6 +315,7 @@ usage() + printf("\t--download-only No action -- download only\n"); + printf("\t--nodeps Do not follow dependencies\n"); + printf("\t--nocase Perform case insensitive pattern matching\n"); ++ printf("\t--size Print package size when listing available packages\n"); + printf("\t--force-removal-of-dependent-packages\n"); + printf("\t Remove package and all dependencies\n"); + printf("\t--autoremove Remove packages that were installed\n"); +--- a/libopkg/opkg_cmd.c ++++ b/libopkg/opkg_cmd.c +@@ -47,10 +47,12 @@ static void + print_pkg(pkg_t *pkg) + { + char *version = pkg_version_str_alloc(pkg); ++ printf("%s - %s", pkg->name, version); ++ if (conf->size) ++ printf(" - %lu", pkg->size); + if (pkg->description) +- printf("%s - %s - %s\n", pkg->name, version, pkg->description); +- else +- printf("%s - %s\n", pkg->name, version); ++ printf(" - %s", pkg->description); ++ printf("\n"); + free(version); + } +