From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Tue, 23 Apr 2024 15:52:37 +0200 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rzGZZ-00Ctj6-05 for lore@lore.pengutronix.de; Tue, 23 Apr 2024 15:52:37 +0200 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1rzGZY-0007Or-CU; Tue, 23 Apr 2024 15:52:36 +0200 Received: from mail.thorsis.com ([217.92.40.78]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rzGZC-0007NM-0m; Tue, 23 Apr 2024 15:52:14 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 46147148728D; Tue, 23 Apr 2024 15:52:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thorsis.com; s=dkim; t=1713880333; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=roa/reIwO/b/q4Yf45M37+t+NJcmNFLe21IFjdqui1Q=; b=w57r66wD4woum/blSuZMFd9bYESRzXafDEAzvsIPUIRHpNwTlXQWEBPFHKA8z4/nRRoyov j3rAP2M4/2zYyD9pdzITNNcWdJuPdhuyddl30yeWqIPrfr+K2UnbHFTHWQt/FrUifvSX82 nZ1ajKO3SPE0bP1HLAFP0b+byiisWYuybIu3tVAU5ZLE29qnJLPKThraOViaMliD8wVSyR 9GMOOox8pTKwqAJ4BCrGsqhEj/kaNz4uQDcT/m5POO+2fbV9WgLgQZxOHphMEAqfAiGHVT QyTqp945e6aZao80VSAjcMLs6t0YZOhjgH6W0op5qJzLAbgiKIVuF/y4GbWf/A== From: Alexander Dahl To: ptxdist@pengutronix.de Date: Tue, 23 Apr 2024 15:52:11 +0200 Message-ID: <1964395.PYKUYFuaPT@ada-pc> In-Reply-To: <20220129070330.2601433-4-michael.riesch@wolfvision.net> References: <20220129070330.2601433-1-michael.riesch@wolfvision.net> <20220129070330.2601433-4-michael.riesch@wolfvision.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Clacks-Overhead: GNU Terry Pratchett X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-3.0 required=4.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [ptxdist] [PATCH v6 3/5] scripts: add helper to inject files into a source directory X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Cc: Michael Olbrich , m.tretter@pengutronix.de, Michael Riesch Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false Hello Michael, I know this has been applied already, but while working on the extension I= =20 asked about last week, I stumbled over some things. See below. Am Samstag, 29. Januar 2022, 08:03:28 CEST schrieb Michael Riesch: > Some packages may require certain files that are maintained > or generated outside of their source repository. For example, > binary firmware blobs could be excluded from the sources due > to licensing issues. Add a helper that allows to inject certain > files into the source directory (usually in the prepare stage). >=20 > Signed-off-by: Michael Riesch > --- >=20 > Notes: > v6: > - replaced 'break' with 'return' >=20 > rules/post/ptxd_make_world_inject.make | 19 ++++++++++++ > scripts/lib/ptxd_make_world_inject.sh | 42 ++++++++++++++++++++++++++ > 2 files changed, 61 insertions(+) > create mode 100644 rules/post/ptxd_make_world_inject.make > create mode 100644 scripts/lib/ptxd_make_world_inject.sh >=20 > diff --git a/rules/post/ptxd_make_world_inject.make > b/rules/post/ptxd_make_world_inject.make new file mode 100644 > index 000000000..b7d28e92f > --- /dev/null > +++ b/rules/post/ptxd_make_world_inject.make > @@ -0,0 +1,19 @@ > +# -*-makefile-*- > +# > +# Copyright (C) 2021 by Michael Riesch > +# > +# For further information about the PTXdist project and license conditio= ns > +# see the README file. > +# > + > +world/inject/env =3D \ > + $(call world/env, $(1)) \ > + pkg_inject_path=3D"$($(1)_INJECT_PATH)" \ > + pkg_inject_files=3D"$($(1)_INJECT_FILES)" \ > + pkg_source=3D"$($(1)_DIR)" Why passing 'pkg_source' here? world/env/impl and thus world/env has=20 'pkg_dir' and it has exactly the same content which is available in the she= ll=20 script later. Second thing: world/env is assigned in=20 'rules/post/ptxd_make_world_common.make' and the interesting part looks lik= e=20 this: pkg_dir=3D"$(call ptx/escape,$($(1)_DIR))" Same for all the other variables with paths. Why was ptx/escape not used o= n=20 _INJECT_PATH and _INJECT_FILES here? > + > +world/inject =3D \ > + $(call world/inject/env,$(strip $(1))) \ > + ptxd_make_world_inject > + > +# vim: syntax=3Dmake > diff --git a/scripts/lib/ptxd_make_world_inject.sh > b/scripts/lib/ptxd_make_world_inject.sh new file mode 100644 > index 000000000..fe4eb8363 > --- /dev/null > +++ b/scripts/lib/ptxd_make_world_inject.sh > @@ -0,0 +1,42 @@ > +#!/bin/bash > +# > +# Copyright (C) 2021 by Michael Riesch > +# > +# For further information about the PTXdist project and license conditio= ns > +# see the README file. > +# > + > +ptxd_make_inject() { > + local source target > + > + source=3D"$(echo ${inject_file} | cut -d ":" -f 1)" > + target=3D"${pkg_source}/$(echo ${inject_file} | cut -d ":" -f 2)" > + if [ -z "${target}" ]; then > + target=3D"${source}" > + fi Here ${target} can never be empty, because if both ${pkg_source} and $(echo= =E2=80=A6)=20 are empty, there's still the '/' in the middle. So the last three lines of= =20 this block make no sense. Some leftover from earlier iterations? Greets Alex > + > + if [[ "${source}" =3D~ ^/.* ]]; then > + ptxd_bailout "'${source}' must not be an absolute path!" \ > + "Use _INJECT_PATH to specify the search path." > + fi > + > + if ! ptxd_in_path pkg_inject_path "${source}"; then > + ptxd_bailout "Blob '${source}' not found in '${pkg_inject_path}'." > + fi > + source=3D"${ptxd_reply}" > + > + echo -e "\nInject file $(ptxd_print_path ${source}) into" \ > + "$(ptxd_print_path ${target})..." > + cp ${source} ${target} > +} > +export -f ptxd_make_inject > + > + > +ptxd_make_world_inject() { > + ptxd_make_world_init || return > + > + for inject_file in ${pkg_inject_files}; do > + ptxd_make_inject || return > + done > +} > +export -f ptxd_make_world_inject