fix: limit the files in rocky-repos

This commit is contained in:
Seaton Jiang 2021-11-09 17:43:47 +08:00
parent b5afd718a0
commit bb7509110d
No known key found for this signature in database
GPG Key ID: C1584029151E7E64
2 changed files with 12 additions and 10 deletions

View File

@ -16,7 +16,7 @@ Running this script will convert an existing CentOS 8 system to Rocky Linux 8.
#### Use Mirror URLs of Rocky Linux
```bash
export ROCKY_LINUX_ENV_MIRROR_URL="https://mirrors.example.org/rocky"
export ROCKY_ENV_MIRROR_URL="https://mirrors.example.org/rocky"
./migrate2rocky.sh -r
```

View File

@ -115,10 +115,10 @@ SUPPORTED_PLATFORM="platform:el$SUPPORTED_MAJOR"
ARCH=$(arch)
# Use Mirror URLs of Rocky Linux from environment if set.
ROCKY_LINUX_DEFAULT_URL="https://dl.rockylinux.org/pub/rocky"
ROCKY_LINUX_MIRROR_URL="${ROCKY_LINUX_ENV_MIRROR_URL:-"${ROCKY_LINUX_DEFAULT_URL}"}"
ROCKY_DEFAULT_URL="https://dl.rockylinux.org/pub/rocky"
ROCKY_MIRROR_URL="${ROCKY_ENV_MIRROR_URL:-"${ROCKY_DEFAULT_URL}"}"
gpg_key_url="${ROCKY_LINUX_MIRROR_URL}/RPM-GPG-KEY-rockyofficial"
gpg_key_url="${ROCKY_MIRROR_URL}/RPM-GPG-KEY-rockyofficial"
gpg_key_sha512="88fe66cf0a68648c2371120d56eb509835266d9efdf7c8b9ac8fc101bdf1f0e0197030d3ea65f4b5be89dc9d1ef08581adb068815c88d7b1dc40aa1c32990f6a"
sm_ca_dir=/etc/rhsm/ca
@ -127,8 +127,8 @@ unset tmp_sm_ca_dir
# all repos must be signed with the same key given in $gpg_key_url
declare -A repo_urls
repo_urls=(
[rockybaseos]="${ROCKY_LINUX_MIRROR_URL}/${SUPPORTED_MAJOR}/BaseOS/$ARCH/os/"
[rockyappstream]="${ROCKY_LINUX_MIRROR_URL}/${SUPPORTED_MAJOR}/AppStream/$ARCH/os/"
[rockybaseos]="${ROCKY_MIRROR_URL}/${SUPPORTED_MAJOR}/BaseOS/$ARCH/os/"
[rockyappstream]="${ROCKY_MIRROR_URL}/${SUPPORTED_MAJOR}/AppStream/$ARCH/os/"
)
# The repos package for CentOS stream requires special handling.
@ -850,11 +850,13 @@ EOF
fi
# Replace mirror
if [ -n "$ROCKY_LINUX_ENV_MIRROR_URL" ]; then
if [[ $ROCKY_ENV_MIRROR_URL ]]; then
local -a repo_files
readarray -t repo_files < <(rpm -ql rocky-repos | grep '\.repo$')
sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl='${ROCKY_LINUX_MIRROR_URL}'|g' \
-i.bak \
/etc/yum.repos.d/Rocky-*.repo
-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl='"$ROCKY_MIRROR_URL"'|g' \
-i.migrate2rocky \
"${repo_files[@]}"
fi
# Distrosync