軟件集Software Collections


一、SCL

1、SCL是什麼

SCL項目主頁:https://www.softwarecollections.org/

  SCL(Software Collections)可以讓你在同一個操作系統上安裝和使用多個版本的軟件,而不會影響整個系統的安裝包。

SCL爲社區的以下需求而設計:

    創建和使用軟件集合生產系統、概念驗證系統、開發測試平臺。SCL目前已經支持Fedora和RHEL(衍生版本如CentOS也包含在內)。

    SCL的創建就是爲了給RHEL/CentOS用戶提供一種以方便、安全地安裝和使用應用程序和運行時環境的多個(而且可能是更新的)版本的方式,同時避免把系統搞亂。與之相對的是第三方源,它們可能會在已安裝的包之間引起衝突。


現有軟件選集:

現在有以下軟件選集可供CentOS 6.5或以上版本應用

Ruby 1.9.3 (ruby193)
Python 2.7 (python27)
Python 3.3 (python33)
PHP 5.4 (php54)
Perl 5.16.3 (perl516)
Node.js 0.10 (nodejs010)
MariaDB 5.5 (mariadb55)
MySQL 5.5 (mysql55)
PostgreSQL 9.2 (postgresql92)

更多的軟件集可參看這裏:https://www.softwarecollections.org/en/scls/


2、安裝SCL

    在CentOS下使用 SCL,需要安裝CentOS Software Collections。它是CentOS Extras軟件庫的一部份,並可通過以下指命進行安裝

Centos 7:

[root@Node3 ~]# yum install centos-release-scl

Dependencies Resolved

===================================================================================================================================
 Package                                Arch                    Version                              Repository               Size
===================================================================================================================================
Installing:
 centos-release-scl                     noarch                  10:7-3.el6.centos                    extras                   12 k
Installing for dependencies:
 centos-release-scl-rh                  noarch                  2-3.el6.centos                       extras                   12 k

Transaction Summary
===================================================================================================================================
Install       2 Package(s)


[root@Node3 yum.repos.d]# rpm -ql centos-release-scl
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
/etc/yum.repos.d/CentOS-SCLo-scl.repo
/usr/share/doc/centos-release-scl/GPL


Centos 6:

[root@Python ~]# yum install centos-release-SCL

Dependencies Resolved

============================================================================================================================================================================================
 Package                                               Arch                                   Version                                          Repository                              Size
============================================================================================================================================================================================
Installing:
 centos-release-scl-rh                                 noarch                                 2-3.el6.centos                                   extras                                  12 k

Transaction Summary
============================================================================================================================================================================================
Install       1 Package(s)


[root@Python yum.repos.d]# rpm -ql centos-release-scl-rh
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
/etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
/usr/share/doc/centos-release-scl-rh/GPL


注意:Centos6和Centos7的包名是區分大小寫的!


二、SCL的設置及啓用

1、要啓用和運行SCL中的應用,你還需要安裝下列包:

[root@Python ~]# yum install scl-utils scl-utils-build


2、SCL的設置及啓用

SCL設置步驟非常簡單

[root@Python ~]# scl --help
usage: scl <action> [<collection>...] <command>
   or: scl -l|--list [<collection>...]
   or: scl register <path>
   or: scl deregister <collection> [--force]

Options:
    -l, --list            list installed Software Collections or packages
                          that belong to them
    -h, --help            display this help and exit

Actions:
    enable                calls enable script from Software Collection
                          (enables a Software Collection)
    <SCL script name>     calls arbitrary script from a Software Collection

Use '-' as <command> to read the command from standard input.

啓用一個已經安裝的SCL包

    需要在每個命令中使用scl命令顯式啓用它(即想在哪條命令中使用SCL中的包,就得通過scl命令執行該命令)

$ scl enable <scl-package-name> <command>

如果想在啓用的包時執行多條命令,你可以像下面那樣創建一個啓用SCL的bash會話

$ scl enable <scl-package-name> bash



三、SCL使用實例:CentOS下安裝高版本GCC

    有時編譯需要用到4.8以上版本的GCC,由於CentOS源沒有提供高版本的GCC rpm包,這時就不能通過yum方式安裝。通常的解決方案就是通過編譯安裝高版本的GCC(需要很長時間)。

這裏介紹一個更好用、更簡單的方法來升級系統GCC。


查看舊版本的GCC相關包:

[root@Python ~]# rpm -qa|grep gcc
libgcc-4.4.7-18.el6.x86_64
gcc-4.4.7-18.el6.x86_64
gcc-c++-4.4.7-18.el6.x86_64
gcc-gfortran-4.4.7-18.el6.x86_64


安裝GCC 5:

[root@Python ~]# yum list|grep devtoolset|grep gcc
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
devtoolset-3-gcc.x86_64                    4.9.2-6.2.el6          centos-sclo-rh
devtoolset-3-gcc-c++.x86_64                4.9.2-6.2.el6          centos-sclo-rh
devtoolset-3-gcc-gfortran.x86_64           4.9.2-6.2.el6          centos-sclo-rh
devtoolset-3-gcc-plugin-devel.x86_64       4.9.2-6.2.el6          centos-sclo-rh
devtoolset-4-gcc.x86_64                    5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-gcc-c++.x86_64                5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-gcc-gdb-plugin.x86_64         5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-gcc-gfortran.x86_64           5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-gcc-plugin-devel.x86_64       5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-libgccjit.x86_64              5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-libgccjit-devel.x86_64        5.3.1-6.1.el6          centos-sclo-rh
devtoolset-4-libgccjit-docs.x86_64         5.3.1-6.1.el6          centos-sclo-rh
devtoolset-6-gcc.x86_64                    6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-gcc-c++.x86_64                6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-gcc-gdb-plugin.x86_64         6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-gcc-gfortran.x86_64           6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-gcc-plugin-devel.x86_64       6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-libgccjit.x86_64              6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-libgccjit-devel.x86_64        6.2.1-3.1.el6          centos-sclo-rh
devtoolset-6-libgccjit-docs.x86_64         6.2.1-3.1.el6          centos-sclo-rh

   在centos6.5上安裝devtoolset-3會報錯,4和6的版本不會。

[root@Python ~]# yum install devtoolset-4-gcc devtoolset-4-gcc-c++ devtoolset-4-gcc-gfortran


安裝後:

[root@Python ~]# rpm -qa|grep gcc
devtoolset-4-gcc-5.3.1-6.1.el6.x86_64
libgcc-4.4.7-18.el6.x86_64
gcc-4.4.7-18.el6.x86_64
gcc-c++-4.4.7-18.el6.x86_64
devtoolset-4-gcc-c++-5.3.1-6.1.el6.x86_64
gcc-gfortran-4.4.7-18.el6.x86_64
devtoolset-4-gcc-gfortran-5.3.1-6.1.el6.x86_64


啓用高版本的GCC:

[root@Python ~]# gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# scl -l
devtoolset-4


啓用SCL的方法:

1) scl enable 軟件包名 bash   

     啓用一個新的shell

[root@Python ~]# scl enable devtoolset-4 bash  # 進入一個新shell

[root@Python ~]# gcc --version
gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# c++ --version
c++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# g++ --version
g++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


2 )source /opt/rh/devtoolset-4/enable 

      在當前shell中生效

[root@Python ~]# source /opt/rh/devtoolset-4/enable 
[root@Python ~]# gcc --version
gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# c++ --version
c++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@Python ~]# g++ --version
g++ (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


如果我們需要開機設置GCC 5:

[root@Python ~]# echo "source /opt/rh/devtoolset-4/enable" > /etc/profile.d/RK.sh


注意:

 通過devtoolset安裝的gcc因爲沒有libstdc++包,沒有生成libstdc++庫文件,編譯或運行程序時可能會遇到

  類似 /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found 的問題

[root@Python ~]# rpm -qa|grep libstdc++    # 沒有devtoolset-4-libstdc包
libstdc++-4.4.7-18.el6.x86_64
libstdc++-devel-4.4.7-18.el6.x86_64
devtoolset-4-libstdc++-devel-5.3.1-6.1.el6.x86_64

[root@Python ~]# rpm -ql devtoolset-4-libstdc++-devel|grep libstdc++.so
[root@Python ~]# rpm -ql libstdc++-devel|grep libstdc++.so
[root@Python ~]# rpm -ql libstdc++|grep libstdc++.so
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.13
[root@Python ~]# ls -l `rpm -ql libstdc++|grep libstdc++.so`
lrwxrwxrwx 1 root root     19 Jun  7 06:46 /usr/lib64/libstdc++.so.6 -> libstdc++.so.6.0.13
-rwxr-xr-x 1 root root 987096 Mar 21 12:04 /usr/lib64/libstdc++.so.6.0.13

[root@Python ~]# find / -name "libstdc++*"
/root/libstdc++-5.3.1-6.fc22.x86_64.rpm
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++_nonshared.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++.so
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++_nonshared.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++.so
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++fs.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++fs.a
/opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++.a
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.13
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyo
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyc
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyo
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyc
/usr/share/doc/libstdc++-devel-4.4.7
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libstdc++.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libstdc++.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libstdc++.a
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libstdc++.a
/usr/lib/vmware-tools/lib64/libstdc++.so.6
/usr/lib/vmware-tools/lib64/libstdc++.so.6/libstdc++.so.6
/usr/lib/vmware-tools/lib32/libstdc++.so.6
/usr/lib/vmware-tools/lib32/libstdc++.so.6/libstdc++.so.6


# devtoolset安裝的gcc還是調用老的libstdc++動態庫

[root@Python ~]# vim /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++.so
[root@Python ~]# vim /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++.so
[root@Python ~]# strings /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/32/libstdc++.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf32-i386)
INPUT ( /usr/lib/libstdc++.so.6 -lstdc++_nonshared )
[root@Python ~]# strings /opt/rh/devtoolset-4/root/usr/lib/gcc/x86_64-redhat-linux/5.3.1/libstdc++.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
INPUT ( /usr/lib64/libstdc++.so.6 -lstdc++_nonshared )


詳見:http://xiexiaojun.blog.51cto.com/2305291/1934746



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章