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

rpm: always replace existing repo-configuration #458

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ do_install() {
installation.

If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.
again to update Docker, you can ignore this message, but be aware that the
script resets any custom changes in the deb and rpm repo configuration
files to match the parameters passed to the script.

You may press Ctrl+C now to abort this script.
EOF
Expand Down Expand Up @@ -559,7 +561,7 @@ do_install() {
fi
if command_exists dnf5; then
$sh_c "dnf -y -q --setopt=install_weak_deps=False install dnf-plugins-core"
$sh_c "dnf5 config-manager addrepo --save-filename=docker-ce.repo --from-repofile='$repo_file_url'"
$sh_c "dnf5 config-manager addrepo --overwrite --save-filename=docker-ce.repo --from-repofile='$repo_file_url'"

if [ "$CHANNEL" != "stable" ]; then
$sh_c "dnf5 config-manager setopt \"docker-ce-*.enabled=0\""
Expand All @@ -568,6 +570,7 @@ do_install() {
$sh_c "dnf makecache"
elif command_exists dnf; then
$sh_c "dnf -y -q --setopt=install_weak_deps=False install dnf-plugins-core"
$sh_c "rm -f /etc/yum.repos.d/docker-ce.repo /etc/yum.repos.d/docker-ce-staging.repo"
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if there's cleaner ways to do this; I couldn't find subcommands or options in older dnf versions to replace existing repo-configs or to easily "reconcile" the options for each repo (without writing complex steps to generate the baseurl etc).

$sh_c "dnf config-manager --add-repo $repo_file_url"

if [ "$CHANNEL" != "stable" ]; then
Expand All @@ -577,6 +580,7 @@ do_install() {
$sh_c "dnf makecache"
else
$sh_c "yum -y -q install yum-utils"
$sh_c "rm -f /etc/yum.repos.d/docker-ce.repo /etc/yum.repos.d/docker-ce-staging.repo"
$sh_c "yum-config-manager --add-repo $repo_file_url"

if [ "$CHANNEL" != "stable" ]; then
Expand Down Expand Up @@ -659,18 +663,23 @@ do_install() {
set -x
fi
$sh_c "zypper install -y $pre_reqs"
$sh_c "rm -f /etc/zypp/repos.d/docker-ce-*.repo"
$sh_c "zypper addrepo $repo_file_url"
if ! is_dry_run; then
cat >&2 <<-'EOF'
WARNING!!
openSUSE repository (https://download.opensuse.org/repositories/security:/SELinux) will be enabled now.
Do you wish to continue?
You may press Ctrl+C now to abort this script.

opensuse_factory_url="https://download.opensuse.org/repositories/security:/SELinux/openSUSE_Factory/"
if ! zypper lr -d | grep -q "${opensuse_factory_url}"; then
opensuse_repo="${opensuse_factory_url}security:SELinux.repo"
Comment on lines +669 to +671
Copy link
Member Author

Choose a reason for hiding this comment

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

For this repository, I didn't want to do a blanket "remove the file", because we have no real control over the filename (/etc/zypp/repos.d/security_SELinux.repo), which I think is based on security:SELinux.repo -> security_SELinux.repo, but not 100% sure how much of a promise that is.

So instead of removing the file, I decided to check if a repository pointing to the given URL is already configured, which should probably cover this situation.

if ! is_dry_run; then
cat >&2 <<- EOF
WARNING!!
openSUSE repository ($opensuse_repo) will be enabled now.
Do you wish to continue?
You may press Ctrl+C now to abort this script.
EOF
( set -x; sleep 30 )
( set -x; sleep 20 )
fi
$sh_c "zypper addrepo $opensuse_repo"
fi
opensuse_repo="https://download.opensuse.org/repositories/security:/SELinux/openSUSE_Factory/security:SELinux.repo"
$sh_c "zypper addrepo $opensuse_repo"
$sh_c "zypper --gpg-auto-import-keys refresh"
$sh_c "zypper lr -d"
)
Expand Down
Loading