Skip to content
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

Merged
merged 4 commits into from Dec 4, 2017
Merged

config-functions.sh - partial rewrite of SetOSVendorAndVersion #1611

merged 4 commits into from Dec 4, 2017

Conversation

gdha
Copy link
Member

@gdha gdha commented Nov 30, 2017

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 to lsb_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...

…and perhaps also /etc/issue

before falling back to lsb_release.
Feedback and updates are welcome - WIP #731
@gdha gdha added the enhancement Adaptions and new features label Nov 30, 2017
@gdha gdha added this to the ReaR v2.3 milestone Nov 30, 2017
@gdha gdha self-assigned this Nov 30, 2017
@gdha gdha requested review from schlomo, gozora, schabrolles and a team November 30, 2017 14:19
Copy link
Member

@schlomo schlomo left a 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
Copy link
Member

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
Copy link
Member

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

Copy link
Member

@schabrolles schabrolles left a comment

Choose a reason for hiding this comment

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

@gdha,

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"

@jsmeix
Copy link
Member

jsmeix commented Dec 4, 2017

Because all reviewers approved it
I would merge it soon today
to get it into ReaR 2.3.

@gdha
Copy link
Member Author

gdha commented Dec 4, 2017

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
@gdha
Copy link
Member Author

gdha commented Dec 4, 2017

@rear/contributors May I clean up the rear.spec file which auto creates the os.conf file, or shall we wait to do this after the release of 2.3?

@jsmeix
Copy link
Member

jsmeix commented Dec 4, 2017

@gdha
because rear.spec for the "official" rear RPMs for SLES
and openSUSE is independent of rear.spec in OBS
I don't mind what you prefer for rear.spec in OBS.

I assume when os.conf is created by rear.spec (during build time)
it ensures that the right build-tim values are hardcoded/predefined
which could be more fail-safe provided users install a matching
rear RPM package but on the other hand this way most users
won't test if the run-time automatism via SetOSVendorAndVersion()
actually works.

@gdha gdha merged commit 30957e3 into rear:master Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adaptions and new features fixed / solved / done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants