문서의 이전 판입니다!
릴리즈 버전 고정 release lock
Rocky Linux를 dnf update시에 마이너 버전 업 시키지 않고 특정 버전으로 고정하는 방법
#!/bin/bash
##############################################
# Set the target release version to lock
RELEASE_VER="9.5"
echo "=== Starting Release Lock Script for Rocky Linux ${RELEASE_VER} ==="
# Define the location of the repo files on the newly installed system
REPO_PATH="/etc/yum.repos.d"
# List of default repo files to modify
REPO_FILES=("rocky.repo" "rocky-addons.repo" "rocky-extras.repo")
echo "Target repository path: ${REPO_PATH}"
echo "Target repository files: ${REPO_FILES[@]}"
# Loop through each repo file and modify it
for repo_file in "${REPO_FILES[@]}"; do
if [ -f "${REPO_PATH}/${repo_file}" ]; then
echo "Processing file: ${REPO_PATH}/${repo_file}"
# 1. Create a backup of the original file
cp "${REPO_PATH}/${repo_file}" "${REPO_PATH}/${repo_file}.orig"
# 2. Comment out the 'mirrorlist' line
sed -i 's/^mirrorlist=/#mirrorlist=/' "${REPO_PATH}/${repo_file}"
# 3. Uncomment 'baseurl' and replace the path with the vault path
# Using comma as a separator for sed to avoid issues with slashes in URLs
sed -i "s,^#baseurl=http://dl.rockylinux.org/\$contentdir/\$releasever/,baseurl=http://dl.rockylinux.org/vault/rocky/${RELEASE_VER}/," "${REPO_PATH}/${repo_file}"
echo "Finished processing ${repo_file}"
else
echo "Warning: ${REPO_PATH}/${repo_file} not found. Skipping."
fi
done
echo "Cleaning DNF cache..."
dnf clean all
echo "=== Release Lock Script Finished Successfully ==="
# version lock end
########################################