linux 重装yum centos7 更新了python无法使用yum问题

2022-03-06 22:46:10 浏览数 (1)

代码语言:java复制
#!/bin/bash

# centos7 重装yum

catlogdata="/eisc/yum"

mkdir -p $catlogdata ; rm -rf $catlogdata/*;     # 创建下载目录,并清空目录

curldown="http://mirrors.163.com/centos/7/os/x86_64/Packages"

                                                 # 定义下载连接变量

rpm -aq|grep yum|xargs rpm -e --nodeps           # 卸载yum

wgetrun(){

curl $curldown/wget-1.14-18.el7_6.1.x86_64.rpm > wget.rpm

rpm -ivh wget.rpm

}; wgetrun                                       # 解决wget 问题

rpmb=(

"python-iniparse-0.4-9.el7.noarch.rpm "

"python-pycurl-7.19.0-19.el7.x86_64.rpm"

"python-2.7.5-89.el7.x86_64.rpm" 

"python-urlgrabber-3.10-10.el7.noarch.rpm"

"python-libs-2.7.5-89.el7.x86_64.rpm" 

"yum-metadata-parser-1.1.4-10.el7.x86_64.rpm" 

"yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm"

"yum-3.4.3-168.el7.centos.noarch.rpm"

);                                              # 定义数组变量要下载的包

for i in ${rpmb[*]}

    do

        wget $curldown/$i -O $catlogdata/$i

        echo "下载文件:$curldown/$i 到: $catlogdata/$i"

    done

rpm -ivh $catlogdata/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

rpm -ivh $catlogdata/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm

rpm -ivh $catlogdata/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm $catlogdata/yum-3.4.3-168.el7.centos.noarch.rpm

                                               # 两个包要一起安装相互依赖

                                               # centos7 重装yum:https://www.cnblogs.com/DiZhang/p/12544744.html

wget eisc.cn/file/shell/centos-yum.sh ; sh centos-yum.sh

                                               # centos 切换yum 源                                               

yum install yum-utils -y                       # 解决:发现 XX 个已存在的 RPM 数据库问题 

0 人点赞