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

DRAFT: Avoid using the potentially non standard compliant lsb_release command #270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Matombo
Copy link

@Matombo Matombo commented Oct 26, 2022

Alternative to #257

Check the distribution the way dkms.in does it and not solely rely und the lsb_release command.

Not yet tested.

@evelikov
Copy link
Collaborator

(Copy/paste for cross-referencing purposes)

I've proposed removing the common.postinst script with #339. If you think that may cause issue please reply in there.

If we end up removing it, this MR will no longer be needed.

@bac0n
Copy link

bac0n commented Jan 14, 2025

I have redone my distro_version function (original only check from the beginning of the running_distibution= string):

distro_version(){
    local ID ID_LIKE
    for f in /etc/os-release /usr/lib/os-release; do
        [[ -r $f ]] && ( . "$f" && echo "${ID_LIKE:-$ID}" ) && return
    done
    die 4 "System is missing os-release file."
}

running_distribution=$(distro_version) || exit $?

and the case switches:

case " $running_distribution " in
    *\ @(ubuntu|debian)\ *)
        echo "Matching debian" ;;
    *\ pop\ *)
        echo "Matching pop!_os" ;;
    *)
        echo "no match!" ;;
esac

If you want to just match from the beginning of ID, ID_LIKE as it is now, probably simpler to cast ID_LIKE to an array first:

ID_LIKE=($ID_LIKE); echo "${ID_LIKE[0]:-$ID}"

that would remove the need for word* wildcard matching:

case "$running_distribution" in
    ubuntu|debian) echo match ;;
esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants