From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99E21C433EF for ; Thu, 6 Jan 2022 21:00:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3515F83281; Thu, 6 Jan 2022 21:00:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0wI49U2jIDY2; Thu, 6 Jan 2022 21:00:56 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id A1264831C1; Thu, 6 Jan 2022 21:00:55 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 7A8361BF340 for ; Thu, 6 Jan 2022 21:00:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 6802C4018D for ; Thu, 6 Jan 2022 21:00:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eHseFkuq-OGV for ; Thu, 6 Jan 2022 21:00:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by smtp2.osuosl.org (Postfix) with ESMTPS id 63819404BD for ; Thu, 6 Jan 2022 21:00:21 +0000 (UTC) Received: (Authenticated sender: thomas.petazzoni@bootlin.com) by relay11.mail.gandi.net (Postfix) with ESMTPSA id E65CE100005; Thu, 6 Jan 2022 21:00:15 +0000 (UTC) From: Thomas Petazzoni To: James Hilliard , Christian Stewart , Buildroot List , Matt Weber , "Yann E. MORIN" Date: Thu, 6 Jan 2022 21:59:51 +0100 Message-Id: <20220106210000.397694-4-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220106210000.397694-1-thomas.petazzoni@bootlin.com> References: <20220106210000.397694-1-thomas.petazzoni@bootlin.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 03/11] support/download/post-process-helpers: add helper function for post process scripts X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Patrick Havelange , Thomas Petazzoni Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" download post process scripts will often need to unpack the source code tarball, do some operation, and then repack it. In order to help with this, post-process-helpers provide an unpack() function and a repack() function. Signed-off-by: Thomas Petazzoni --- support/download/helpers | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/support/download/helpers b/support/download/helpers index 40d5eea591..4c5eb466cc 100755 --- a/support/download/helpers +++ b/support/download/helpers @@ -72,5 +72,27 @@ mk_tar_gz() { popd >/dev/null } +post_process_unpack() { + local dest="${1}" + local tarball="${2}" + local one_file + + mkdir "${dest}" + tar -C "${dest}" --strip-components=1 -xf "${tarball}" + one_file="$(find "${dest}" -type f -print0 |LC_ALL=C sort -z |head -z -n1 |tr -d "\0")" + touch -r "${one_file}" "${dest}.timestamp" +} + +post_process_repack() { + local in_dir="${1}" + local base_dir="${2}" + local out="${3}" + local date + + date="@$(stat -c '%Y' "${in_dir}/${base_dir}.timestamp")" + + mk_tar_gz "${in_dir}/${base_dir}" "${base_dir}" "${date}" "${out}" +} + # Keep this line and the following as last lines in this file. # vim: ft=bash -- 2.33.1 _______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot