CentOS 7.9 升級 GCC 4.8.5 到 8.3.1

gentsir發表於2024-12-10
mkdir /etc/yum.repos.d.bak
mv /etc/yum.repos.d/* /etc/yum.repos.d.bak
rm -f /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-7-anon.repo

cp /etc/yum.repos.d.bak/CentOS-SCLo-scl.repo /etc/yum.repos.d/
cp /etc/yum.repos.d.bak/CentOS-SCLo-scl-rh.repo /etc/yum.repos.d/

vim /etc/yum.repos.d/CentOS-SCLo-scl.repo
```
# 修改檔案中第一個baseurl為
# baseurl=https://mirrors.huaweicloud.com/centos/$releasever/sclo/$basearch/sclo/
# 並註釋 mirrorlist 行
```

vim /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
```
# 修改檔案中第一個baseurl為
# baseurl=https://mirrors.huaweicloud.com/centos/$releasever/sclo/$basearch/rh/
# 並註釋 mirrorlist 行
```

yum clean all
yum makecache fast

yum -y install centos-release-scl
yum-config-manager --enable rhel-server-rhscl-7-rpms
```
-bash: yum-config-manager: command not found
```

yum -y install yum-utils

yum-config-manager --enable rhel-server-rhscl-7-rpms
```
File "/usr/bin/yum-config-manager", line 135
  except yum.Errors.RepoError, e:
         ^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized
```

vim /usr/bin/yum-config-manager
```
# 因升級到 python3 後導致的錯誤
# 修改檔案第一行 #!/usr/bin/python -tt
# 為 #!/usr/bin/python2.7 -tt
# 再次執行 yum-config-manager --enable rhel-server-rhscl-7-rpms
```

yum -y install devtoolset-8
scl enable devtoolset-8 bash

相關文章