Skip to content

properly check Docker version #871

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 1 commit into
base: master
Choose a base branch
from

Conversation

anarcat
Copy link

@anarcat anarcat commented Jan 10, 2024

dpkg --compare-versions is debian-specific, but we're already debian-specific here.

Closes: #869

@anarcat
Copy link
Author

anarcat commented Jan 10, 2024

this is an alternative fix for #869 that possibly addresses the fundamental issue a little better. i think it might still be worth having a way to skip this mechanism in any case.

dpkg --compare-versions is debian-specific, but we're already
debian-specific here.
@anarcat anarcat force-pushed the better-version-compare branch from 15b6934 to 0a7329d Compare May 21, 2025 13:35
@anarcat
Copy link
Author

anarcat commented May 21, 2025

i will note that the conflict here was due to a rewrite of that version comparison to this function:

version_gt() (
    set +x

    yy_a="$(echo "$1" | cut -d'.' -f1)"
    yy_b="$(echo "$2" | cut -d'.' -f1)"
    if [ "$yy_a" -lt "$yy_b" ]; then
        return 1
    fi
    if [ "$yy_a" -gt "$yy_b" ]; then
        return 0
    fi
    mm_a="$(echo "$1" | cut -d'.' -f2)"
    mm_b="$(echo "$2" | cut -d'.' -f2)"
    mm_a="${mm_a#0}"
    mm_b="${mm_b#0}"
    if [ "${mm_a:-0}" -lt "${mm_b:-0}" ]; then
        return 1
    fi
    if [ "${mm_a:-0}" -gt "${mm_b:-0}" ]; then
        return 0
    fi

    bb_a="$(echo "$1" | cut -d'.' -f3)"
    bb_b="$(echo "$2" | cut -d'.' -f3)"
    bb_a="${bb_a#0}"
    bb_b="${bb_b#0}"
    if [ "${bb_a:-0}" -lt "${bb_b:-0}" ]; then
        return 1
    fi
    if [ "${bb_a:-0}" -gt "${bb_b:-0}" ]; then
        return 0
    fi

    return 1
)

which... i mean. i am having a hard time putting this nicely, but let's just say this could be slightly more readable and less buggy, to say the least. that function is 35 lines long, compared to my one-line patch, and doesn't actually work for debian versions:

helpers.sh: line 190: [: 24+dfsg1: integer expression expected

so i've rebased this and urge maintainers here to take another look at this merge request instead of reinventing the wheel like this. i haven't actually ripped out version_gt but i would strongly recommend getting rid of that code.

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.

last upgrade crashed on debian bookworm
1 participant