Skip to content

ENT-12600: detect-environment: Document and refactor #1737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

larsewi
Copy link
Contributor

@larsewi larsewi commented Jun 6, 2025

Build with exotics and no tests
Build Status

^ Build failures are unrelated:

@larsewi larsewi changed the title detect-environment: Fixed shellcheck issues detect-environment: Document and refactor Jun 6, 2025
@larsewi larsewi changed the title detect-environment: Document and refactor ENT-12600: detect-environment: Document and refactor Jun 6, 2025
@cf-bottom
Copy link

Thanks for submitting a PR! Maybe @craigcomstock can review this?

@larsewi larsewi force-pushed the detect-environment branch 5 times, most recently from eb0edfd to 4ccc0c9 Compare June 10, 2025 11:49
@larsewi larsewi force-pushed the detect-environment branch 2 times, most recently from d6ca0df to 2632a22 Compare June 16, 2025 08:06
larsewi added 18 commits June 16, 2025 10:17
Renamed function `detect_labels` to `detect_cross_target`, because this
is really what it does. Furthermore, I added a comment explaining the
code, as well as code to inform about the detection of cross target.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
The rest of the file uses two space indentation. Hence, the check to see
if the functions script was sourced should also have two space
indentation for consitency.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Put the pattern block terminators on separate lines, in the
detect_distribution function, for the sake of consistency.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Removed version substitution of the Debian release code-names (e.g.,
jessie, buster, etc.) from /etc/debian_version. Looking through the
[changelog](https://launchpad.net/debian/+source/base-files/+changelog)
for the base-files package in Debian, you can easily see that it has
never contained the code-names. At least not since version 5.0.3.
Furthermore, we have not updated the version substitution since Debian
10 which is End-of-Life.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
There has not been a 1-digit major release of ubuntu for a long time.
Hence, there is no point in looking for it when verifying the version
number extracted from /etc/lsb-release.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
On SUSE 12 the /etc/SuSE-release file exists with a deprecation warning.
However, /etc/os-release also exists. So we might as well remove the
parsing of the former and rely on the latter.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
If the former if condition is true, then the latter implicitly cannot be
true. Hence, there is no point in evaluating it.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Put the pattern block terminators on separate lines, in the
detect_packaging function, for the sake of consistency.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Put the pattern block terminators on separate lines, in the
detect_arch function, for the sake of consistency.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
For some reason the version detection for FreeBSD and HP-UX was in the
detect_arch function. However, it belongs in the detect_os function.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
AIX 5.3 is no longer supported, so we don't need this environment
variable anymore.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
@larsewi larsewi force-pushed the detect-environment branch from 2632a22 to b2be1bc Compare June 16, 2025 08:19
larsewi added 7 commits June 16, 2025 16:39
Signed-off-by: Lars Erik Wik <[email protected]>
The function "fatal" is not defined in this script. So it may not be
available.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Put the pattern block terminators on separate lines, in the
detect_cores function, for the sake of consistency.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
The detect-environment script is quite noicy due to the fact that it
prints the environment every time it's sourced. Hence, modified it to
print only the environment variables that the script affects.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
If we disable -x to decrease the verbosity of the build scripts. Then
these log messages will come in handy.

Ticket: ENT-12600
Signed-off-by: Lars Erik Wik <[email protected]>
@larsewi larsewi force-pushed the detect-environment branch from b2be1bc to d02fbb9 Compare June 16, 2025 14:40
@larsewi larsewi requested a review from craigcomstock June 20, 2025 10:06
@larsewi larsewi marked this pull request as ready for review June 20, 2025 10:06
@larsewi larsewi requested a review from olehermanse June 24, 2025 07:30
@@ -72,7 +72,7 @@ case "$WITH_SYSTEMD" in
esac

# RHEL 8 requires an SELinux policy
if [ "x$OS" = "xrhel" ] && [ "${VER%\.*}" -gt "7" ]; then
if [ "x$OS" = "xrhel" ] && [ "${OS_VERSION%\.*}" -gt "7" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to use this x business. https://www.shellcheck.net/wiki/SC2268

Unless we run on awfully old shells, which we do... so maybe change the letter as shellcheck suggests

If you are targeting especially old shells, you can ignore this warning (or use a different letter).

esac

# Windows is build on Debian. Hence we need to determine the architecture
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Windows is build on Debian. Hence we need to determine the architecture
# We need to determine the architecture

Windows is built on Ubuntu-16, not Debian, and I don't think that is important to this area of code which distribution is involved.


PATCH=`func_whereis gpatch patch`
# We use it to submit patches to the dependencies.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# We use it to submit patches to the dependencies.
# We use patch to apply patches to the dependencies.

# This function appends the -j/--jobs option to the MAKEFLAGS environment
# variable based on the number of cores. However, the variable is overwritten in
# the "install-dependencies" script. I created a ticket fix this (see
# ENT-13041).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no doubt! over-rode to -j1 even! :(

hpux)
echo "Detected OS family is hpux"
NUM_CORES="$(ioscan -k -C processor |grep processor | wc -l)";;
NUM_CORES="$(ioscan -k -C processor | grep -c processor)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check this? I wouldn't bet that grep on hpux is "normal" ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked, all good in our hpux environment.

           -c                  Only a count of matching lines is printed.

@@ -386,7 +426,7 @@ detect_environment
echo
echo
echo "==================== Current environment ========================"
env
env | grep -E "^(label|CROSS_TARGET|UNAME|OS|OS_VERSION|DEP_PACKAGING|PACKAGING|ARCH|MAKE|FUSER|PATCH|MAKEFLAGS)="
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line will definitely get lost in refactorings. Maybe we could instead append to a string near each of these and use that here! That way when someone copy/pastas a section about FUSER it will come with all the bits to make this line work.

@olehermanse olehermanse removed their request for review June 27, 2025 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants