Re: [PATCH 7/7] perf build: install-build-deps: add RHEL family devel package mapping

[email protected]
Newsgroups org.kernel.vger.linux-perf-users
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The script outputs a `missing_file: unbound variable` error to stderr and alters the exit code to 1 upon successful completion due to `set -u` and local variable scope lifecycle.
--

--- Patch [7]: [PATCH 7/7] perf build: install-build-deps: add RHEL family devel package mapping ---
commit 5192f0f9f2879409655c946317c1f14bc8dff929
Author: Arnaldo Carvalho de Melo <[email protected]>

perf build: install-build-deps: add RHEL family devel package mapping

With the Fedora mapping in place, this patch extends it to the RHEL
family (RHEL, CentOS Stream, Rocky Linux, AlmaLinux, Oracle Linux),
which shares most Fedora package names and runs dnf (RHEL 8 and
later).

> diff --git a/tools/perf/scripts/install-build-deps.sh b/tools/perf/scripts/install-build-deps.sh
> index 4a6f4bda49094..ef2226bd79b5f 100755
> --- a/tools/perf/scripts/install-build-deps.sh
> +++ b/tools/perf/scripts/install-build-deps.sh

[ ... ]

> @@ -377,23 +518,46 @@ main() {

[ ... ]

> +	missing_file=$(mktemp) || {
> +		echo "error: cannot create a temporary file (mktemp failed)" >&2
> +		exit 1
> +	}
> +	# package_set() runs in a subshell, doing dnf repoquery loops that
> +	# may be interrupted: remove the temp file on any exit and turn
> +	# SIGINT/SIGTERM into an exit, so the script terminates instead of
> +	# resuming after the interrupted command.
> +	trap 'rm -f "$missing_file"' EXIT

[Severity: Medium]
Since missing_file is declared as a local variable in main(), will this
trap trigger an unbound variable error when the script completes?

Because single quotes are used for the trap command, the missing_file
variable is evaluated when the trap fires at the very end of the script.
When the default install action succeeds, main() returns normally and its
local variables go out of scope.

Will this unbound variable evaluation cause the script to exit with code 1
on a successful run, failing the make install-build-deps target?

[ ... ]

> @@ -410,6 +574,7 @@ main() {
>  		echo "error: the install command failed, see the output above" >&2
>  		exit 1
>  	}
> +	note_missing "$missing_pkgs"
>  }
>  
>  main "$@"

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.