From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Tue, 13 Oct 2026 13:17:46 +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 1xGaVu-00D8rN-0w for lore@lore.pengutronix.de; Tue, 13 Oct 2026 13:17:46 +0200 Received: from [127.0.0.1] (helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1xGaVt-0007mF-2T; Tue, 13 Oct 2026 13:17:45 +0200 Received: from mx1.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::107]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1xGaVp-0007m6-U7 for ptxdist@pengutronix.de; Tue, 13 Oct 2026 13:17:41 +0200 Received: from h4.cmg1.smtp.forpsi.com (h4.cmg1.smtp.forpsi.com [185.129.138.163]) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPS id 7659D20007C for ; Tue, 13 Oct 2026 13:17:41 +0200 (CEST) ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1791890261; a=rsa-sha256; cv=none; b=DZA14tIDa6cPH1NSk2B2Cwh55mII/OMc4osbm1VF//nfRTizgez1aEzXxtbMUuiFheHPH4 Yx0fMehsyZ2LZ6scwoMAx4+lerSVR/6r2g3cEVI9t4iPF5MisCW03oIidqAI1ThbxCKuyk vSqUB5WLwFYK0NmbIDRlp5PtPvoM8vwai/QQB0olrTkUuKqRHLsyFQKITVUXpprPyBNobB 0PdF3EYly8d8bw6aWDd0DZgbmKiP4o7jghK85nk/FQbToK485T3U1s7+5z4YXNBTjgQEqo QRpjpElzvfKDRkfaflLicfujL0S7F6/fQy+GdPtxW87iROv796DjYK2A0BQT1Q== ARC-Authentication-Results: i=1; mx1.white.stw.pengutronix.de; dkim=pass header.d=triops.cz header.s=f2019 header.b=bdOMMoip; spf=none (mx1.white.stw.pengutronix.de: domain of oss-lists@triops.cz has no SPF policy when checking 185.129.138.163) smtp.mailfrom=oss-lists@triops.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1791890261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mwLwdzGHdQi4zClvBhl/992bSSNCuhsuLGR5CSbbVtY=; b=AsziXdF1l2OJZ0GlAgEImR0bq73iEt3J7nArjDlnrPaLJEjZlC4sWoQ6Dt75sBmBbZrs+0 fwAM6RFpf9aAXOGt76sgx5/t4LOkF1kiLhSdMjIrlUm9y1D9oITV08+OwND6q9UK3VSCa4 b1Slu5uDT2MrfqKHlcetQmrfsjnyOoSzTHWZYSrlR/dusXSx/4/ae1PvMMfUdpQJOCtryz qcC7CAGeYq/YgUTwWb2qd7UlRsgnZhPgtaRZmqsgrMxEyTXVjR59eARzoawLvcInnTYjVq 7IL95tJkpgoWqnDxHFZwtcwEJ3iCv4WQybpWF//si8j/pbKNn/C1Vq87C2NWUQ== Received: from lenoch ([91.218.190.200]) by cmgsmtp with ESMTPSA id GaVnxAqStDJUVGaVox0ce4; Tue, 13 Oct 2026 13:17:41 +0200 Date: Tue, 13 Oct 2026 13:17:39 +0200 From: Ladislav Michl To: ptxdist@pengutronix.de Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CMAE-Envelope: MS4xfAZ6xaOz/lUN3tbD00j02VDos6DKBc1O4dBaXOBLoKbHvI6/Mggni3920pGHIS+6Z7K9/7WLZTb6/9f2jNxLgbs0fRXAJ4+3UZmYIho8RjH53zOFWVIu iRBy3GUL0q7EeAQQ4X43/wRWnJlFyPkCBPaatEAR2fE6zADfnjzi5v5InpNcdkAfRnr9haSshAZCvg== X-Spamd-Result: default: False [-2.60 / 15.00]; BAYES_HAM(-3.00)[99.99%]; MID_RHS_NOT_FQDN(0.50)[]; ONCE_RECEIVED(0.20)[]; R_DKIM_ALLOW(-0.20)[triops.cz:s=f2019]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; ASN(0.00)[asn:24806, ipnet:185.129.136.0/22, country:CZ]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; RCVD_TLS_ALL(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; ARC_SIGNED(0.00)[pengutronix.de:s=20260414:i=1]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DMARC_NA(0.00)[triops.cz]; R_SPF_NA(0.00)[no SPF record]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[triops.cz:+] X-Rspamd-Action: no action X-Rspamd-Server: mx1 X-Rspamd-Queue-Id: 7659D20007C X-Stat-Signature: u5wyqkoykhqsd5mob6fw59e16z5ykxim Subject: [ptxdist] [PATCH 3/6] ptxdist: prepare host tools on demand 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 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 From: Ladislav Michl Run ptxdist_bootstrap.sh on first use if PTXdist is neither installed nor configured in-tree. The PTXdist tree itself is never written to. Concurrent PTXdist runs are serialized using lock file, host tools are prepared again if they were built for another PTXdist tree or a linked host tool vanished. Signed-off-by: Ladislav Michl --- README | 13 ++++++-- bin/ptxdist | 86 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 84 insertions(+), 15 deletions(-) diff --git a/README b/README index debf098d8..5774e046a 100644 --- a/README +++ b/README @@ -20,9 +20,16 @@ to install it. When you start using PTXdist, make sure your $PATH environment variable points to /bin, because that's where the PTXdist frontend program is being installed to. -For developers who want to work with git versions of PTXdist it is only -necessary to run "./autogen.sh && ./configure && make" and set the PATH -variable to the bin/ directory inside the PTXdist tree. +Installing is optional. PTXdist can be used directly from an unpacked +tarball or a git checkout, without any configure or build step: + + cd + /path/to/ptxdist/bin/ptxdist menuconfig + +On first use, PTXdist checks the host for everything it needs, reports +all missing tools at once, and builds kconfig in .ptxdist// +(.ptxdist/git/ for git checkouts) inside the BSP. The PTXdist tree +itself is never written to. Idea ---- diff --git a/bin/ptxdist b/bin/ptxdist index 94c41412f..7b20026bb 100755 --- a/bin/ptxdist +++ b/bin/ptxdist @@ -2131,19 +2131,8 @@ setup_topdir() { ptxdist="$(_realpath "${0}")" && topdir="$(cd "$(dirname "${ptxdist}")"/.. && pwd)" || return - # - # sanity check: is PTXdist already configured? - # - if [ ! -e "${topdir}/.done" ]; then - echo - echo "${PTXDIST_LOG_PROMPT}error: PTXdist in ${topdir} is not built." - echo - exit 1 - fi - PTXDIST="${ptxdist}" PTXDIST_TOPDIR="${topdir}" - PTXDIST_HOSTTOOLS_DIR="${topdir}" PTXDIST_WORKSPACE="$(pwd)" eval PTXDIST_PTXCONFIG_DEFAULT="${PTXDIST_PTXCONFIG_DEFAULT}" @@ -2151,11 +2140,84 @@ setup_topdir() { eval PTXDIST_COLLECTIONCONFIG_DEFAULT="${PTXDIST_COLLECTIONCONFIG_DEFAULT}" eval PTXDIST_TOOLCHAIN_DEFAULT="${PTXDIST_TOOLCHAIN_DEFAULT}" - # ${PTXDIST_HOSTTOOLS_DIR}/bin contains links to sane tools found by configure + setup_hosttools || return + + # ${PTXDIST_HOSTTOOLS_DIR}/bin contains links to sane tools found on the host export PATH="${PTXDIST_HOSTTOOLS_DIR}/bin:${PATH}" } +# +# check that the host tools in ${1} are complete and built for this +# PTXdist, that no linked host tool vanished meanwhile and that the +# sources did not change since, e.g. after 'git pull' +# +_check_hosttools() { + local link + + [ "$(cat "${1}/.done" 2>/dev/null)" = "${PTXDIST_TOPDIR}" ] || return + for link in "${1}/bin/"*; do + [ -e "${link}" ] || return + done + [ -z "$(find "${PTXDIST_TOPDIR}/scripts/kconfig" \ + "${PTXDIST_TOPDIR}/scripts/ptxdist_bootstrap.sh" \ + -newer "${1}/.done" -print -quit)" ] +} + +# +# prepare the host tools (kconfig and links to sane tools) out-of-tree +# unless PTXdist is installed or configured in-tree. +# +# in: PTXDIST_TOPDIR +# PTXDIST_WORKSPACE +# out: PTXDIST_HOSTTOOLS_DIR +# +setup_hosttools() { + local hosttools version lock + + if [ -e "${PTXDIST_TOPDIR}/.done" ]; then + # installed or configured in-tree + PTXDIST_HOSTTOOLS_DIR="${PTXDIST_TOPDIR}" + return + fi + + source "${PTXDIST_TOPDIR}/scripts/ptxdist_version.sh" || return + + # like ptxdistrc: one for all git versions, they change with each commit + version="${PTXDIST_VERSION_FULL}" + if [ -n "${PTXDIST_VERSION_SCM}" ]; then + version=git + fi + + if [ -e "${PTXDIST_WORKSPACE}/selected_ptxconfig" -o \ + -e "${PTXDIST_WORKSPACE}/configs/ptxconfig" ]; then + hosttools="${PTXDIST_WORKSPACE}/.ptxdist/${version}" + else + # not in a BSP, e.g. 'ptxdist setup' + hosttools="${XDG_CACHE_HOME:-${HOME}/.cache}/ptxdist/${version}" + fi + PTXDIST_HOSTTOOLS_DIR="${hosttools}" + + if _check_hosttools "${hosttools}"; then + return + fi + + mkdir -p "$(dirname "${hosttools}")" && + exec {lock}>"${hosttools}.lock" && + flock "${lock}" || return + + # a concurrent PTXdist may have finished first + if ! _check_hosttools "${hosttools}"; then + echo "${PTXDIST_LOG_PROMPT}preparing host tools in '${hosttools}' ..." >&2 + rm -rf "${hosttools}" && + mkdir "${hosttools}" || return + "${BASH}" "${PTXDIST_TOPDIR}/scripts/ptxdist_bootstrap.sh" "${hosttools}" || exit 1 + fi + + exec {lock}>&- +} + + ensure_ptxrc() { local ptxrc tmpptxrc local rc_default="${PTXDIST_TOPDIR}/config/setup/ptxdistrc.default" -- 2.47.3