From patchwork Tue Nov 28 03:37:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Yurovsky X-Patchwork-Id: 841961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A/Ku1Mqw"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ym8Vq5Lsjz9sNx for ; Tue, 28 Nov 2017 14:37:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 14A7322FFB; Tue, 28 Nov 2017 03:37:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mlJMnw9TVSpp; Tue, 28 Nov 2017 03:37:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 5E5062338F; Tue, 28 Nov 2017 03:37:19 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 794B21C071A for ; Tue, 28 Nov 2017 03:37:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 74E8088347 for ; Tue, 28 Nov 2017 03:37:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YjtAP+Q+kJfq for ; Tue, 28 Nov 2017 03:37:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) by hemlock.osuosl.org (Postfix) with ESMTPS id B3CCC86716 for ; Tue, 28 Nov 2017 03:37:16 +0000 (UTC) Received: by mail-pl0-f66.google.com with SMTP id f6so9829746pln.12 for ; Mon, 27 Nov 2017 19:37:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3XlKB8gdm9AwknSALkHA4B7Q/Jg7SGrPoaxYbDXJrPs=; b=A/Ku1Mqwppb8VplUNnjHscJIPR9nJVS2RPfy9xDRu4rTqPbE5QwIYNRx8VHUFb9PAu +rfIGovaKHXcQLDPQ0IfqQjQ3pbh/4CBJmYRB6xSTEUTLz+tfzonAvByScJp6zgRLbbB Pb4dZ9CZXsVMVQVNUMn4lJXd8Sh8i5KgjTuRI/pe9bbIyIPa4DXLb+a5CKwffr7CmRLN 7T19Z/9CnZY1mFbvu+Twey6jbfno0VeUooAZgUTDCjatJhR/UlRPnyal+cGNJDNbd6fh sCC/tkojffwSXB+monxFUU/HO5ng3OGm6kNVutFiOJhmWkvO8OpVepvXlQ/oDd9oTq4C L36w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3XlKB8gdm9AwknSALkHA4B7Q/Jg7SGrPoaxYbDXJrPs=; b=X2CFMMdipwwpW1L3pbUrdP0Sz26sLuEOKsGTdip6Y23t+h3AsuDFNQMpZTcpFpKMSI G3chcqIerUdHZ41I6Az4YKS8H6wUAZufJ7Bw8BYBwXeXPGs3AHtlipL7ZBh0tQtCKKHU ATxRupiNbtuFcRj0hkmZw8BtHAmUz5z5M1kRuK1ZD5ltZGAg+ziaA40STpckstEF3Wdf LuLkPu5z7iumodiM7/UB2hU2dT3KQKoBPbbV2LuplQlDXUk4TBvdYvGxSelO5GwFC7YI uK4YBfcFdDEyt/KYEVHue4sEyCzsE+DfTVd8QRzn1P1u7ZcBYihkZcA06d80dP7ul80D phOg== X-Gm-Message-State: AJaThX5abzw7PZYjgtmNdlZEmHtp3dqCrY7H6N3NkEYNd2obeEWaRR1Z wHzeSrQhluAwPW3zrWntqRcikv6F X-Google-Smtp-Source: AGs4zMbx4gqsYS+q5Ge5mtWeBj8KDEY/rUAXw76cE78f1y55EKFb2/6iW7wLnkRjYUR8cCHgJd2s+w== X-Received: by 10.84.193.3 with SMTP id e3mr40557979pld.300.1511840236150; Mon, 27 Nov 2017 19:37:16 -0800 (PST) Received: from carbon.impinj.com ([2601:602:9d02:8cb9:cd82:cb07:83cf:b5ed]) by smtp.gmail.com with ESMTPSA id r9sm16914519pgp.93.2017.11.27.19.37.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Nov 2017 19:37:15 -0800 (PST) From: Andrey Yurovsky To: buildroot@buildroot.org Date: Mon, 27 Nov 2017 19:37:07 -0800 Message-Id: <20171128033707.15072-1-yurovsky@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171127220849.5f62e6fc@windsurf.home> References: <20171127220849.5f62e6fc@windsurf.home> Subject: [Buildroot] [PATCH] support/scripts/size-stats: avoid divide-by-zero X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.24 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, Andrey Yurovsky MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Some packages (ex: skeleton-init-systemd) have a zero size so we cannot divide by the package size. In that case make their percent zero explicitly and avoid a ZeroDivisionError exception. Signed-off-by: Andrey Yurovsky Acked-by: "Yann E. MORIN" --- support/scripts/size-stats | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/support/scripts/size-stats b/support/scripts/size-stats index af45000359..3ff2a1ce18 100755 --- a/support/scripts/size-stats +++ b/support/scripts/size-stats @@ -178,9 +178,17 @@ def gen_files_csv(filesdict, pkgsizes, outputf): "File size in system (%)"]) for f, (pkgname, filesize) in filesdict.items(): pkgsize = pkgsizes[pkgname] + + if pkgsize == 0: + percent_pkg = 0 + else: + percent_pkg = float(filesize) / pkgsize * 100 + + percent_total = float(filesize) / total * 100 + wr.writerow([f, pkgname, filesize, pkgsize, - "%.1f" % (float(filesize) / pkgsize * 100), - "%.1f" % (float(filesize) / total * 100)]) + "%.1f" % percent_pkg, + "%.1f" % percent_total]) #