[OS-BUILD PATCHv2] redhat/configs: Change script interpreter to /bin/bash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Benjamin Poirier <bpoirier@xxxxxxxxxx>

redhat/configs: Change script interpreter to /bin/bash

Upstream-status: RHEL-only
Bugzilla: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3668

When running `make dist-configs` on a system where /bin/sh is dash (rather
than bash), the command fails with:

[...]
Building .../redhat/configs/kernel-riscv64-rt-debug-fedora.config ...
Building .../redhat/configs/kernel-riscv64-rt-debug-fedora.config complete
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
./generate_all_configs.sh: 26: Bad substitution
head: cannot open '.../redhat/configs/kernel-6.14.0*.config' for reading: No such file or directory
cat: '.../redhat/configs/kernel-6.14.0*.config': No such file or directory
Processing .../redhat/configs/kernel-6.14.0*.config ...
.../Makefile:750: arch//Makefile: No such file or directory
make[3]: *** No rule to make target 'arch//Makefile'.  Stop.
make[2]: *** [Makefile:263: __sub-make] Error 2
make[1]: *** [Makefile:564: dist-configs] Error 1
make[1]: Leaving directory '.../redhat'
make: *** [makefile:12: dist-configs] Error 2

The problem is due to the following substitution:
${i:$specpackage_name_len}

If we remove the shellcheck ignore, shellcheck explains:
SC3057 (warning): In POSIX sh, string indexing is undefined.

Since there are already many other scripts under redhat/ which use
/bin/bash as their interpreter, fix this problem by changing the
interpreter for this script to use bash as well.

We can then remove the shellcheck ignore but this results in another
message:
SC2001 (style): See if you can use ${variable//search/replace} instead.

The code is restructured as suggested.

Signed-off-by: Benjamin Poirier <bpoirier@xxxxxxxxxx>

diff --git a/redhat/configs/generate_all_configs.sh b/redhat/configs/generate_all_configs.sh
index blahblah..blahblah 100755
--- a/redhat/configs/generate_all_configs.sh
+++ b/redhat/configs/generate_all_configs.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 # Adjusts the configuration options to build the variants correctly
 
@@ -22,9 +22,9 @@ fi
 # The +1 is to remove the - at the end of the SPECPACKAGE_NAME string
 specpackage_name_len=$((${#SPECPACKAGE_NAME} + 1))
 for i in "${SPECPACKAGE_NAME}"*-"$FLAVOR".config; do
-	# shellcheck disable=SC3057
-	NEW=${SPECPACKAGE_NAME}-"$SPECRPMVERSION"-$(echo "${i:$specpackage_name_len}" | sed s/-"$FLAVOR"//)
-	mv "$i" "$NEW"
+	variant=${i:$specpackage_name_len}
+	variant=${variant/-$FLAVOR}
+	mv "$i" "$SPECPACKAGE_NAME-$SPECRPMVERSION-$variant"
 done
 
 rm -f kernel-*-"$SECONDARY".config

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3668

-- 
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux