國內升級腳本:linux
#!/usr/bin/env bash # -*- coding: utf-8 -*- # # Authors: limanman # OsChina: http://my.oschina.net/pydevops/ # Purpose: # GCC_V='4.7.2' # sudo yum -y groupinstall "chinese-support" sudo yum -y install vim wget sudo yum -y groupinstall "Development Tools" sudo yum -y install glibc-static libstdc++-static cmake glibc.i686 glibc-devel wget http://ftp.gnu.org/gnu/gcc/gcc-${GCC_V}/gcc-${GCC_V}.tar.gz -O gcc-${GCC_V}.tar.gz tar xzf gcc-${GCC_V}.tar.gz cd gcc-${GCC_V} ./contrib/download_prerequisites cd .. mkdir build_gcc${GCC_V} cd build_gcc${GCC_V} sudo ../gcc-${GCC_V}/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib sudo make -j23 sudo make install cd .. rm -rf build_gcc${GCC_V} gcc-${GCC_V} gcc-${GCC_V}.tar.gz :<<EOF mkdir -p /xm-workspace/xm-back/ mv /usr/bin/gcc /xm-workspace/xm-back/gcc_org ln -s /usr/local/bin/x86_64-unknown-linux-gnu-gcc-4.7.2 /usr/bin/gcc rm -rf /usr/lib64/libstdc++.so.6 cp -rfp /usr/local/lib64/libstdc++.so.6.0.17 /usr/lib64/libstdc++.so.6.0.17 ln /usr/lib64/libstdc++.so.6.0.17 /usr/lib64/libstdc++.so.6 EOF
國外升級腳本:c++
#!/usr/bin/env bash # -*- coding: utf-8 -*- # # Authors: limanman # OsChina: http://my.oschina.net/pydevops/ # Purpose: # GCC_V='4.7.2' # sudo yum -y groupinstall "chinese-support" sudo yum -y install vim wget sudo yum -y groupinstall "Development Tools" sudo yum -y install glibc-static libstdc++-static cmake glibc.i686 glibc-devel wget http://ftp.gnu.org/gnu/gcc/gcc-${GCC_V}/gcc-${GCC_V}.tar.gz -O gcc-${GCC_V}.tar.gz tar xzf gcc-${GCC_V}.tar.gz cd gcc-${GCC_V} ./contrib/download_prerequisites cd .. mkdir build_gcc${GCC_V} cd build_gcc${GCC_V} sudo make distclean sudo ../gcc-${GCC_V}/configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --disable-bootstrap sudo make -j23 sudo make install cd .. rm -rf build_gcc${GCC_V} gcc-${GCC_V} gcc-${GCC_V}.tar.gz :<<EOF mkdir -p /xm-workspace/xm-back/ mv /usr/bin/gcc /xm-workspace/xm-back/gcc_org ln -s /usr/local/bin/x86_64-unknown-linux-gnu-gcc-4.7.2 /usr/bin/gcc rm -rf /usr/lib64/libstdc++.so.6 cp -rfp /usr/local/lib64/libstdc++.so.6.0.17 /usr/lib64/libstdc++.so.6.0.17 ln /usr/lib64/libstdc++.so.6.0.17 /usr/lib64/libstdc++.so.6 EOF
說明:由於線上需求,必須批量升級Centos6.5 GCC到4.7.X,以上腳本已通過測試,也許有些系統不兼容因此零時註釋:<<EOF ..... EOF, 可手動測試下在拿到線上跑,以避免形成沒必要要的麻煩.
shell