public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] rust.eclass: add ERUST_{SLOT,TYPE} user variables
@ 2024-12-03 12:22 kangie
  2024-12-03 13:26 ` Michał Górny
  2024-12-04 17:45 ` Sam James
  0 siblings, 2 replies; 4+ messages in thread
From: kangie @ 2024-12-03 12:22 UTC (permalink / raw
  To: gentoo-dev; +Cc: Matt Jolly

From: Matt Jolly <kangie@gentoo.org>

These variables enable users (though most likely Gentoo developers)
to override the selection of the Rust implementation by the eclass.

This means that _only_ the specified ERUST_SLOT and/or ERUST_TYPE
('source' or 'binary') will be checked for, with the eclass `die`ing
with "No Rust slot satisfying the package's dependencies..." if the
selected impl is not available.

These variables are intended to enable reproducing bugs and testing
packages against specific dev-lang/rust{,-bin} packages; they must
not be set in ebuilds.

Closes: https://bugs.gentoo.org/945752
Signed-off-by: Matt Jolly <kangie@gentoo.org>
---
 eclass/rust.eclass | 49 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 44 insertions(+), 5 deletions(-)

diff --git a/eclass/rust.eclass b/eclass/rust.eclass
index 71cbb4b24f8c..991a9cdb7f14 100644
--- a/eclass/rust.eclass
+++ b/eclass/rust.eclass
@@ -98,6 +98,26 @@ declare -a -g -r _RUST_SLOTS_ORDERED=(
 	"1.54.0"
 )
 
+# == user control knobs ==
+
+# @ECLASS_VARIABLE: ERUST_SLOT
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Specify the version (slot) of Rust to be used by the package. This is
+# useful for troubleshooting and debugging purposes; If unset, the newest
+# acceptable Rust version will be used. May be combined with ERUST_TYPE.
+# This variable must not be set in ebuilds.
+
+# @ECLASS_VARIABLE: ERUST_TYPE
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Specify the type of Rust to be used by the package from options:
+# 'source' or 'binary' (-bin). This is useful for troubleshooting and
+# debugging purposes. If unset, the standard eclass logic will be used
+# to determine the type of Rust to use (i.e. prefer source if binary
+# is also available). May be combined with ERUST_SLOT.
+# This variable must not be set in ebuilds.
+
 # == control variables ==
 
 # @ECLASS_VARIABLE: RUST_MAX_VER
@@ -332,6 +352,10 @@ _get_rust_slot() {
 			fi
 		fi
 
+		if [[ -n "${ERUST_SLOT}" && "${slot}" != "${ERUST_SLOT}" ]]; then
+			continue
+		fi
+
 		# If we're in LLVM mode we can skip any slots that don't match the selected USE
 		if [[ -n "${RUST_NEEDS_LLVM}" ]]; then
 			if [[ "${llvm_slot}" != "${llvm_r1_slot}" ]]; then
@@ -345,12 +369,27 @@ _get_rust_slot() {
 			rust_check_deps && return
 		else
 			local usedep="${RUST_REQ_USE+[${RUST_REQ_USE}]}"
-			# When checking for installed packages prefer the non `-bin` package
+			# When checking for installed packages prefer the source package;
 			# if effort was put into building it we should use it.
-			local rust_pkgs=(
-				"dev-lang/rust:${slot}${usedep}"
-				"dev-lang/rust-bin:${slot}${usedep}"
-			)
+			local rust_pkgs
+			case "${ERUST_TYPE}" in
+				source)
+					rust_pkgs=(
+						"dev-lang/rust:${slot}${usedep}"
+					)
+					;;
+				binary)
+					rust_pkgs=(
+						"dev-lang/rust-bin:${slot}${usedep}"
+					)
+					;;
+				*)
+					rust_pkgs=(
+						"dev-lang/rust:${slot}${usedep}"
+						"dev-lang/rust-bin:${slot}${usedep}"
+					)
+					;;
+			esac
 			local _pkg
 			for _pkg in "${rust_pkgs[@]}"; do
 				if has_version "${hv_switch}" "${_pkg}"; then
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] rust.eclass: add ERUST_{SLOT,TYPE} user variables
  2024-12-03 12:22 [gentoo-dev] [PATCH] rust.eclass: add ERUST_{SLOT,TYPE} user variables kangie
