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 434F515800F for ; Sat, 7 Jan 2023 14:56:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 90340E08BB; Sat, 7 Jan 2023 14:56:52 +0000 (UTC) Received: from smtp.gentoo.org (smtp.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 7AE3CE08AD for ; Sat, 7 Jan 2023 14:56:52 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C1E2933E695 for ; Sat, 7 Jan 2023 14:56:51 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3DA6D7EF for ; Sat, 7 Jan 2023 14:56:50 +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: <1673103403.579b4fc3cc9e0f055eb5cc257b822358dddf7fb8.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/out-of-source-utils.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 579b4fc3cc9e0f055eb5cc257b822358dddf7fb8 X-VCS-Branch: master Date: Sat, 7 Jan 2023 14:56:50 +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: 0925803a-fbb2-45a0-8849-a0656ff964c1 X-Archives-Hash: 625b5612c215dd5d93c0b520c2e1cdcc commit: 579b4fc3cc9e0f055eb5cc257b822358dddf7fb8 Author: Michał Górny gentoo org> AuthorDate: Sat Dec 31 18:32:12 2022 +0000 Commit: Michał Górny gentoo org> CommitDate: Sat Jan 7 14:56:43 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=579b4fc3 out-of-source-utils.eclass: New utility eclass Introduce a new out-of-source-utils.eclass to carry run_in_build_dir() helper function. This function used to be defined in multibuild.eclass and indirectly exposed through the eclasses using it. However, it is used rather rarely and it is technically also useful for out-of-source.eclass, so it makes more sense for it to be standalone. In the end, eclasses are cheap. Signed-off-by: Michał Górny gentoo.org> eclass/out-of-source-utils.eclass | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/eclass/out-of-source-utils.eclass b/eclass/out-of-source-utils.eclass new file mode 100644 index 000000000000..d68b21088995 --- /dev/null +++ b/eclass/out-of-source-utils.eclass @@ -0,0 +1,43 @@ +# Copyright 2022-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: out-of-source-utils.eclass +# @MAINTAINER: +# Michał Górny +# @AUTHOR: +# Michał Górny +# @SUPPORTED_EAPIS: 6 7 8 +# @BLURB: Utility functions for building packages out-of-source +# @DESCRIPTION: +# This eclass provides a run_in_build_dir() helper that can be used +# to execute specified command inside BUILD_DIR. + +case ${EAPI} in + 6|7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ ! ${_OUT_OF_SOURCE_UTILS_ECLASS} ]]; then +_OUT_OF_SOURCE_UTILS_ECLASS=1 + +# @FUNCTION: run_in_build_dir +# @USAGE: ... +# @DESCRIPTION: +# Run the given command in the directory pointed by BUILD_DIR. +run_in_build_dir() { + debug-print-function ${FUNCNAME} "${@}" + local ret + + [[ ${#} -eq 0 ]] && die "${FUNCNAME}: no command specified." + [[ -z ${BUILD_DIR} ]] && die "${FUNCNAME}: BUILD_DIR not set." + + mkdir -p "${BUILD_DIR}" || die + pushd "${BUILD_DIR}" >/dev/null || die + "${@}" + ret=${?} + popd >/dev/null || die + + return ${ret} +} + +fi