Sensible default for __apt_source --component #31

Closed
opened 2021-11-20 11:24:58 +00:00 by ungleich-gitea · 6 comments

I reckon, more often than not, if one leaves it empty, they mean main. Hence I am proposing we change the default to main from the current empty string.

I do realise, this seems to be a breaking change, however an empty value here would cause apt to fail with an error anyway, so the other option would be to make --component mandatory. Which -- considering above statement -- would be the less elegant solution. (At least in my view... 😉 )

I reckon, more often than not, if one leaves it empty, they mean `main`. Hence I am proposing we change the default to `main` from the current *empty string*. I do realise, this seems to be a breaking change, however an empty value here would cause `apt` to fail with an error anyway, so the other option would be to make `--component` mandatory. Which -- considering above statement -- would be the less elegant solution. (At least in my view... :wink: )
Author
Owner

As much as I see the value in @ssrq's suggestions, as this has been stale for 9 months now, I am inclined to close it.

Feel free to reopen, if you disagree...

As much as I see the value in @ssrq's suggestions, as this has been stale for 9 months now, I am inclined to close it. Feel free to reopen, if you disagree...
Author
Owner

Thanks for your response, @steven. I looked at a few 3rd party repos and they used main, too, so I implied that this is some sort of common agreement.
Do you have examples of repositories that do not follow this style, so that we have some basis to reason on?

After scanning through sources.list(5) I take it that you can omit the component if you specify a slash-terminated path instead of distribution + component.

What do you think about if we add a --path parameter that is mutually exclusive with --distribution and --component?

e.g.:

if test -s "${__object:?}/parameter/distribution"
then
    test -s "${__object:?}/parameter/component" || {
        echo 'If --distribution is used, at least one --component must also be given.' >&2
        exit 1
    }
    locator=$(printf '%s%s' \
        "$(cat "${__object:?}/parameter/distribution")" \
        "$(printf ' %s' $(cat "${__object:?}/parameter/component"))"
fi

if test -s "${__object:?}/parameter/path"
then
    test -z "${locator}" || {
        echo '--distribution and --path are mutually exclusive.' >&2
        exit 1
    }

    path=$(cat "${__object:?}/parameter/path")
    case $path
    in
        (/*/)
            locator=$path
            ;;
        (*)
            printf 'Invalid --path: %s\n' "${path}" >&2
            printf 'Path must start and end with a slash.\n' >&2
            ;;
    esac
    unset path
fi

test -n "${locator}" || {
    echo 'Use must provide either --distribution or --path.' >&2
    exit 1
}
Thanks for your response, @steven. I looked at a few 3rd party repos and they used `main`, too, so I implied that this is some sort of common agreement. Do you have examples of repositories that do not follow this style, so that we have some basis to reason on? After scanning through [sources.list(5)](https://manpages.debian.org/buster/apt/sources.list.5.en.html) I take it that you can omit the component if you specify a slash-terminated path instead of distribution + component. What do you think about if we add a `--path` parameter that is mutually exclusive with `--distribution` and `--component`? e.g.: ```sh if test -s "${__object:?}/parameter/distribution" then test -s "${__object:?}/parameter/component" || { echo 'If --distribution is used, at least one --component must also be given.' >&2 exit 1 } locator=$(printf '%s%s' \ "$(cat "${__object:?}/parameter/distribution")" \ "$(printf ' %s' $(cat "${__object:?}/parameter/component"))" fi if test -s "${__object:?}/parameter/path" then test -z "${locator}" || { echo '--distribution and --path are mutually exclusive.' >&2 exit 1 } path=$(cat "${__object:?}/parameter/path") case $path in (/*/) locator=$path ;; (*) printf 'Invalid --path: %s\n' "${path}" >&2 printf 'Path must start and end with a slash.\n' >&2 ;; esac unset path fi test -n "${locator}" || { echo 'Use must provide either --distribution or --path.' >&2 exit 1 } ```
Author
Owner

There are much more deb repos in use these days then the ones of Ubuntu and Debian.
Many if not most of them do not use 'main' as the component.

I think the proposed change breaks backwards compatibility for no real added value.
After all, depending on how you structure your cdist types, you're talking about 2 occurrences of the string 'main' that you save.

Grepping through my primary ~/.cdist config I have at least 6 places that would be broken by this change. That's not a lot, but nevertheless.

@ssrq the reason to default to empty string is third party deb repos that either do not have a component part or do not use 'main'.

So -1 from my side.

There are much more deb repos in use these days then the ones of Ubuntu and Debian. Many if not most of them do not use 'main' as the component. I think the proposed change breaks backwards compatibility for no real added value. After all, depending on how you structure your cdist types, you're talking about 2 occurrences of the string 'main' that you save. Grepping through my primary ~/.cdist config I have at least 6 places that would be broken by this change. That's not a lot, but nevertheless. @ssrq the reason to default to empty string is third party deb repos that either do not have a component part or do not use 'main'. So -1 from my side.
Author
Owner

The main component is used by De??an and Ubuntu, so I think that it is a sane default.
@steven I'm only wondering what the use case was to have an empty string as the default?

While at it and doing partially breaking changes, I would convert the --component parameter to a optional_multiple.
I think it makes sense to abstract away the construction of the correctly formatted source line from the user.
If the user supplies a space-delimited string, I would print a message to stderr telling the user to consider using multiple --component arguments instead.

The `main` component is used by De??an and Ubuntu, so I think that it is a sane default. @steven I'm only wondering what the use case was to have an empty string as the default? While at it and doing partially breaking changes, I would convert the `--component` parameter to a `optional_multiple`. I think it makes sense to abstract away the construction of the correctly formatted source line from the user. If the user supplies a space-delimited string, I would print a message to stderr telling the user to consider using multiple `--component` arguments instead.
Author
Owner

mentioned in merge request !932

mentioned in merge request !932
Author
Owner

changed the description

changed the description
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: ungleich-public/cdist#31
No description provided.