From patchwork Tue Jun 2 05:27:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Bloch X-Patchwork-Id: 1667 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 5D13C191F9588 for ; Tue, 2 Jun 2020 05:28:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_ADSP_CUSTOM_MED=0.001, DKIM_INVALID=1,DKIM_SIGNED=0.1,FREEMAIL_FROM=0.5,MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_MSPIKE_H4=0.001,RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001,T_DMARC_POLICY_NONE=0.01,T_DMARC_SIMPLE_DKIM=0.01 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-BL-Results: [127.0.9.2] [127.0.0.19] Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Tue, 2 Jun 2020 05:28:17 +0000 (UTC) Received: from orion.archlinux.org (localhost [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id D383B1C797104E; Tue, 2 Jun 2020 05:28:15 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: luna) by orion.archlinux.org (Postfix) with ESMTPSA id 77DD91C7971047; Tue, 2 Jun 2020 05:28:15 +0000 (UTC) Authentication-Results: orion.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ukFJPCAb Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 66E922BE6B; Tue, 2 Jun 2020 05:28:15 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ukFJPCAb Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 61D2F2BA4D for ; Tue, 2 Jun 2020 05:28:12 +0000 (UTC) Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by luna.archlinux.org (Postfix) with ESMTPS for ; Tue, 2 Jun 2020 05:28:12 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id x14so1992763wrp.2 for ; Mon, 01 Jun 2020 22:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IqriJHSbSfUyBaDJWDL6C/ztZMwIoY94k8iEJSOCUOo=; b=ukFJPCAb0yv0RzmJ49qLveXJBX0Yu2x9+xFWLSU1xyZbxCctGw+9nka75kS/6c1pxf CmBKVEJIqkq9tjm+4a5/Wny0chUyy4lG81bcvgUaA28IUVx4DRhPdrBv6zBtNNmcmFH2 dvd0Jyfd4TFDbooX9v++0Whc4Pyd47xlx1J5yyN+v6mA9/tRQY96TXLeQ/7bq6f3HRCP TBbYFLlnkX2lbmbGocITmaW9T0l9/OMSZsRifPwdR3/d6lb+NeBW/9noLTnEtZ1KUZFj J/RCcQRpL6AX8qD58zRWfPZEUimxEKAi6l2ChoGNX1UahMSqkaDb4kyw8DCY3mIObhtE 3hVw== 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:mime-version :content-transfer-encoding; bh=IqriJHSbSfUyBaDJWDL6C/ztZMwIoY94k8iEJSOCUOo=; b=EgZglUAfiyUOfsVmH+7o0i7DRAHWeRyzgIYlOVxMfKEzo0mSwtikksis7sdC3j2OWn DMcvlb52s+SJ82sdYUQzSIwcuZm9k2CjO49qGfL5vdRB3ZmZD0jW+P8TmAxgH951JQya 16VgTvNQZzC2GAcQfH28JZuujPlGoz5K5syYALOEDSavAcLQIl+yEvCb8d5z9kRgYsaT erKFtEe5LCe+AmnGcI1djb5opVwKR1U7B1CahxV/3epQZbNK23/fN5pVM/izNSK3pYEQ trBhRW3tHf/6V/Lps0rkuiUM2MRJkgcgIM6bHovmWreJh/OTKzLNVKKPe6HDIkVMkUlO dKsw== X-Gm-Message-State: AOAM533wA4oCwm9uNqB6wQBkJPXz2o7jieOeI/8paKl1ti+O+oYG7Rzh bUWTE4uevKOidZcB11HfwH9jQkBtSlpSXw== X-Google-Smtp-Source: ABdhPJzOEWPYi6pH55X2RjWBAur7vTmddvHItaa3PsWSBsZRjPjS5CKk94Zm3ew//wWIgF1R8LzyJQ== X-Received: by 2002:a5d:4fc4:: with SMTP id h4mr24069251wrw.49.1591075691184; Mon, 01 Jun 2020 22:28:11 -0700 (PDT) Received: from leo-lap.lan ([176.230.212.100]) by smtp.gmail.com with ESMTPSA id p16sm2252391wru.27.2020.06.01.22.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 22:28:10 -0700 (PDT) From: Leonid Bloch To: pacman-contrib@lists.archlinux.org Subject: [PATCH v2] paccache: Support cleaning many thousands of candidates Date: Tue, 2 Jun 2020 08:27:58 +0300 Message-Id: <20200602052758.4817-1-lb.workbox@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-BeenThere: pacman-contrib@lists.archlinux.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussion list for pacman-contrib development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Johannes_L=C3=B6thberg?= Errors-To: pacman-contrib-bounces@lists.archlinux.org Sender: "pacman-contrib" In situations when there are many thousands of candidates for deletion, paccache returns an "Argument list too long" error at the freed space calculation stage, because the expansion of the ${candidates[@]} array becomes too long for Bash. This commit fixes that problem, by getting the @SIZECMD@ arguments via `printf '%s\0' "${candidates[@]}" | xargs -0`, similarly to what is done for the (re)moving commands below. Signed-off-by: Leonid Bloch --- src/paccache.sh.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/paccache.sh.in b/src/paccache.sh.in index af901f4..1311fd7 100644 --- a/src/paccache.sh.in +++ b/src/paccache.sh.in @@ -391,7 +391,8 @@ candidates=("${candtemp[@]}") unset candtemp # do this before we destroy anything -totalsaved=$(@SIZECMD@ "${candidates[@]}" | awk '{ sum += $1 } END { print sum }') +totalsaved=$(printf '%s\0' "${candidates[@]}" | xargs -0 @SIZECMD@ | + awk '{ sum += $1 } END { print sum }') # Exit immediately if a pipeline returns non-zero. set -o errexit