@ 2024-12-03 13:26 ` Michał Górny
  2024-12-04  1:38   ` Matt Jolly
  2024-12-04 17:45 ` Sam James
  1 sibling, 1 reply; 4+ messages in thread
From: Michał Górny @ 2024-12-03 13:26 UTC (permalink / raw
  To: gentoo-dev; +Cc: Matt Jolly

[-- Attachment #1: Type: text/plain, Size: 2229 bytes --]

On Tue, 2024-12-03 at 22:22 +1000, kangie@gentoo.org wrote:
> From: Matt Jolly <kangie@gentoo.org>
> 
> These variables enable users (though most likely Gentoo developers)
> to override the selection of the Rust implementation by the eclass.
> 
> This means that _only_ the specified ERUST_SLOT and/or ERUST_TYPE
> ('source' or 'binary') will be checked for, with the eclass `die`ing
> with "No Rust slot satisfying the package's dependencies..." if the
> selected impl is not available.
> 
> These variables are intended to enable reproducing bugs and testing
> packages against specific dev-lang/rust{,-bin} packages; they must
> not be set in ebuilds.
> 
> Closes: https://bugs.gentoo.org/945752
> Signed-off-by: Matt Jolly <kangie@gentoo.org>
> ---
>  eclass/rust.eclass | 49 +++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 44 insertions(+), 5 deletions(-)
> 
> diff --git a/eclass/rust.eclass b/eclass/rust.eclass
> index 71cbb4b24f8c..991a9cdb7f14 100644
> --- a/eclass/rust.eclass
> +++ b/eclass/rust.eclass
> @@ -98,6 +98,26 @@ declare -a -g -r _RUST_SLOTS_ORDERED=(
>  	"1.54.0"
>  )
>  
> +# == user control knobs ==
> +
> +# @ECLASS_VARIABLE: ERUST_SLOT
> +# @USER_VARIABLE
> +# @DESCRIPTION:
> +# Specify the version (slot) of Rust to be used by the package. This is
> +# useful for troubleshooting and debugging purposes; If unset, the newest
> +# acceptable Rust version will be used. May be combined with ERUST_TYPE.
> +# This variable must not be set in ebuilds.
> +
> +# @ECLASS_VARIABLE: ERUST_TYPE
> +# @USER_VARIABLE
> +# @DESCRIPTION:
> +# Specify the type of Rust to be used by the package from options:
> +# 'source' or 'binary' (-bin). This is useful for troubleshooting and
> +# debugging purposes. If unset, the standard eclass logic will be used
> +# to determine the type of Rust to use (i.e. prefer source if binary
> +# is also available). May be combined with ERUST_SLOT.
> +# This variable must not be set in ebuilds.

Could you perhaps add 'OVERRIDE' to the names, to make it clear they're
not supposed to be normally used?  Just like we have
PYTHON_COMPAT_OVERRIDE in Python eclasses.

-- 
Best regards,
Michał Górny


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] rust.eclass: add ERUST_{SLOT,TYPE} user variables
  2024-12-03 13:26 ` Michał Górny
@ 2024-12-04  1:38   ` Matt Jolly
  0 siblings, 0 replies; 4+ messages in thread
From: Matt Jolly @ 2024-12-04  1:38 UTC (permalink / raw
  To: gentoo-dev

Hi Michał,

Sure. No worries - Given the trivial nature I'll update the variable
before merging rather than sending a V2 unless there's other feedback
that requires it. :)

On 3/12/24 23:26, Michał Górny wrote:
> On Tue, 2024-12-03 at 22:22 +1000, kangie@gentoo.org wrote:
>> From: Matt Jolly <kangie@gentoo.org>
>>
>> These variables enable users (though most likely Gentoo developers)
>> to override the selection of the Rust implementation by the eclass.
>>
>> This means that _only_ the specified ERUST_SLOT and/or ERUST_TYPE
>> ('source' or 'binary') will be checked for, with the eclass `die`ing
>> with "No Rust slot satisfying the package's dependencies..." if the
>> selected impl is not available.
>>
>> These variables are intended to enable reproducing bugs and testing
>> packages against specific dev-lang/rust{,-bin} packages; they must
>> not be set in ebuilds.
>>
>> Closes: https://bugs.gentoo.org/945752
>> Signed-off-by: Matt Jolly <kangie@gentoo.org>
>> ---
>>   eclass/rust.eclass | 49 +++++++++++++++++++++++++++++++++++++++++-----
>>   1 file changed, 44 insertions(+), 5 deletions(-)
>>
>> diff --git a/eclass/rust.eclass b/eclass/rust.eclass
>> index 71cbb4b24f8c..991a9cdb7f14 100644
>> --- a/eclass/rust.eclass
>> +++ b/eclass/rust.eclass
>> @@ -98,6 +98,26 @@ declare -a -g -r _RUST_SLOTS_ORDERED=(
>>   	"1.54.0"
>>   )
>>   
>> +# == user control knobs ==
>> +
>> +# @ECLASS_VARIABLE: ERUST_SLOT
>> +# @USER_VARIABLE
>> +# @DESCRIPTION:
>> +# Specify the version (slot) of Rust to be used by the package. This is
>> +# useful for troubleshooting and debugging purposes; If unset, the newest
>> +# acceptable Rust version will be used. May be combined with ERUST_TYPE.
>> +# This variable must not be set in ebuilds.
>> +
>> +# @ECLASS_VARIABLE: ERUST_TYPE
>> +# @USER_VARIABLE
>> +# @DESCRIPTION:
>> +# Specify the type of Rust to be used by the package from options:
>> +# 'source' or 'binary' (-bin). This is useful for troubleshooting and
>> +# debugging purposes. If unset, the standard eclass logic will be used
>> +# to determine the type of Rust to use (i.e. prefer source if binary
>> +# is also available). May be combined with ERUST_SLOT.
>> +# This variable must not be set in ebuilds.
> 
> Could you perhaps add 'OVERRIDE' to the names, to make it clear they're
> not supposed to be normally used?  Just like we have
> PYTHON_COMPAT_OVERRIDE in Python eclasses.
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH] rust.eclass: add ERUST_{SLOT,TYPE} user variables
  2024-12-03 12:22 [gentoo-dev] [PATCH] rust.eclass: add ERUST_{SLOT,TYPE} user variables kangie
  2024-12-03 13:26 ` Michał Górny
