为 Debian 和 Ubuntu 的新版本软件源启用 DEB822 格式并重构 & bug fix

This commit is contained in:
Super Manito
2025-05-13 06:21:27 +08:00
parent c23266e9db
commit c3d0d5fa2c
2 changed files with 343 additions and 238 deletions

View File

@@ -196,40 +196,40 @@ File_openKylinVersion=/etc/kylin-version/kylin-system-version.conf
File_ProxmoxVersion=/etc/pve/.version File_ProxmoxVersion=/etc/pve/.version
## 定义软件源相关文件或目录 ## 定义软件源相关文件或目录
File_DebianSourceList=/etc/apt/sources.list Dir_AptAdditionalSources=/etc/apt/sources.list.d
File_DebianSourceListBackup=/etc/apt/sources.list.bak Dir_AptAdditionalSourcesBackup=$Dir_AptAdditionalSources.bak
File_DebianSources=/etc/apt/sources.list.d/debian.sources
File_DebianSourcesBackup=/etc/apt/sources.list.d/debian.sources.bak
File_UbuntuSources=/etc/apt/sources.list.d/ubuntu.sources
File_UbuntuSourcesBackup=/etc/apt/sources.list.d/ubuntu.sources.bak
File_ArmbianSourceList=/etc/apt/sources.list.d/armbian.list
File_ArmbianSourceListBackup=/etc/apt/sources.list.d/armbian.list.bak
File_ProxmoxSourceList=/etc/apt/sources.list.d/pve-no-subscription.list
File_ProxmoxSourceListBackup=/etc/apt/sources.list.d/pve-no-subscription.list.bak
File_LinuxMintSourceList=/etc/apt/sources.list.d/official-package-repositories.list
File_LinuxMintSourceListBackup=/etc/apt/sources.list.d/official-package-repositories.list.bak
File_RaspberryPiSourceList=/etc/apt/sources.list.d/raspi.list
File_RaspberryPiSourceListBackup=/etc/apt/sources.list.d/raspi.list.bak
File_ArchLinuxMirrorList=/etc/pacman.d/mirrorlist
File_ArchLinuxMirrorListBackup=/etc/pacman.d/mirrorlist.bak
File_AlpineRepositories=/etc/apk/repositories
File_AlpineRepositoriesBackup=/etc/apk/repositories.bak
File_GentooMakeConf=/etc/portage/make.conf
File_GentooMakeConfBackup=/etc/portage/make.conf.bak
File_GentooReposConf=/etc/portage/repos.conf/gentoo.conf
File_GentooReposConfBackup=/etc/portage/repos.conf/gentoo.conf.bak
File_NixConf=/etc/nix/nix.conf
File_NixConfBackup=/etc/nix/nix.conf.bak
Dir_GentooReposConf=/etc/portage/repos.conf
Dir_DebianExtendSource=/etc/apt/sources.list.d
Dir_DebianExtendSourceBackup=/etc/apt/sources.list.d.bak
Dir_YumRepos=/etc/yum.repos.d Dir_YumRepos=/etc/yum.repos.d
Dir_YumReposBackup=/etc/yum.repos.d.bak Dir_YumReposBackup=$Dir_YumRepos.bak
Dir_ZYppRepos=/etc/zypp/repos.d Dir_ZYppRepos=/etc/zypp/repos.d
Dir_ZYppReposBackup=/etc/zypp/repos.d.bak Dir_ZYppReposBackup=$Dir_ZYppRepos.bak
Dir_GentooReposConf=/etc/portage/repos.conf
Dir_NixConfig=/etc/nix Dir_NixConfig=/etc/nix
File_AptSourceList=/etc/apt/sources.list
File_AptSourceListBackup=$File_AptSourceList.bak
File_DebianSources=$Dir_AptAdditionalSources/debian.sources
File_DebianSourcesBackup=$File_DebianSources.bak
File_UbuntuSources=$Dir_AptAdditionalSources/ubuntu.sources
File_UbuntuSourcesBackup=$File_UbuntuSources.bak
File_ArmbianSourceList=$Dir_AptAdditionalSources/armbian.list
File_ArmbianSourceListBackup=$File_ArmbianSourceList.bak
File_ProxmoxSourceList=$Dir_AptAdditionalSources/pve-no-subscription.list
File_ProxmoxSourceListBackup=$File_ProxmoxSourceList.bak
File_LinuxMintSourceList=$Dir_AptAdditionalSources/official-package-repositories.list
File_LinuxMintSourceListBackup=$File_LinuxMintSourceList.bak
File_RaspberryPiSourceList=$Dir_AptAdditionalSources/raspi.list
File_RaspberryPiSourceListBackup=$File_RaspberryPiSourceList.bak
File_ArchLinuxMirrorList=/etc/pacman.d/mirrorlist
File_ArchLinuxMirrorListBackup=$File_ArchLinuxMirrorList.bak
File_AlpineRepositories=/etc/apk/repositories
File_AlpineRepositoriesBackup=$File_AlpineRepositories.bak
File_GentooMakeConf=/etc/portage/make.conf
File_GentooMakeConfBackup=$File_GentooMakeConf.bak
File_GentooReposConf=/etc/portage/repos.conf/gentoo.conf
File_GentooReposConfBackup=$File_GentooReposConf.bak
File_NixConf=/etc/nix/nix.conf
File_NixConfBackup=$File_NixConf.bak
## 定义颜色变量 ## 定义颜色和样式变量
RED='\033[31m' RED='\033[31m'
GREEN='\033[32m' GREEN='\033[32m'
YELLOW='\033[33m' YELLOW='\033[33m'
@@ -730,23 +730,34 @@ function collect_system_info() {
fi fi
SYSTEM_JUDGMENT="$(lsb_release -is)" SYSTEM_JUDGMENT="$(lsb_release -is)"
SYSTEM_VERSION_CODENAME="${DEBIAN_CODENAME:-"$(lsb_release -cs)"}" SYSTEM_VERSION_CODENAME="${DEBIAN_CODENAME:-"$(lsb_release -cs)"}"
# Raspberry Pi OS ## Raspberry Pi OS 判定
if [ -s "${File_RaspberryPiOSRelease}" ]; then if [[ "${SYSTEM_FACTIONS}" == "${SYSTEM_DEBIAN}" ]] && [ -s "${File_RaspberryPiOSRelease}" ]; then
SYSTEM_JUDGMENT="${SYSTEM_RASPBERRY_PI_OS}" SYSTEM_JUDGMENT="${SYSTEM_RASPBERRY_PI_OS}"
SYSTEM_PRETTY_NAME="${SYSTEM_RASPBERRY_PI_OS}" SYSTEM_PRETTY_NAME="${SYSTEM_RASPBERRY_PI_OS}"
fi fi
# Debian 尚未正式发布的版本 ## 针对特定系统的判定
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_DEBIAN}" ]] && [[ -z "${SYSTEM_VERSION_ID}" ]]; then if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_DEBIAN}" ]]; then
if [[ "${SYSTEM_VERSION_CODENAME}" == "trixie" ]]; then ## 尚未正式发布的版本
if [[ -z "${SYSTEM_VERSION_ID}" && "${SYSTEM_VERSION_CODENAME}" == "trixie" ]]; then
SYSTEM_VERSION_ID="13" SYSTEM_VERSION_ID="13"
SYSTEM_VERSION_ID_MAJOR="${SYSTEM_VERSION_ID%.*}" SYSTEM_VERSION_ID_MAJOR="${SYSTEM_VERSION_ID%.*}"
SYSTEM_VERSION_ID_MINOR="${SYSTEM_VERSION_ID#*.}" SYSTEM_VERSION_ID_MINOR="${SYSTEM_VERSION_ID#*.}"
fi fi
## 是否使用 DEB822 格式
if [[ "${SYSTEM_VERSION_ID_MAJOR}" && "${SYSTEM_VERSION_ID_MAJOR}" -ge 13 ]]; then
USE_DEB822_FORMAT="true"
fi
fi
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_UBUNTU}" ]]; then
## 是否使用 DEB822 格式
if [[ "${SYSTEM_VERSION_ID_MAJOR}" && "${SYSTEM_VERSION_ID_MAJOR}" -ge 24 ]]; then
USE_DEB822_FORMAT="true"
fi
fi fi
;; ;;
"${SYSTEM_REDHAT}") "${SYSTEM_REDHAT}")
SYSTEM_JUDGMENT="$(awk '{printf $1}' $File_RedHatRelease)" SYSTEM_JUDGMENT="$(awk '{printf $1}' $File_RedHatRelease)"
## 特殊系统判断 ## 针对特定系统的判定
# Red Hat Enterprise Linux # Red Hat Enterprise Linux
grep -q "${SYSTEM_RHEL}" $File_RedHatRelease && SYSTEM_JUDGMENT="${SYSTEM_RHEL}" grep -q "${SYSTEM_RHEL}" $File_RedHatRelease && SYSTEM_JUDGMENT="${SYSTEM_RHEL}"
# CentOS Stream # CentOS Stream
@@ -875,7 +886,7 @@ function collect_system_info() {
"${SYSTEM_DEBIAN}") "${SYSTEM_DEBIAN}")
case "${SYSTEM_VERSION_ID_MAJOR}" in case "${SYSTEM_VERSION_ID_MAJOR}" in
8 | 9 | 10) 8 | 9 | 10)
SOURCE_BRANCH="debian-archive" # EOF SOURCE_BRANCH="debian-archive/debian"
;; ;;
*) *)
SOURCE_BRANCH="debian" SOURCE_BRANCH="debian"
@@ -898,13 +909,17 @@ function collect_system_info() {
SOURCE_BRANCH="centos-stream" # 使用 CentOS Stream 仓库 SOURCE_BRANCH="centos-stream" # 使用 CentOS Stream 仓库
;; ;;
*) *)
SOURCE_BRANCH="centos-vault" # EOF if [[ "${DEVICE_ARCH_RAW}" == "x86_64" ]]; then
SOURCE_BRANCH="centos-vault"
else
SOURCE_BRANCH="centos-altarch"
fi
;; ;;
esac esac
;; ;;
"${SYSTEM_CENTOS}") "${SYSTEM_CENTOS}")
if [[ "${DEVICE_ARCH_RAW}" == "x86_64" ]]; then if [[ "${DEVICE_ARCH_RAW}" == "x86_64" ]]; then
SOURCE_BRANCH="centos-vault" # EOF SOURCE_BRANCH="centos-vault"
else else
SOURCE_BRANCH="centos-altarch" SOURCE_BRANCH="centos-altarch"
fi fi
@@ -914,7 +929,7 @@ function collect_system_info() {
case "${SYSTEM_VERSION_ID_MAJOR}" in case "${SYSTEM_VERSION_ID_MAJOR}" in
8) 8)
if [[ "${DEVICE_ARCH_RAW}" == "x86_64" ]]; then if [[ "${DEVICE_ARCH_RAW}" == "x86_64" ]]; then
SOURCE_BRANCH="centos-vault" # EOF SOURCE_BRANCH="centos-vault"
else else
SOURCE_BRANCH="centos-altarch" SOURCE_BRANCH="centos-altarch"
fi fi
@@ -1352,18 +1367,19 @@ function backup_original_mirrors() {
if [[ "${BACKUP}" == "true" ]]; then if [[ "${BACKUP}" == "true" ]]; then
case "${SYSTEM_FACTIONS}" in case "${SYSTEM_FACTIONS}" in
"${SYSTEM_DEBIAN}" | "${SYSTEM_OPENKYLIN}") "${SYSTEM_DEBIAN}" | "${SYSTEM_OPENKYLIN}")
if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_LINUX_MINT}" ]]; then
# /etc/apt/sources.list # /etc/apt/sources.list
backup_file $File_DebianSourceList $File_DebianSourceListBackup "sources.list" if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_LINUX_MINT}" && -s "${File_AptSourceList}" ]]; then
backup_file $File_AptSourceList $File_AptSourceListBackup "sources.list"
fi fi
## 自新版本的 Debian 与 Ubuntu 起,软件源文件格式统一为 DEB822 格式,涉及 Debian 12 的容器镜像、Ubuntu 24.04 和未来尚未发布的版本
# Debian DEB822 格式源文件 # Debian DEB822 格式源文件
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_DEBIAN}" ]]; then if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_DEBIAN}" ]] && [ -f "${File_DebianSources}" ]; then
[ -f "${File_DebianSources}" ] && backup_file $File_DebianSources $File_DebianSourcesBackup "debian.sources" backup_file $File_DebianSources $File_DebianSourcesBackup "debian.sources"
USE_DEB822_FORMAT="true"
fi fi
# Ubuntu DEB822 格式源文件 # Ubuntu DEB822 格式源文件
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_UBUNTU}" ]]; then if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_UBUNTU}" ]] && [ -f "${File_UbuntuSources}" ]; then
[ -f "${File_UbuntuSources}" ] && backup_file $File_UbuntuSources $File_UbuntuSourcesBackup "ubuntu.sources" backup_file $File_UbuntuSources $File_UbuntuSourcesBackup "ubuntu.sources"
USE_DEB822_FORMAT="true"
fi fi
# Armbian # Armbian
if [ -f "${File_ArmbianRelease}" ]; then if [ -f "${File_ArmbianRelease}" ]; then
@@ -1418,18 +1434,21 @@ function backup_original_mirrors() {
function remove_original_mirrors() { function remove_original_mirrors() {
case "${SYSTEM_FACTIONS}" in case "${SYSTEM_FACTIONS}" in
"${SYSTEM_DEBIAN}" | "${SYSTEM_OPENKYLIN}") "${SYSTEM_DEBIAN}" | "${SYSTEM_OPENKYLIN}")
if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_LINUX_MINT}" ]]; then # /etc/apt/sources.list
[ -f "${File_DebianSourceList}" ] && sed -i '1,$d' $File_DebianSourceList if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_LINUX_MINT}" && -s "${File_AptSourceList}" ]]; then
sed -i '1,$d' $File_AptSourceList
fi fi
[ -d "${Dir_DebianExtendSource}" ] || mkdir -p $Dir_DebianExtendSource # /etc/apt/sources.list.d
## 自新版本的 Debian 与 Ubuntu 起,软件源文件格式统一为 DEB822 格式,涉及 Debian 12 的容器镜像、Ubuntu 24.04 和未来尚未发布的版本 [ -d "${Dir_AptAdditionalSources}" ] || mkdir -p $Dir_AptAdditionalSources
# Debian DEB822 格式源文件 # Debian DEB822 格式源文件
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_DEBIAN}" ]]; then if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_DEBIAN}" ]] && [ -f "${File_DebianSources}" ]; then
[ -f "${File_DebianSources}" ] && rm -rf "${File_DebianSources}" sed -i '1,$d' $File_DebianSources
USE_DEB822_FORMAT="true"
fi fi
# Ubuntu DEB822 格式源文件 # Ubuntu DEB822 格式源文件
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_UBUNTU}" ]]; then if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_UBUNTU}" ]] && [ -f "${File_UbuntuSources}" ]; then
[ -f "${File_UbuntuSources}" ] && rm -rf "${File_UbuntuSources}" sed -i '1,$d' $File_UbuntuSources
USE_DEB822_FORMAT="true"
fi fi
# Armbian # Armbian
if [ -f "${File_ArmbianRelease}" ]; then if [ -f "${File_ArmbianRelease}" ]; then
@@ -1579,8 +1598,18 @@ function change_mirrors_main() {
if command -v diff &>/dev/null && [[ "${BACKED_UP}" == "true" ]]; then if command -v diff &>/dev/null && [[ "${BACKED_UP}" == "true" ]]; then
case "${SYSTEM_FACTIONS}" in case "${SYSTEM_FACTIONS}" in
"${SYSTEM_DEBIAN}" | "${SYSTEM_OPENKYLIN}") "${SYSTEM_DEBIAN}" | "${SYSTEM_OPENKYLIN}")
if [[ "${USE_DEB822_FORMAT}" == "true" ]]; then
# DEB822 格式源文件
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_DEBIAN}" ]]; then
diff_file $File_DebianSourcesBackup $File_DebianSources
fi
if [[ "${SYSTEM_JUDGMENT}" == "${SYSTEM_UBUNTU}" ]]; then
diff_file $File_UbuntuSourcesBackup $File_UbuntuSources
fi
else
if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_LINUX_MINT}" ]]; then if [[ "${SYSTEM_JUDGMENT}" != "${SYSTEM_LINUX_MINT}" ]]; then
diff_file $File_DebianSourceListBackup $File_DebianSourceList diff_file $File_AptSourceListBackup $File_AptSourceList
fi
fi fi
# Armbian # Armbian
if [ -f "${File_ArmbianRelease}" ]; then if [ -f "${File_ArmbianRelease}" ]; then
@@ -1636,6 +1665,9 @@ function change_mirrors_main() {
"${SYSTEM_OPENCLOUDOS}") "${SYSTEM_OPENCLOUDOS}")
change_mirrors_OpenCloudOS change_mirrors_OpenCloudOS
;; ;;
"${SYSTEM_OPENKYLIN}")
change_mirrors_openKylin
;;
"${SYSTEM_ANOLISOS}") "${SYSTEM_ANOLISOS}")
change_mirrors_AnolisOS change_mirrors_AnolisOS
;; ;;
@@ -1651,9 +1683,6 @@ function change_mirrors_main() {
"${SYSTEM_GENTOO}") "${SYSTEM_GENTOO}")
change_mirrors_Gentoo change_mirrors_Gentoo
;; ;;
"${SYSTEM_OPENKYLIN}")
change_mirrors_openKylin
;;
"${SYSTEM_NIXOS}") "${SYSTEM_NIXOS}")
change_mirrors_NixOS change_mirrors_NixOS
;; ;;
@@ -1855,36 +1884,69 @@ function upgrade_software() {
## 更换基于 Debian 系 Linux 发行版的软件源 ## 更换基于 Debian 系 Linux 发行版的软件源
function change_mirrors_Debian() { function change_mirrors_Debian() {
function gen_debian_source() { ## 通用生成方法
echo "deb ${1} ${2} ${3} function gen_deb_source() {
# deb-src ${1} ${2} ${3} echo "deb ${WEB_PROTOCOL}://${1}/ ${2} ${3}
deb ${1} ${2}-updates ${3} # deb-src ${WEB_PROTOCOL}://${1}/ ${2} ${3}"
# deb-src ${1} ${2}-updates ${3}
deb ${1} ${2}-backports ${3}
# deb-src ${1} ${2}-backports ${3}"
} }
function gen_debian_source_no_backports() { function gen_deb_source_no_src() {
echo "deb ${1} ${2} ${3} echo "deb ${WEB_PROTOCOL}://${1}/ ${2} ${3}"
# deb-src ${1} ${2} ${3}
deb ${1} ${2}-updates ${3}
# deb-src ${1} ${2}-updates ${3}"
} }
function gen_ubuntu_source() { function gen_deb_disabled_source() {
echo "deb ${1} ${2} ${3} echo "# deb ${WEB_PROTOCOL}://${1}/ ${2} ${3}
# deb-src ${1} ${2} ${3} # # deb-src ${WEB_PROTOCOL}://${1}/ ${2} ${3}"
deb ${1} ${2}-updates ${3} }
# deb-src ${1} ${2}-updates ${3} function gen_deb822_source() {
deb ${1} ${2}-backports ${3} echo "Types: deb
# deb-src ${1} ${2}-backports ${3} URIs: ${WEB_PROTOCOL}://${1}/
Suites: ${2}
Components: ${3}
Signed-By: /usr/share/keyrings/${SYSTEM_JUDGMENT,,}-archive-keyring.gpg"
}
function gen_deb822_disabled_source() {
echo "# Types: deb
# URIs: ${WEB_PROTOCOL}://${1}/
# Suites: ${2}
# Components: ${3}
# Signed-By: /usr/share/keyrings/${SYSTEM_JUDGMENT,,}-archive-keyring.gpg"
}
function gen_deb_source_security() {
echo "## 安全更新软件源
$(gen_deb_source "${1}" "${2}-security" "${3}")"
}
function gen_deb822_source_security() {
echo "## 安全更新软件源
$(gen_deb822_source "${1}" "${2}-security" "${3}")"
}
## 针对特定系统生成软件源
function gen_debian_deb_source() {
echo "$(gen_deb_source "${1}" "${2}" "${3}")
$(gen_deb_source "${1}" "${2}-updates" "${3}")
$(gen_deb_source "${1}" "${2}-backports" "${3}")"
}
function gen_debian_deb822_source() {
echo "$(gen_deb822_source "${1}" "${2} ${2}-updates ${2}-backports" "${3}")"
}
function gen_debian_deb_source_no_backports() {
echo "$(gen_deb_source "${1}" "${2}" "${3}")
$(gen_deb_source "${1}" "${2}-updates" "${3}")"
}
function gen_debian_deb822_source_no_backports() {
echo "$(gen_deb822_source "${1}" "${2} ${2}-updates" "${3}")"
}
function gen_ubuntu_deb_source() {
echo "$(gen_deb_source "${1}" "${2}" "${3}")
$(gen_deb_source "${1}" "${2}-updates" "${3}")
$(gen_deb_source "${1}" "${2}-backports" "${3}")
## 预发布软件源(不建议启用)
$(gen_deb_disabled_source "${1}" "${2}-proposed" "${3}")"
}
function gen_ubuntu_deb822_source() {
echo "$(gen_deb822_source "${1}" "${2} ${2}-updates ${2}-backports" "${3}")
## 预发布软件源(不建议启用) ## 预发布软件源(不建议启用)
# deb ${1} ${2}-proposed ${3} $(gen_deb822_disabled_source "${1}" "${2}-proposed" "${3}")"
# deb-src ${1} ${2}-proposed ${3}"
}
function gen_security_source() {
echo "## 安全更新软件源
deb ${1} ${2}-security ${3}
# deb-src ${1} ${2}-security ${3}"
} }
## 使用官方源 ## 使用官方源
@@ -1907,9 +1969,12 @@ deb ${1} ${2}-security ${3}
;; ;;
esac esac
fi fi
local deb_source_title="## 默认禁用源码镜像以提高速度,如需启用请自行取消注释"
local repository_sections # 仓库区域 local repository_sections # 仓库区域
local tips="## 默认禁用源码镜像以提高速度,如需启用请自行取消注释" local source_host="${SOURCE}/${SOURCE_BRANCH}"
local base_url="${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}/" local source_host_security=""
case "${SYSTEM_JUDGMENT}" in case "${SYSTEM_JUDGMENT}" in
"${SYSTEM_DEBIAN}") "${SYSTEM_DEBIAN}")
case "${SYSTEM_VERSION_ID}" in case "${SYSTEM_VERSION_ID}" in
@@ -1920,32 +1985,45 @@ deb ${1} ${2}-security ${3}
repository_sections="main contrib non-free non-free-firmware" repository_sections="main contrib non-free non-free-firmware"
;; ;;
esac esac
source_host_security="${SOURCE_SECURITY:-"${SOURCE}"}/${SOURCE_SECURITY_BRANCH:-"${SOURCE_BRANCH}-security"}"
if [[ "${USE_DEB822_FORMAT}" == "true" ]]; then
if [[ "${SYSTEM_VERSION_CODENAME}" != "sid" ]]; then if [[ "${SYSTEM_VERSION_CODENAME}" != "sid" ]]; then
echo "${tips} echo "$(gen_debian_deb822_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")
$(gen_debian_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList
# 处理 security 仓库源 $(gen_deb822_source_security "${source_host_security}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSources
base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-"${SOURCE}"}/${SOURCE_SECURITY_BRANCH:-"${SOURCE_BRANCH}-security"}/"
echo "$(gen_security_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList
else else
echo "${tips} echo "$(gen_debian_deb822_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSources
deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections} fi
# deb-src ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}" >>$File_DebianSourceList else
if [[ "${SYSTEM_VERSION_CODENAME}" != "sid" ]]; then
echo "${deb_source_title}
$(gen_debian_deb_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")
$(gen_deb_source_security "${source_host_security}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_AptSourceList
else
echo "${deb_source_title}
$(gen_deb_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_AptSourceList
fi
fi fi
;; ;;
"${SYSTEM_UBUNTU}" | "${SYSTEM_ZORIN}") "${SYSTEM_UBUNTU}" | "${SYSTEM_ZORIN}")
repository_sections="main restricted universe multiverse" repository_sections="main restricted universe multiverse"
echo "${tips} source_host_security="${SOURCE_SECURITY:-${SOURCE}}/${SOURCE_BRANCH}"
$(gen_ubuntu_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList if [[ "${USE_DEB822_FORMAT}" == "true" ]]; then
# 处理 security 仓库源 echo "$(gen_ubuntu_deb822_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")
base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-${SOURCE}}/${SOURCE_BRANCH}/"
echo " $(gen_deb822_source_security "${source_host_security}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_UbuntuSources
$(gen_security_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList else
echo "${deb_source_title}
$(gen_ubuntu_deb_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")
$(gen_deb_source_security "${source_host_security}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_AptSourceList
fi
;; ;;
"${SYSTEM_KALI}") "${SYSTEM_KALI}")
repository_sections="main contrib non-free non-free-firmware" repository_sections="main contrib non-free non-free-firmware"
echo "${tips} echo "${deb_source_title}
deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections} $(gen_deb_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_AptSourceList
# deb-src ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}" >>$File_DebianSourceList
;; ;;
"${SYSTEM_DEEPIN}") "${SYSTEM_DEEPIN}")
if [[ "${SYSTEM_VERSION_ID}" == "25" ]]; then if [[ "${SYSTEM_VERSION_ID}" == "25" ]]; then
@@ -1953,15 +2031,15 @@ deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}
else else
repository_sections="main contrib non-free" repository_sections="main contrib non-free"
fi fi
echo "${tips} echo "${deb_source_title}
deb ${base_url}/${SYSTEM_VERSION_CODENAME} ${SYSTEM_VERSION_CODENAME} ${repository_sections} $(gen_deb_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_AptSourceList
# deb-src ${base_url} ${repository_sections}" >>$File_DebianSourceList
;; ;;
"${SYSTEM_LINUX_MINT}") "${SYSTEM_LINUX_MINT}")
## 专用源 ## 专用源
repository_sections="main upstream import backport" repository_sections="main upstream import backport"
echo "${tips} echo "${deb_source_title}
deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}" >>$File_LinuxMintSourceList $(gen_deb_source_no_src "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_LinuxMintSourceList
## 底层系统软件源 ## 底层系统软件源
local base_system_branch base_system_codename local base_system_branch base_system_codename
if [[ "${SYSTEM_VERSION_ID}" == 6 ]]; then if [[ "${SYSTEM_VERSION_ID}" == 6 ]]; then
@@ -1969,11 +2047,10 @@ deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}" >>$File_Linux
base_system_branch="debian" base_system_branch="debian"
base_system_codename="bookworm" base_system_codename="bookworm"
repository_sections="main contrib non-free non-free-firmware" repository_sections="main contrib non-free non-free-firmware"
base_url="${WEB_PROTOCOL}://${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}/" source_host="${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}"
echo "$(gen_debian_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList source_host_security="${SOURCE_SECURITY:-${SOURCE_BASE_SYSTEM:-${SOURCE}}}/${SOURCE_SECURITY_BRANCH:-${SOURCE_BASE_SYSTEM_BRANCH:-debian-security}}"
# 处理 security 仓库源 echo "$(gen_debian_deb_source "${source_host}" "${base_system_codename}" "${repository_sections}")
base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-${SOURCE_BASE_SYSTEM:-${SOURCE}}}/${SOURCE_SECURITY_BRANCH:-${SOURCE_BASE_SYSTEM_BRANCH:-debian-security}}/" $(gen_deb_source_security "${source_host_security}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList
echo "$(gen_security_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList
else else
# Ubuntu 版 # Ubuntu 版
if [[ "${DEVICE_ARCH_RAW}" == "x86_64" || "${DEVICE_ARCH_RAW}" == *i?86* ]]; then if [[ "${DEVICE_ARCH_RAW}" == "x86_64" || "${DEVICE_ARCH_RAW}" == *i?86* ]]; then
@@ -1996,32 +2073,30 @@ deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}" >>$File_Linux
;; ;;
esac esac
repository_sections="main restricted universe multiverse" repository_sections="main restricted universe multiverse"
base_url="${WEB_PROTOCOL}://${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}/" source_host="${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}"
echo "$(gen_ubuntu_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList source_host_security="${SOURCE_SECURITY:-${SOURCE_BASE_SYSTEM:-${SOURCE}}}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}"
# 处理 security 仓库源 echo "$(gen_ubuntu_deb_source "${source_host}" "${base_system_codename}" "${repository_sections}")
base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-${SOURCE_BASE_SYSTEM:-${SOURCE}}}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}/" $(gen_deb_source_security "${source_host_security}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList
echo "
$(gen_security_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_LinuxMintSourceList
fi fi
;; ;;
"${SYSTEM_RASPBERRY_PI_OS}") "${SYSTEM_RASPBERRY_PI_OS}")
## 专用源 ## 专用源
repository_sections="main" repository_sections="main"
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
SOURCE="archive.raspberrypi.org" SOURCE="archive.raspberrypi.org"
SOURCE_BRANCH="debian" SOURCE_BRANCH="debian"
base_url="${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}/" source_host="${SOURCE}/${SOURCE_BRANCH}"
fi fi
echo "${tips} echo "${deb_source_title}
deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections} $(gen_deb_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_RaspberryPiSourceList
# deb-src ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}" >>$File_RaspberryPiSourceList
## 底层系统软件源64位系统为 Debian 官方仓库32位为 Raspbian 仓库) ## 底层系统软件源64位系统为 Debian 官方仓库32位为 Raspbian 仓库)
local base_system_branch base_system_codename local base_system_branch base_system_codename
case "${DEVICE_ARCH_RAW}" in case "${DEVICE_ARCH_RAW}" in
x86_64 | aarch64) x86_64 | aarch64)
case "${SYSTEM_VERSION_ID_MAJOR}" in case "${SYSTEM_VERSION_ID_MAJOR}" in
8 | 9 | 10) 8 | 9 | 10)
base_system_branch="debian-archive" # EOF base_system_branch="debian-archive/debian"
;; ;;
*) *)
base_system_branch="debian" base_system_branch="debian"
@@ -2039,12 +2114,11 @@ deb ${base_url} ${SYSTEM_VERSION_CODENAME} ${repository_sections}
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
SOURCE="deb.debian.org" SOURCE="deb.debian.org"
fi fi
base_url="${WEB_PROTOCOL}://${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}/" source_host="${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}"
echo "${tips} source_host_security="${SOURCE_SECURITY:-${SOURCE_BASE_SYSTEM:-${SOURCE}}}/${SOURCE_SECURITY_BRANCH:-${SOURCE_BASE_SYSTEM_BRANCH:-debian-security}}"
$(gen_debian_source_no_backports "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_DebianSourceList echo "${deb_source_title}
# 处理 security 仓库源 $(gen_debian_deb_source_no_backports "${source_host}" "${base_system_codename}" "${repository_sections}")
base_url="${WEB_PROTOCOL}://${SOURCE_SECURITY:-${SOURCE_BASE_SYSTEM:-${SOURCE}}}/${SOURCE_SECURITY_BRANCH:-${SOURCE_BASE_SYSTEM_BRANCH:-debian-security}}/" $(gen_deb_source_security "${source_host_security}" "${base_system_codename}" "${repository_sections}")" >>$File_AptSourceList
echo "$(gen_security_source "${base_url}" "${base_system_codename}" "${repository_sections}")" >>$File_DebianSourceList
;; ;;
*) *)
base_system_branch="raspbian" base_system_branch="raspbian"
@@ -2052,15 +2126,16 @@ $(gen_debian_source_no_backports "${base_url}" "${base_system_codename}" "${repo
repository_sections="main contrib non-free rpi" repository_sections="main contrib non-free rpi"
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
SOURCE="raspbian.raspberrypi.org" SOURCE="raspbian.raspberrypi.org"
base_url="${WEB_PROTOCOL}://${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}/" source_host="${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}"
else else
base_url="${WEB_PROTOCOL}://${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}/raspbian/" source_host="${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}/raspbian"
fi fi
echo "${tips} echo "${deb_source_title}
deb ${base_url} ${base_system_codename} ${repository_sections} $(gen_deb_source "${source_host}" "${base_system_codename}" "${repository_sections}")" >>$File_AptSourceList
# deb-src ${base_url} ${base_system_codename} ${repository_sections}" >>$File_DebianSourceList ## multiarch 源
if [[ "${DEVICE_ARCH_RAW}" == "armv7l" && "${USE_OFFICIAL_SOURCE}" != "true" ]]; then if [[ "${DEVICE_ARCH_RAW}" == "armv7l" && "${USE_OFFICIAL_SOURCE}" != "true" ]]; then
echo "# deb [arch=arm64] ${WEB_PROTOCOL}://${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}/multiarch/ ${base_system_codename} ${repository_sections}" >>$File_DebianSourceList source_host="${SOURCE_BASE_SYSTEM:-"${SOURCE}"}/${SOURCE_BASE_SYSTEM_BRANCH:-"${base_system_branch}"}"
echo "# deb [arch=arm64] ${WEB_PROTOCOL}://${source_host}/multiarch/ ${base_system_codename} ${repository_sections}" >>$File_AptSourceList
fi fi
;; ;;
esac esac
@@ -2154,45 +2229,73 @@ function change_mirrors_RedHat() {
centos-addons.repo centos-addons.repo
;; ;;
*) *)
sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" CentOS-* sed -e "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
sed -i 's|^mirrorlist=|#mirrorlist=|g' CentOS-* -e "s|^mirrorlist=|#mirrorlist=|g" \
-i \
CentOS-*
case "${SYSTEM_VERSION_ID_MAJOR}" in case "${SYSTEM_VERSION_ID_MAJOR}" in
8) 8)
sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/centos-vault|g" CentOS-* sed -e "s|mirror.centos.org/\$contentdir|mirror.centos.org/${SOURCE_BRANCH}|g" \
sed -i "s/\$releasever/8.5.2111/g" CentOS-* -e "s|\$releasever|8.5.2111|g" \
# 单独处理 CentOS-Linux-Sources.repo -i \
sed -i "s|vault.centos.org/\$contentdir|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"centos-vault"}|g" CentOS-Linux-Sources.repo CentOS-*
sed -e "s|vault.centos.org/\$contentdir|vault.centos.org/${SOURCE_VAULT_BRANCH:-centos-vault}|g" \
-i \
CentOS-Linux-Sources.repo
;; ;;
7) 7)
sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/${SOURCE_BRANCH}|g" CentOS-* sed -e "s|mirror.centos.org/centos|mirror.centos.org/${SOURCE_BRANCH}|g" \
sed -i "s/\$releasever/7/g" CentOS-* -e "s|\$releasever|7.9.2009|g" \
# 单独处理 CentOS-Sources.repo -i \
sed -i "s|vault.centos.org/centos|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"${SOURCE_BRANCH}"}|g" CentOS-Sources.repo CentOS-*
sed -e "s|vault.centos.org/centos|vault.centos.org/${SOURCE_VAULT_BRANCH:-centos-vault}|g" \
-i \
CentOS-Sources.repo
;; ;;
esac esac
sed -i "s|mirror.centos.org|${SOURCE}|g" CentOS-* sed -e "s|mirror.centos.org|${SOURCE}|g" \
-e "s|vault.centos.org|${SOURCE_VAULT:-"${SOURCE}"}|g" \
-i \
CentOS-*
;; ;;
esac esac
;; ;;
"${SYSTEM_CENTOS}") "${SYSTEM_CENTOS}")
sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" CentOS-* sed -e "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
sed -i 's|^mirrorlist=|#mirrorlist=|g' CentOS-* -e "s|^mirrorlist=|#mirrorlist=|g" \
## CentOS 7/8 操作系统版本结束了生命周期EOLLinux 社区已不再维护该操作系统版本 -i \
CentOS-*
if [[ "${DEVICE_ARCH_RAW}" == "x86_64" ]]; then
SOURCE_BRANCH="centos-vault"
else
SOURCE_BRANCH="centos-altarch"
fi
case "${SYSTEM_VERSION_ID_MAJOR}" in case "${SYSTEM_VERSION_ID_MAJOR}" in
8) 8)
# 最终版本为 8.5.2011,从 2022-02 开始切换至 centos-vault 仓库 # 最终版本为 8.5.20112022-02
sed -i "s|mirror.centos.org/\$contentdir|mirror.centos.org/${SOURCE_BRANCH:-"centos-vault"}|g" CentOS-* sed -e "s|mirror.centos.org/\$contentdir|mirror.centos.org/${SOURCE_BRANCH}|g" \
sed -i "s/\$releasever/8.5.2111/g" CentOS-* -e "s|\$releasever|8.5.2111|g" \
sed -i "s|vault.centos.org/\$contentdir|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"centos-vault"}|g" CentOS-Linux-Sources.repo # 单独处理 CentOS-Linux-Sources.repo -i \
CentOS-*
sed -e "s|vault.centos.org/\$contentdir|vault.centos.org/${SOURCE_VAULT_BRANCH:-centos-vault}|g" \
-i \
CentOS-Linux-Sources.repo
;; ;;
7) 7)
# 最终版本为 7.9.2009,从 2024-07 开始切换至 centos-vault 仓库 # 最终版本为 7.9.20092024-07
sed -i "s|mirror.centos.org/centos|mirror.centos.org/${SOURCE_BRANCH:-"centos-vault"}|g" CentOS-* sed -e "s|mirror.centos.org/centos|mirror.centos.org/${SOURCE_BRANCH}|g" \
sed -i "s/\$releasever/7.9.2009/g" CentOS-* -e "s|\$releasever|7.9.2009|g" \
sed -i "s|vault.centos.org/centos|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"centos-vault"}|g" CentOS-Sources.repo # 单独处理 CentOS-Sources.repo -i \
CentOS-*
sed -e "s|vault.centos.org/centos|vault.centos.org/${SOURCE_VAULT_BRANCH:-centos-vault}|g" \
-i \
CentOS-Sources.repo
;; ;;
esac esac
sed -i "s|mirror.centos.org|${SOURCE}|g" CentOS-* sed -e "s|mirror.centos.org|${SOURCE}|g" \
-e "s|vault.centos.org|${SOURCE_VAULT:-"${SOURCE}"}|g" \
-i \
CentOS-*
;; ;;
"${SYSTEM_CENTOS_STREAM}") "${SYSTEM_CENTOS_STREAM}")
case "${SYSTEM_VERSION_ID_MAJOR}" in case "${SYSTEM_VERSION_ID_MAJOR}" in
@@ -2240,7 +2343,7 @@ function change_mirrors_RedHat() {
9) 9)
sed -e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \ sed -e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
-e "s|^mirrorlist=|#mirrorlist=|g" \ -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|repo.almalinux.org/vault|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"almalinux-vault"}|g" \ -e "s|repo.almalinux.org/vault|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-almalinux-vault}|g" \
-e "s|repo.almalinux.org/almalinux|${SOURCE}/${SOURCE_BRANCH}|g" \ -e "s|repo.almalinux.org/almalinux|${SOURCE}/${SOURCE_BRANCH}|g" \
-i \ -i \
almalinux-* almalinux-*
@@ -2248,7 +2351,7 @@ function change_mirrors_RedHat() {
8) 8)
sed -e "s|^mirrorlist=|#mirrorlist=|g" \ sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \ -e "s|^# baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
-e "s|repo.almalinux.org/vault|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-"almalinux-vault"}|g" \ -e "s|repo.almalinux.org/vault|${SOURCE_VAULT:-"${SOURCE}"}/${SOURCE_VAULT_BRANCH:-almalinux-vault}|g" \
-e "s|repo.almalinux.org/almalinux|${SOURCE}/${SOURCE_BRANCH}|g" \ -e "s|repo.almalinux.org/almalinux|${SOURCE}/${SOURCE_BRANCH}|g" \
-i \ -i \
almalinux-ha.repo \ almalinux-ha.repo \
@@ -2312,14 +2415,27 @@ function change_mirrors_RedHat() {
change_mirrors_or_install_EPEL # EPEL 附加软件包 change_mirrors_or_install_EPEL # EPEL 附加软件包
} }
## 更换 OpenCloudOS 发行版软件源 ## 更换 openEuler 软件源
function change_mirrors_openEuler() {
## 生成 repo 源文件
gen_repo_files_openEuler
## 使用官方源
[[ "${USE_OFFICIAL_SOURCE}" == "true" ]] && return
## 修改源
cd $Dir_YumRepos
sed -e "s|^baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
-e "s|repo.openeuler.org|${SOURCE}/${SOURCE_BRANCH}|g" \
-i \
openEuler.repo
}
## 更换 OpenCloudOS 软件源
function change_mirrors_OpenCloudOS() { function change_mirrors_OpenCloudOS() {
## 生成 repo 源文件 ## 生成 repo 源文件
gen_repo_files_OpenCloudOS "${SYSTEM_VERSION_ID}" gen_repo_files_OpenCloudOS "${SYSTEM_VERSION_ID}"
## 使用官方源 ## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then [[ "${USE_OFFICIAL_SOURCE}" == "true" ]] && return
return
fi
## 修改源 ## 修改源
cd $Dir_YumRepos cd $Dir_YumRepos
@@ -2336,36 +2452,33 @@ function change_mirrors_OpenCloudOS() {
fi fi
} }
## 更换 openEuler 发行版软件源 ## 更换 openKylin 软件源
function change_mirrors_openEuler() { function change_mirrors_openKylin() {
## 生成 repo 源文件 function gen_deb_source() {
gen_repo_files_openEuler echo "deb ${WEB_PROTOCOL}://${1}/ ${2} ${3}
## 使用官方源 # deb-src ${WEB_PROTOCOL}://${1}/ ${2} ${3}
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then deb ${WEB_PROTOCOL}://${1}/ ${2}-security ${3}
sed -e "s|openEuler-version|openEuler-${version_name}|g" \ # deb-src ${WEB_PROTOCOL}://${1}/ ${2}-security ${3}
-i \ deb ${WEB_PROTOCOL}://${1}/ ${2}-updates ${3}
openEuler.repo # deb-src ${WEB_PROTOCOL}://${1}/ ${2}-updates ${3}"
return
fi
## 修改源
cd $Dir_YumRepos
local version_name="$(cat $File_LinuxRelease | grep -E "^VERSION=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g; s/[()]/ /g; s/ / /g; s/^ //g; s/ $//g; s/ /-/g; s/_/-/g")"
sed -e "s|^baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
-e "s|repo.openeuler.org|${SOURCE}/${SOURCE_BRANCH}|g" \
-e "s|openEuler-version|openEuler-${version_name}|g" \
-i \
openEuler.repo
} }
## 更换 Anolis OS 发行版软件 ## 使用官方
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
SOURCE="archive.build.openkylin.top"
fi
local repository_sections="main cross pty" # 仓库区域
local source_host="${SOURCE}/${SOURCE_BRANCH}"
echo "## 默认禁用源码镜像以提高速度,如需启用请自行取消注释
$(gen_deb_source "${source_host}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_AptSourceList
}
## 更换 Anolis OS 软件源
function change_mirrors_AnolisOS() { function change_mirrors_AnolisOS() {
## 生成 repo 源文件 ## 生成 repo 源文件
gen_repo_files_AnolisOS "${SYSTEM_VERSION_ID}" gen_repo_files_AnolisOS "${SYSTEM_VERSION_ID}"
## 使用官方源 ## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then [[ "${USE_OFFICIAL_SOURCE}" == "true" ]] && return
return
fi
## 修改源 ## 修改源
cd $Dir_YumRepos cd $Dir_YumRepos
@@ -2386,7 +2499,7 @@ function change_mirrors_AnolisOS() {
esac esac
} }
## 更换 openSUSE 发行版软件源 ## 更换 openSUSE 软件源
function change_mirrors_openSUSE() { function change_mirrors_openSUSE() {
## 生成 repo 源文件 ## 生成 repo 源文件
case "${SYSTEM_ID}" in case "${SYSTEM_ID}" in
@@ -2398,19 +2511,20 @@ function change_mirrors_openSUSE() {
;; ;;
esac esac
## 使用官方源 ## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then [[ "${USE_OFFICIAL_SOURCE}" == "true" ]] && return
return
fi
## 修改源 ## 修改源
cd $Dir_ZYppRepos cd $Dir_ZYppRepos
# 更换软件源 # 更换软件源
sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" repo-* sed -e "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" \
-i \
repo-*
case "${SYSTEM_ID}" in case "${SYSTEM_ID}" in
opensuse-leap) opensuse-leap)
case "${SYSTEM_VERSION_ID}" in case "${SYSTEM_VERSION_ID}" in
15.[0-2]) 15.[0-2])
sed -i "s|download.opensuse.org|${SOURCE}/${SOURCE_BRANCH}|g" \ sed -e "s|download.opensuse.org|${SOURCE}/${SOURCE_BRANCH}|g" \
-i \
repo-debug-non-oss.repo \ repo-debug-non-oss.repo \
repo-debug.repo \ repo-debug.repo \
repo-debug-update-non-oss.repo \ repo-debug-update-non-oss.repo \
@@ -2423,7 +2537,8 @@ function change_mirrors_openSUSE() {
repo-update.repo repo-update.repo
;; ;;
*) *)
sed -i "s|download.opensuse.org|${SOURCE}/${SOURCE_BRANCH}|g" \ sed -e "s|download.opensuse.org|${SOURCE}/${SOURCE_BRANCH}|g" \
-i \
repo-backports-debug-update.repo \ repo-backports-debug-update.repo \
repo-backports-update.repo \ repo-backports-update.repo \
repo-debug-non-oss.repo \ repo-debug-non-oss.repo \
@@ -2442,7 +2557,8 @@ function change_mirrors_openSUSE() {
esac esac
;; ;;
opensuse-tumbleweed) opensuse-tumbleweed)
sed -i "s|download.opensuse.org|${SOURCE}/${SOURCE_BRANCH}|g" \ sed -e "s|download.opensuse.org|${SOURCE}/${SOURCE_BRANCH}|g" \
-i \
repo-debug.repo \ repo-debug.repo \
repo-non-oss.repo \ repo-non-oss.repo \
repo-openh264.repo \ repo-openh264.repo \
@@ -2453,7 +2569,7 @@ function change_mirrors_openSUSE() {
esac esac
} }
## 更换 Arch Linux 发行版软件源 ## 更换 Arch Linux 软件源
function change_mirrors_ArchLinux() { function change_mirrors_ArchLinux() {
## 使用官方源 ## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
@@ -2474,7 +2590,7 @@ function change_mirrors_ArchLinux() {
esac esac
} }
## 更换 Alpine Linux 发行版软件源 ## 更换 Alpine Linux 软件源
function change_mirrors_Alpine() { function change_mirrors_Alpine() {
## 使用官方源 ## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
@@ -2492,13 +2608,15 @@ function change_mirrors_Alpine() {
${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}/${version_name}/community" >>$File_AlpineRepositories ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}/${version_name}/community" >>$File_AlpineRepositories
} }
## 更换 Gentoo 发行版软件源 ## 更换 Gentoo 软件源
function change_mirrors_Gentoo() { function change_mirrors_Gentoo() {
## 使用官方源 ## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
grep -Eq "^GENTOO_MIRRORS=" $File_GentooMakeConf grep -Eq "^GENTOO_MIRRORS=" $File_GentooMakeConf
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sed -i "/^GENTOO_MIRRORS=/d" $File_GentooMakeConf sed -e "/^GENTOO_MIRRORS=/d" \
-i \
$File_GentooMakeConf
fi fi
[ -f "${File_GentooReposConf}" ] && rm -rf $File_GentooReposConf [ -f "${File_GentooReposConf}" ] && rm -rf $File_GentooReposConf
return return
@@ -2506,7 +2624,9 @@ function change_mirrors_Gentoo() {
## 修改源 ## 修改源
grep -Eq "^GENTOO_MIRRORS=" $File_GentooMakeConf grep -Eq "^GENTOO_MIRRORS=" $File_GentooMakeConf
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sed -i "s|^GENTOO_MIRRORS=.*|GENTOO_MIRRORS=\"${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}\"|g" $File_GentooMakeConf sed -e "s|^GENTOO_MIRRORS=.*|GENTOO_MIRRORS=\"${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}\"|g" \
-i \
$File_GentooMakeConf
else else
echo -e "\nGENTOO_MIRRORS=\"${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}\"" >>$File_GentooMakeConf echo -e "\nGENTOO_MIRRORS=\"${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}\"" >>$File_GentooMakeConf
fi fi
@@ -2516,33 +2636,11 @@ main-repo = gentoo
[gentoo] [gentoo]
location = /usr/portage location = /usr/portage
sync-type = rsync sync-type = rsync
sync-uri = rsync://${SOURCE_PORTAGE:-"${SOURCE}"}/${SOURCE_PORTAGE_BRANCH:-"gentoo-portage"} sync-uri = rsync://${SOURCE_PORTAGE:-"${SOURCE}"}/${SOURCE_PORTAGE_BRANCH:-gentoo-portage}
auto-sync = yes" >$File_GentooReposConf auto-sync = yes" >$File_GentooReposConf
} }
## 更换 openKylin 发行版软件源 ## 更换 NixOS 软件源
function change_mirrors_openKylin() {
function gen_source() {
echo "deb ${1} ${2} ${3}
# deb-src ${1} ${2} ${3}
deb ${1} ${2}-security ${3}
# deb-src ${1} ${2}-security ${3}
deb ${1} ${2}-updates ${3}
# deb-src ${1} ${2}-updates ${3}"
}
## 使用官方源
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
SOURCE="archive.build.openkylin.top"
fi
local repository_sections="main cross pty" # 仓库区域
local tips="## 默认禁用源码镜像以提高速度,如需启用请自行取消注释"
local base_url="${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}/"
echo "${tips}
$(gen_source "${base_url}" "${SYSTEM_VERSION_CODENAME}" "${repository_sections}")" >>$File_DebianSourceList
}
## 更换 NixOS 发行版软件源
function change_mirrors_NixOS() { function change_mirrors_NixOS() {
local binary_cache_source channel_source local binary_cache_source channel_source
if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then if [[ "${USE_OFFICIAL_SOURCE}" == "true" ]]; then
@@ -2553,7 +2651,9 @@ function change_mirrors_NixOS() {
channel_source="${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}" channel_source="${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}"
fi fi
# binary cache # binary cache
sed -i "s|^substituters.*|substituters = ${binary_cache_source}|g" $File_NixConf sed -e "s|^substituters.*|substituters = ${binary_cache_source}|g" \
-i \
$File_NixConf
# channel # channel
nix-channel --add "${channel_source}/nixos-${SYSTEM_VERSION_ID}" nixos nix-channel --add "${channel_source}/nixos-${SYSTEM_VERSION_ID}" nixos
nix-channel --update >/dev/null 2>&1 nix-channel --update >/dev/null 2>&1
@@ -2582,7 +2682,7 @@ function change_mirrors_or_install_EPEL() {
if [[ "${epel_version}" == "7" ]]; then if [[ "${epel_version}" == "7" ]]; then
[ -z "${SOURCE_EPEL_BRANCH}" ] && SOURCE_EPEL_BRANCH="epel-archive" [ -z "${SOURCE_EPEL_BRANCH}" ] && SOURCE_EPEL_BRANCH="epel-archive"
[[ "${PURE_MODE}" != "true" ]] && echo -e "\n$WARN Extra Packages for Enterprise Linux 7 已结束生命周期并被官方移至归档库!" [[ "${PURE_MODE}" != "true" ]] && echo -e "\n$WARN Extra Packages for Enterprise Linux 7 已结束生命周期并被官方移至归档库!"
[[ "${PURE_MODE}" != "true" ]] && echo -e "\n$TIP 目前部分镜像站没有同步该归档仓库,若换源后出现错误那么请先检查目标镜像站是否支持该仓库。\n\n${GREEN}${PLAIN} ${WEB_PROTOCOL}://${SOURCE_EPEL:-"${SOURCE}"}/${SOURCE_EPEL_BRANCH:-"epel"}" [[ "${PURE_MODE}" != "true" ]] && echo -e "\n$TIP 目前部分镜像站没有同步该归档仓库,若换源后出现错误那么请先检查目标镜像站是否支持该仓库。\n\n${GREEN}${PLAIN} ${WEB_PROTOCOL}://${SOURCE_EPEL:-"${SOURCE}"}/${SOURCE_EPEL_BRANCH:-epel}"
fi fi
## 安装 EPEL 软件包 ## 安装 EPEL 软件包
if [ $VERIFICATION_EPEL -ne 0 ]; then if [ $VERIFICATION_EPEL -ne 0 ]; then
@@ -2631,7 +2731,7 @@ function change_mirrors_or_install_EPEL() {
## 修改源 ## 修改源
sed -e "s|^#baseurl=http\(s\)\?|baseurl=${WEB_PROTOCOL}|g" \ sed -e "s|^#baseurl=http\(s\)\?|baseurl=${WEB_PROTOCOL}|g" \
-e "s|^metalink=|#metalink=|g" \ -e "s|^metalink=|#metalink=|g" \
-e "s|download.example/pub/epel|${SOURCE_EPEL:-"${SOURCE}"}/${SOURCE_EPEL_BRANCH:-"epel"}|g" \ -e "s|download.example/pub/epel|${SOURCE_EPEL:-"${SOURCE}"}/${SOURCE_EPEL_BRANCH:-epel}|g" \
-i \ -i \
$Dir_YumRepos/epel* $Dir_YumRepos/epel*
## 启用所需的仓库EPEL 需要结合 PowerTools / CRB 使用) ## 启用所需的仓库EPEL 需要结合 PowerTools / CRB 使用)
@@ -5388,6 +5488,11 @@ enabled=1
gpgcheck=1 gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-version/source/RPM-GPG-KEY-openEuler gpgkey=http://repo.openeuler.org/openEuler-version/source/RPM-GPG-KEY-openEuler
EOF EOF
## 替换版本号
local version_name="$(cat $File_LinuxRelease | grep -E "^VERSION=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g; s/[()]/ /g; s/ / /g; s/^ //g; s/ $//g; s/ /-/g; s/_/-/g")"
sed -e "s|openEuler-version|openEuler-${version_name}|g" \
-i \
$Dir_YumRepos/openEuler.repo
} }
## 生成 OpenCloudOS repo 源文件 ## 生成 OpenCloudOS repo 源文件

View File

@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
## Author: SuperManito ## Author: SuperManito
## Modified: 2025-05-12 ## Modified: 2025-05-13
## License: MIT ## License: MIT
## GitHub: https://github.com/SuperManito/LinuxMirrors ## GitHub: https://github.com/SuperManito/LinuxMirrors
## Website: https://linuxmirrors.cn ## Website: https://linuxmirrors.cn
@@ -100,8 +100,8 @@ File_AlpineRelease=/etc/alpine-release
File_ProxmoxVersion=/etc/pve/.version File_ProxmoxVersion=/etc/pve/.version
## 定义软件源相关文件或目录 ## 定义软件源相关文件或目录
File_DebianSourceList=/etc/apt/sources.list File_AptSourceList=/etc/apt/sources.list
Dir_DebianExtendSource=/etc/apt/sources.list.d Dir_AptAdditionalSources=/etc/apt/sources.list.d
Dir_YumRepos=/etc/yum.repos.d Dir_YumRepos=/etc/yum.repos.d
## 定义 Docker 相关变量 ## 定义 Docker 相关变量
@@ -112,7 +112,7 @@ DockerVersionFile=docker-version.txt
DockerCEVersionFile=docker-ce-version.txt DockerCEVersionFile=docker-ce-version.txt
DockerCECLIVersionFile=docker-ce-cli-version.txt DockerCECLIVersionFile=docker-ce-cli-version.txt
## 定义颜色变量 ## 定义颜色和样式变量
RED='\033[31m' RED='\033[31m'
GREEN='\033[32m' GREEN='\033[32m'
YELLOW='\033[33m' YELLOW='\033[33m'
@@ -751,8 +751,8 @@ function install_dependency_packages() {
## 删除原有源 ## 删除原有源
case "${SYSTEM_FACTIONS}" in case "${SYSTEM_FACTIONS}" in
"${SYSTEM_DEBIAN}") "${SYSTEM_DEBIAN}")
sed -i '/docker-ce/d' $File_DebianSourceList sed -i '/docker-ce/d' $File_AptSourceList
rm -rf $Dir_DebianExtendSource/docker.list rm -rf $Dir_AptAdditionalSources/docker.list
;; ;;
"${SYSTEM_REDHAT}" | "${SYSTEM_OPENEULER}" | "${SYSTEM_OPENCLOUDOS}" | "${SYSTEM_ANOLISOS}") "${SYSTEM_REDHAT}" | "${SYSTEM_OPENEULER}" | "${SYSTEM_OPENCLOUDOS}" | "${SYSTEM_ANOLISOS}")
rm -rf $Dir_YumRepos/*docker*.repo rm -rf $Dir_YumRepos/*docker*.repo
@@ -843,7 +843,7 @@ function configure_docker_ce_mirror() {
fi fi
chmod a+r $file_keyring chmod a+r $file_keyring
## 添加源 ## 添加源
echo "deb [arch=$(dpkg --print-architecture) signed-by=${file_keyring}] ${WEB_PROTOCOL}://${SOURCE}/linux/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME} stable" | tee $Dir_DebianExtendSource/docker.list >/dev/null 2>&1 echo "deb [arch=$(dpkg --print-architecture) signed-by=${file_keyring}] ${WEB_PROTOCOL}://${SOURCE}/linux/${SOURCE_BRANCH} ${SYSTEM_VERSION_CODENAME} stable" | tee $Dir_AptAdditionalSources/docker.list >/dev/null 2>&1
commands+=("apt-get update") commands+=("apt-get update")
;; ;;
"${SYSTEM_REDHAT}" | "${SYSTEM_OPENEULER}" | "${SYSTEM_OPENCLOUDOS}" | "${SYSTEM_ANOLISOS}") "${SYSTEM_REDHAT}" | "${SYSTEM_OPENEULER}" | "${SYSTEM_OPENCLOUDOS}" | "${SYSTEM_ANOLISOS}")
@@ -1258,7 +1258,7 @@ function check_installed_result() {
echo -e "\n$ERROR 安装失败" echo -e "\n$ERROR 安装失败"
case "${SYSTEM_FACTIONS}" in case "${SYSTEM_FACTIONS}" in
"${SYSTEM_DEBIAN}") "${SYSTEM_DEBIAN}")
echo -e "\n检查源文件cat $Dir_DebianExtendSource/docker.list" echo -e "\n检查源文件cat $Dir_AptAdditionalSources/docker.list"
echo -e '请尝试手动执行安装命令apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin\n' echo -e '请尝试手动执行安装命令apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin\n'
;; ;;
"${SYSTEM_REDHAT}" | "${SYSTEM_OPENEULER}" | "${SYSTEM_OPENCLOUDOS}" | "${SYSTEM_ANOLISOS}") "${SYSTEM_REDHAT}" | "${SYSTEM_OPENEULER}" | "${SYSTEM_OPENCLOUDOS}" | "${SYSTEM_ANOLISOS}")