-
Notifications
You must be signed in to change notification settings - Fork 246
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
config-functions.sh - partial rewrite of SetOSVendorAndVersion #1611
Conversation
…and perhaps also /etc/issue before falling back to lsb_release. Feedback and updates are welcome - WIP #731
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for pushing this topic.
Some thoughts:
- If to use grep, can't you simplify the code by first determining the file to grep and then using the same block of greps for that?
- os-release is meant to be sourced in shell scripts, wouldn't that make the code much simpler and also avoid false positives, e.g. by matching some string in a comment? For security purposes we could source the file in a subshell and then return only the results that we care about.
- If to be very careful we could also check for
/usr/lib/os-release
if/etc/os-release
is absent
@@ -16,19 +16,52 @@ function SetOSVendorAndVersion () { | |||
# The test must match OS_VENDOR=generic and OS_VERSION=none in default.conf: | |||
if test "$OS_VENDOR" = generic -o "$OS_VERSION" = none ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticed, the comment says "and", the check does "or"
grep -q -i 'debian' /etc/os-release && OS_VENDOR=Debian | ||
grep -q -i -E '(ubuntu|linuxmint)' /etc/os-release && OS_VENDOR=Ubuntu | ||
grep -q -i 'arch' /etc/os-release && OS_VENDOR=Arch | ||
OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | cut -d\" -f2 ) # 7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this would be much simpler done via sourcing the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just one thought, /etc/os-release
provides variables ID
and ID_LIKE
. Why not use them to create OS_VENDOR
(from ID) and OS_MASTER_VENDOR
(from ID_LIKE) ?
here is the output from a redhat Linux
NAME="Red Hat Enterprise Linux Server"
VERSION="7.4 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.4"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.4 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.4:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.4
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.4"
Because all reviewers approved it |
Would like to make some more updates before I push into rear-2.3. Will do this today |
…e checks for older versions of SuSE and RedHat For issue #731
@rear/contributors May I clean up the rear.spec file which auto creates the |
@gdha I assume when os.conf is created by rear.spec (during build time) |
For issue #731 we tried to avoid the usage of
lsb_release
, therefore, we try to extract all required info from/etc/os-release
, or/etc/system-release
, or/etc/issue
before falling back tolsb_release
.In later stadium we will also write the
/etc/rear/os.conf
file instead of being auto-created by installing the rpm. For Debian or Ubuntu that did not happen. So, that is one of the reasons to harmonize the creation of/etc/os.conf
.This PR is not complete, but I wanted to push it forward for your comments etc...