@ 2024-12-04 17:45 ` Sam James
  1 sibling, 0 replies; 4+ messages in thread
From: Sam James @ 2024-12-04 17:45 UTC (permalink / raw
  To: kangie; +Cc: gentoo-dev

kangie@gentoo.org writes:

> From: Matt Jolly <kangie@gentoo.org>
>
> These variables enable users (though most likely Gentoo developers)
> to override the selection of the Rust implementation by the eclass.
>
> This means that _only_ the specified ERUST_SLOT and/or ERUST_TYPE
> ('source' or 'binary') will be checked for, with the eclass `die`ing
> with "No Rust slot satisfying the package's dependencies..." if the
> selected impl is not available.
>
> These variables are intended to enable reproducing bugs and testing
> packages against specific dev-lang/rust{,-bin} packages; they must
> not be set in ebuilds.

On reflection, I still quite like the idea of trying the eselect'ed Rust
first but I'm (of course) open to arguments not to.

>
> Closes: https://bugs.gentoo.org/945752
> Signed-off-by: Matt Jolly <kangie@gentoo.org>
> ---
>  eclass/rust.eclass | 49 +++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 44 insertions(+), 5 deletions(-)
>
> diff --git a/eclass/rust.eclass b/eclass/rust.eclass
> index 71cbb4b24f8c..991a9cdb7f14 100644
> --- a/eclass/rust.eclass
> +++ b/eclass/rust.eclass
> @@ -98,6 +98,26 @@ declare -a -g -r _RUST_SLOTS_ORDERED=(
>  	"1.54.0"
>  )
>  
> +# == user control knobs ==
> +
> +# @ECLASS_VARIABLE: ERUST_SLOT
> +# @USER_VARIABLE
> +# @DESCRIPTION:
> +# Specify the version (slot) of Rust to be used by the package. This is
> +# useful for troubleshooting and debugging purposes; If unset, the newest
> +# acceptable Rust version will be used. May be combined with ERUST_TYPE.
> +# This variable must not be set in ebuilds.
> +
> +# @ECLASS_VARIABLE: ERUST_TYPE
> +# @USER_VARIABLE
> +# @DESCRIPTION:
> +# Specify the type of Rust to be used by the package from options:
> +# 'source' or 'binary' (-bin). This is useful for troubleshooting and
> +# debugging purposes. If unset, the standard eclass logic will be used
> +# to determine the type of Rust to use (i.e. prefer source if binary
> +# is also available). May be combined with ERUST_SLOT.
> +# This variable must not be set in ebuilds.
> +
>  # == control variables ==
>  
>  # @ECLASS_VARIABLE: RUST_MAX_VER
> @@ -332,6 +352,10 @@ _get_rust_slot() {
>  			fi
>  		fi
>  
> +		if [[ -n "${ERUST_SLOT}" && "${slot}" != "${ERUST_SLOT}" ]]; then
> +			continue
> +		fi
> +
>  		# If we're in LLVM mode we can skip any slots that don't match the selected USE
>  		if [[ -n "${RUST_NEEDS_LLVM}" ]]; then
>  			if [[ "${llvm_slot}" != "${llvm_r1_slot}" ]]; then
> @@ -345,12 +369,27 @@ _get_rust_slot() {
>  			rust_check_deps && return
>  		else
>  			local usedep="${RUST_REQ_USE+[${RUST_REQ_USE}]}"
> -			# When checking for installed packages prefer the non `-bin` package
> +			# When checking for installed packages prefer the source package;
>  			# if effort was put into building it we should use it.
> -			local rust_pkgs=(
> -				"dev-lang/rust:${slot}${usedep}"
> -				"dev-lang/rust-bin:${slot}${usedep}"
> -			)
> +			local rust_pkgs
> +			case "${ERUST_TYPE}" in
> +				source)
> +					rust_pkgs=(
> +						"dev-lang/rust:${slot}${usedep}"
> +					)
> +					;;
> +				binary)
> +					rust_pkgs=(
> +						"dev-lang/rust-bin:${slot}${usedep}"
> +					)
> +					;;
> +				*)
> +					rust_pkgs=(
> +						"dev-lang/rust:${slot}${usedep}"
> +						"dev-lang/rust-bin:${slot}${usedep}"
> +					)
> +					;;
> +			esac
>  			local _pkg
>  			for _pkg in "${rust_pkgs[@]}"; do
>  				if has_version "${hv_switch}" "${_pkg}"; then


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-04 17:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 12:22 [gentoo-dev] [PATCH] rust.eclass: add ERUST_{SLOT,TYPE} user variables kangie
2024-12-03 13:26 ` Michał Górny
2024-12-04  1:38   ` Matt Jolly
2024-12-04 17:45 ` Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox