From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3E3FC158015 for ; Sat, 30 Dec 2023 16:20:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7F3D92BC057; Sat, 30 Dec 2023 16:20:40 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6A8672BC057 for ; Sat, 30 Dec 2023 16:20:40 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A8CA833E690 for ; Sat, 30 Dec 2023 16:20:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 160AB14BD for ; Sat, 30 Dec 2023 16:20:38 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1703953150.44d713565ee89e990ac10a438fef1126e47330b1.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/dist-kernel-utils.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 44d713565ee89e990ac10a438fef1126e47330b1 X-VCS-Branch: master Date: Sat, 30 Dec 2023 16:20:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 569b301b-c99b-41af-9225-17c57ee97cbf X-Archives-Hash: e9b0b86a20aaf372be32492882e0c328 commit: 44d713565ee89e990ac10a438fef1126e47330b1 Author: Michał Górny gentoo org> AuthorDate: Thu Dec 28 11:22:29 2023 +0000 Commit: Michał Górny gentoo org> CommitDate: Sat Dec 30 16:19:10 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=44d71356 dist-kernel-utils.eclass: Add dist-kernel_compressed_module_cleanup Signed-off-by: Michał Górny gentoo.org> eclass/dist-kernel-utils.eclass | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass index 67cb802151b2..8ccffd038474 100644 --- a/eclass/dist-kernel-utils.eclass +++ b/eclass/dist-kernel-utils.eclass @@ -210,5 +210,42 @@ dist-kernel_PV_to_KV() { echo "${kv}" } +# @FUNCTION: dist-kernel_compressed_module_cleanup +# @USAGE: +# @DESCRIPTION: +# Traverse path for duplicate (un)compressed modules and remove all +# but the newest variant. +dist-kernel_compressed_module_cleanup() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${#} -ne 1 ]] && die "${FUNCNAME}: invalid arguments" + local path=${1} + local basename f + + while read -r basename; do + local prev= + for f in "${path}/${basename}"{,.gz,.xz,.zst}; do + if [[ ! -e ${f} ]]; then + continue + elif [[ -z ${prev} ]]; then + prev=${f} + elif [[ ${f} -nt ${prev} ]]; then + rm -v "${prev}" || die + prev=${f} + else + rm -v "${f}" || die + fi + done + done < <( + cd "${path}" && + find -type f \ + \( -name '*.ko' \ + -o -name '*.ko.gz' \ + -o -name '*.ko.xz' \ + -o -name '*.ko.zst' \ + \) | sed -e 's:[.]\(gz\|xz\|zst\)$::' | sort | uniq -d || die + ) +} + _DIST_KERNEL_UTILS=1 fi