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

[pull] master from docker:master #53

Merged
merged 8 commits into from
Sep 12, 2024
Merged

Conversation

pull[bot]
Copy link

@pull pull bot commented Sep 12, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

thaJeztah and others added 8 commits September 4, 2024 16:09
The `-y` and `-q` options are global options, and can be set before the
command that's run. There's some ambiguity in the USAGE output of different
versions (`yum`, `dnf`, `dnf5`)

yum always outputs the same usage, but shows that options go _before_
the command;

    yum --help
    Usage: yum [options] COMMAND

    yum install --help
    Usage: yum [options] COMMAND

dnf (dnf4) is ambiguous; when showing usage for `install` it shows the
options to be set _after_ the command;

    dnf install --help
    usage: dnf install [-c [config file]] [-q] [-v] [--version] ....

but the global `--help` shows them to be before the command;

    dnf --help
    usage: dnf [options] COMMAND

    General DNF options:
      ...
      -q, --quiet           quiet operation
      -v, --verbose         verbose operation
      ,,,
      --setopt SETOPTS      set arbitrary config and repo options

dnf5 is more explicit about global vs per-command options;

    dnf --help
    Usage:
      dnf5 [GLOBAL OPTIONS] <COMMAND> ...

    dnf install --help
    Usage:
      dnf5 [GLOBAL OPTIONS] install [OPTIONS] [ARGUMENTS]

Testing shows that older versions (`dnf4` and `yum`) handle both fine,
and because `dnf5` (per the above) prefers global options to go before
the command, we can use that convention in this script.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
The `-y` and `-q` options are global options, and can be set before the
command that's run;

    apt-get --help
    ...
    Usage: apt-get [options] command
           apt-get [options] install|remove pkg1 [pkg2 ...]
           apt-get [options] source pkg1 [pkg2 ...]

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Fedora 41 and up use the new dnf5 as default, which is a rewrite of
the dnf commands with different options;

    + dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
      Unknown argument "--add-repo" for command "config-manager". Add "--help" for more information about the arguments.
      make: *** [Makefile:95: verify] Error 2
      script returned exit code 2

This patch:

- adds a check for dnf5
- removes some indirection through env-vars, and instead inlines the code

Note that with CentOS 7 being EOL, we can probably remove the `yum` variant
from the script, but I left those in place for now.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
We only need the config-manager, but it comes with a large number of weak
dependencies;

    dnf -q install dnf-plugins-core
    Transaction Summary:
    Installing:       78 packages

Disable weak dependencies to skip those, as they're not essential for this
script;

    dnf -q --setopt=install_weak_deps=False install dnf-plugins-core
    Transaction Summary:
    Installing:       32 packages

Signed-off-by: Sebastiaan van Stijn <[email protected]>
The addrepo command has a bug that causes it to fail if the `.repo` file
contains empty lines, causing it to fail;

    dnf config-manager addrepo --from-repofile="https://download.docker.com/linux/fedora/docker-ce.repo"
    Error in added repository configuration file. Cannot set repository option "#1=
    ": Option "#1" not found

Use a temporary file and strip empty lines as a workaround until the bug
is fixed.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
add support for dnf5 (in preparation of fedora 41)
commit 766b70c quoted these values to
prevent globbing, but used single quotes. However, these commands are
executed with `sh -c` using single quotes, which makes the output hard
to read because of the embedded quotes being escaped.

This patch changes to use double-quotes, which should still prevent
globbing to happen, but make the output more readable.

Before:

    CHANNEL=test ./install.sh
    ...
    Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
    + '[' test '!=' stable ']'
    + sh -c 'dnf config-manager --set-disabled '\''docker-ce-*'\'''
    + sh -c 'dnf config-manager --set-enabled '\''docker-ce-test'\'''
    + sh -c 'dnf makecache'

After:

    CHANNEL=test ./install.sh
    ...
    Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
    + '[' test '!=' stable ']'
    + sh -c 'dnf config-manager --set-disabled "docker-ce-*"'
    + sh -c 'dnf config-manager --set-enabled "docker-ce-test"'
    + sh -c 'dnf makecache'

Signed-off-by: Sebastiaan van Stijn <[email protected]>
use double-quotes to make output more readable
@pull pull bot added the ⤵️ pull label Sep 12, 2024
@pull pull bot merged commit 4bf098d into zengqingfu1442:master Sep 12, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant