Docker中安装Centos6VCS的踩坑记录

===========================================================

感谢田佬的若干帮助,while (true) putchar('%');

  • 安装Centos6

  • 拉取Centos6镜像

  
  

- 使用下面命令拉取  
    
    
  ```shell
  docker pull centos:6
  
  ```
- 使用下面命令查看是否成功  
    
    
  ```shell
  docker images
  
  ```
- 如果拉取成功,结果如下(**IMAGE ID, CREATED, SIZE**可能不同)  
    
    
  ```shell
  REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
  centos       6         d0957ffdf8a2   2 years ago    194MB
  
  ```
  • 运行一个Centos6容器

  
  

- 使用下面的命令运行  
    
    
  ```shell
  docker run -it centos:6
  
  ```
- 出现下面的结果表明成功运行(**7fee4585addb**为容器**ID**,可能不同)  
    
    
  ```shell
  [root@7fee4585addb /]#
  
  ```
- 以这种方式运行容器时,**hostname**和**mac**地址是**不确定**的(本地运行两个容器,**hostname**和**mac**地址分别如下)  
    
    
  ```shell
  [root@7fee4585addb /]# hostname
  7fee4585addb
  [root@7fee4585addb /]# cat /sys/class/net/eth0/address
  02:42:ac:11:00:02
  
  ```
  
    
    
    
  ```shell
  [root@682672e6af90 /]# hostname
  682672e6af90
  [root@682672e6af90 /]# cat /sys/class/net/eth0/address
  02:42:ac:11:00:03
  
  ```
- 为事先指定**hostname**和**mac**地址,可以通过`--hostname`和`--mac-address`选项指定,下面的命令可以指定**hostname**为`Tadokoro`,**mac**地址为`02:42:AC:11:45:14`  
    
    
  ```shell
  docker run -it --hostname Tadokoro --mac-address 02:42:AC:11:45:14 centos:6
  
  ```
- 查看容器的**hostname**和**mac**地址,此时为指定的内容  
    
    
  ```shell
  [root@Tadokoro /]# hostname
  Tadokoro
  [root@Tadokoro /]# cat /sys/class/net/eth0/address
  02:42:ac:11:45:14
  
  ```
- 需要注意的是,**hostname**可以随便写,但**mac**地址不能太离谱,否则会出错  
    
    
  ```shell
  docker run -it --hostname WrongMac --mac-address 11:22:33:44:55:66 centos:6
  
  ```
  
    
    
    
  ```shell
  docker: Error response from daemon:
      OCI runtime create failed: container_linux.go:380:
      starting container process caused: process_linux.go:545:
      container init caused: Running hook #0:: error running hook:
      exit status 1, stdout: , stderr: time="2021-08-05T23:09:08+08:00" level=fatal
      msg="failed to add interface vethf040ecb to sandbox: error setting interface \"vethf040ecb\" MAC to \"11:22:33:44:55:66\": cannot assign requested address": unknown.
      ERRO[0000] error waiting for container: context canceled
  
  ```
  • Centos6容器换源

  
  

- 在**Centos6**中执行下面的命令  
    
    
  ```shell
  yum update
  
  ```
- 得到的结果如下  
    
    
  ```shell
  [root@Tadokoro /]# yum update
  Loaded plugins: fastestmirror, ovl
  Setting up Update Process
  YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
  Eg. Invalid release/repo/arch combination/
  removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
  Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
  
  ```
- 这是因为**Centos6**已经[停止维护](https://wiki.centos.org/About/Product),相当一部分源都炸了,还有很多存在版本维护问题  
  ![在Docker中安装Centos6与VCS的踩坑记录教程](https://www.icode9.com/i/l/?n=20&i=blog/2322553/202108/2322553-20210806121644385-1139958324.jpg)
- 下面是一个可以正常使用的源,来自[此博客](https://developer.aliyun.com/article/779734),感谢作者  
    
    
  ```url
  https://www.xmpan.com/Centos-6-Vault-Aliyun.repo
  
  ```
  
    
    
    
  ```repo
  # CentOS-Base.repo
  #
  # The mirror system uses the connecting IP address of the client and the
  # update status of each mirror to pick mirrors that are updated to and
  # geographically close to the client.  You should use this for CentOS updates
  # unless you are manually picking other mirrors.
  #
  # If the mirrorlist= does not work for you, as a fall back you can try the
  # remarked out baseurl= line instead.
  #
  #
  
  [base]
  name=CentOS-6.10 - Base - mirrors.aliyun.com
  failovermethod=priority
  baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
  gpgcheck=1
  gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
  
  #released updates
  [updates]
  name=CentOS-6.10 - Updates - mirrors.aliyun.com
  failovermethod=priority
  baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
  gpgcheck=1
  gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
  
  #additional packages that may be useful
  [extras]
  name=CentOS-6.10 - Extras - mirrors.aliyun.com
  failovermethod=priority
  baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
  gpgcheck=1
  gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
  
  #additional packages that extend functionality of existing packages
  [centosplus]
  name=CentOS-6.10 - Plus - mirrors.aliyun.com
  failovermethod=priority
  baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
  gpgcheck=1
  enabled=0
  gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
  
  #contrib - packages by Centos Users
  [contrib]
  name=CentOS-6.10 - Contrib - mirrors.aliyun.com
  failovermethod=priority
  baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
  gpgcheck=1
  enabled=0
  gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
  
  ```
- 接下来要做的就是用上文的内容覆盖`etc/yum.repos.d/CentOS-Base.repo`,下面是若干方法 
  - 最蠢的方法,清空CentOS-Base.repo后,使用**echo**命令逐行追加,笔者这么干了好久  
      
      
    ```shell
    echo > CentOS-Base.repo
    echo "# CentOS-Base.repo" >> CentOS-Base.repo
    echo "#" >> CentOS-Base.repo
    echo "# The mirror system uses the connecting IP address of the client and the" >> CentOS-Base.repo
    ......
    
    ```
  - 清空CentOS-Base.repo后,使用系统自带的**vi**编辑,笔者一度不知道有**vi**这东西  
      
      
    ```shell
    echo > CentOS-Base.repo
    vi CentOS-Base.repo
    
    ```
  - 本地准备好CentOS-Base.repo,拷贝进目标容器,覆盖旧CentOS-Base.repo  
      
      
    ```shell
    docker cp CentOS-Base.repo [容器ID]:/etc/yum.repos.d/
    
    ```
  - 直接**curl**地址,然后重定向给目标文件CentOS-Base.repo  
      
      
    ```shell
    curl https://www.xmpan.com/Centos-6-Vault-Aliyun.repo > CentOS-Base.repo
    
    ```
- 再次执行`yum update`,结果正确  
    
    
  ```shell
  Loaded plugins: fastestmirror, ovl
  Setting up Update Process
  Determining fastest mirrors
  base                                                                                                                                   | 3.7 kB     00:00
  base/primary_db                                                                                                                        | 4.7 MB     00:00
  extras                                                                                                                                 | 3.4 kB     00:00
  extras/primary_db                                                                                                                      |  29 kB     00:00
  updates                                                                                                                                | 3.4 kB     00:00
  updates/primary_db                                                                                                                     |  12 MB     00:01
  Resolving Dependencies
  --> Running transaction check
  ---> Package bind-libs.x86_64 32:9.8.2-0.68.rc1.el6_10.1 will be updated
  ---> Package bind-libs.x86_64 32:9.8.2-0.68.rc1.el6_10.8 will be an update
  ---> Package bind-utils.x86_64 32:9.8.2-0.68.rc1.el6_10.1 will be updated
  ---> Package bind-utils.x86_64 32:9.8.2-0.68.rc1.el6_10.8 will be an update
  ---> Package binutils.x86_64 0:2.20.51.0.2-5.48.el6 will be updated
  ---> Package binutils.x86_64 0:2.20.51.0.2-5.48.el6_10.1 will be an update
  ---> Package ca-certificates.noarch 0:2018.2.22-65.1.el6 will be updated
  ---> Package ca-certificates.noarch 0:2020.2.41-65.1.el6_10 will be an update
  ---> Package curl.x86_64 0:7.19.7-53.el6_9 will be updated
  ---> Package curl.x86_64 0:7.19.7-54.el6_10 will be an update
  ---> Package dbus-libs.x86_64 1:1.2.24-9.el6 will be updated
  ......
  
  ```
  • 安装必须的包

  
  

- 执行`yum install gcc`
  - 在使用**VCS**编译时,需要用到
  - 在给**snpslmd**打补丁的时候,需要用到
- 执行`yum install gcc-c++`
  - 在使用**VCS**编译时,需要用到
- 执行`yum install redhat-lsb`
  - 在使用**lmgrd**时,需要用到
  • 安装与激活VCS

  • 准备VCS安装包

  
  

- 安装包文件树如下,其中**scl\_v2018.06\_windows.exe**和**scl\_keygen.zip**无需拷贝进**Docker**  
    
    
  ```shell
  .
  ├── scl
  │   ├── scl_v2018.06_common.spf
  │   ├── scl_v2018.06_linux64.spf
  │   └── scl_v2018.06_windows.exe
  ├── scl_keygen.zip
  ├── synopsyinstaller
  │   ├── checksum_info.txt
  │   ├── installer_INSTALL_README.txt
  │   ├── snps_container_INSTALL_README.txt
  │   ├── snps_container_v1.0_common.spf
  │   └── SynopsysInstaller_v5.0.run
  ├── vcs
  │   ├── checksum_info.txt
  │   ├── vcs_INSTALL_README.txt
  │   ├── vcs_vO-2018.09-SP2_common.spf
  │   └── vcs_vO-2018.09-SP2_linux64.spf
  └── verdi
      ├── verdi_vVerdi_O-2018.09-SP2_common.spf
      └── verdi_vVerdi_O-2018.09-SP2_linux64.spf
  
  ```
- 计划安装目录为`/home/synopsys`,方便起见,将上述文件也置于**home**下,**Docker**内文件树如下  
    
    
  ```shell
  [root@Tadokoro home]# tree
  .
  ├── scl
  │   ├── scl_v2018.06_common.spf
  │   └── scl_v2018.06_linux64.spf
  ├── synopsyinstaller
  │   ├── checksum_info.txt
  │   ├── installer_INSTALL_README.txt
  │   ├── snps_container_INSTALL_README.txt
  │   ├── snps_container_v1.0_common.spf
  │   └── SynopsysInstaller_v5.0.run
  ├── synopsys
  ├── vcs
  │   ├── checksum_info.txt
  │   ├── vcs_INSTALL_README.txt
  │   ├── vcs_vO-2018.09-SP2_common.spf
  │   └── vcs_vO-2018.09-SP2_linux64.spf
  └── verdi
      ├── verdi_vVerdi_O-2018.09-SP2_common.spf
      └── verdi_vVerdi_O-2018.09-SP2_linux64.spf
  
  5 directories, 13 files
  
  ```
  • 安装SynopsysInstaller

  
  

- 在`/home/synopsysInstaller`中,为**SynopsysInstaller\_v5.0.run**添加权限  
    
    
  ```shell
  [root@Tadokoro home]# cd synopsyinstaller/
  [root@Tadokoro synopsyinstaller]# ls
  checksum_info.txt  installer_INSTALL_README.txt  snps_container_INSTALL_README.txt  snps_container_v1.0_common.spf  SynopsysInstaller_v5.0.run
  [root@Tadokoro synopsyinstaller]# chmod 777 SynopsysInstaller_v5.0.run
  
  ```
- 执行`SynopsysInstaller_v5.0.run`,地址填写`/home/synopsys`  
    
    
  ```shell
  [root@Tadokoro synopsyinstaller]# ./SynopsysInstaller_v5.0.run
  
  #******************************************************************
  #
  #    Synopsys Installer Self-Extracting Executable
  #
  #    This script extracts and installs Synopsys Installer 5.0 into
  #    the given directory
  #
  #    For help type:
  #
  #       SynopsysInstaller_v5.0.run -help
  #
  #******************************************************************
  
  Please specify installation directory [.]: /home/synopsys
  Installing Synopsys Installer 5.0 into the directory '/home/synopsys'...
  
  Unpacking: SynopsysInstaller.tgz ...
  Unpacking: singularity.tar.gz ...
  
  Installation complete.
  
  ```
  • 安装SCL, VCS, Verdi

  
  

- 在`/home/synopsys`中,执行**installer**,发现在**root**模式下使用`-install_as_root`选项也无法正常启动  
    
    
  ```
  [root@Tadokoro home]# cd synopsys
  [root@Tadokoro synopsys]# ls
  batch_installer  container  container_setup.sh  doc  install_bin  installer  setup.sh
  [root@Tadokoro synopsys]# ./installer
  
  WARNING: The Installer must not be run from a root user account.
          Instead, Installer must be run from a regular user account.
          Installing tools from a root account is not supported; in
          certain cases this may cause a tool to fail to run properly
          for some or all users
  
  To run installer as root [not recommended];, please re-invoke
  installer with the -install_as_root switch.
  
  [root@Tadokoro synopsys]# ./installer -install_as_root
  invalid command name "id"
      while executing
  "id -un"
      (procedure "getUserName" line 5)
      invoked from within
  "getUserName"
      (procedure "SI_CORE::init" line 23)
      invoked from within
  "SI_CORE::init"
      (procedure "SI_CONFIG::init" line 2)
      invoked from within
  "SI_CONFIG::init"
      (procedure "SI_INSTALL::init" line 2)
      invoked from within
  "SI_INSTALL::init"
      (file "/home/synopsys/install_bin/pinstaller.tcl" line 9)
  
  ```
- 为此,需要创建一个用户并切换到此用户  
    
    
  ```shell
  [root@Tadokoro synopsyinstaller]# useradd usr
  [root@Tadokoro synopsys]# su usr
  [usr@Tadokoro synopsys]$ ls
  batch_installer  container  container_setup.sh  doc  install_bin  installer  setup.sh
  
  ```
- 在此用户下执行**installer**,安装**SCL**,发现权限不足  
    
    
  ```shell
  [usr@Tadokoro synopsys]$ ./installer
  
          Synopsys (R) Installer
              Version 5.0.0
  
  Copyright (c) 2005 - 2021 Synopsys, Inc.
  This software and the associated documentation are proprietary to Synopsys, Inc.
  This software may only be used in accordance with the terms and conditions of a
  written license agreement with Synopsys, Inc. All other use, reproduction, or
  distribution of this software is strictly prohibited.
  
  Enter the path to the source directory containing the downloaded EFT file(s) [/home/synopsys]: /home/scl
  
  Enter the full path to the directory where you want to
  install Synopsys products. If the directory does not exist,
  it will be created. [/usr/synopsys]: /home/synopsys
  ERROR: Can't install product to destination /home/synopsys.
      Destination directory is not writable.
      use -target <target dir> to specify a different target directory
  
  ```
- 切换到**root**用户,为**synopsys**文件夹添加权限  
    
    
  ```shell
  [usr@Tadokoro synopsys]$ exit
  exit
  [root@Tadokoro synopsys]# cd ../
  [root@Tadokoro home]# chmod 777 synopsys
  [root@Tadokoro home]# cd synopsys
  [root@Tadokoro synopsys]# su usr
  
  ```
- 执行**installer**,安装**SCL**,**Site ID number**无关紧要  
    
    
  ```shell
  [usr@Tadokoro synopsys]$ ./installer
  
          Synopsys (R) Installer
              Version 5.0.0
  
  Copyright (c) 2005 - 2021 Synopsys, Inc.
  This software and the associated documentation are proprietary to Synopsys, Inc.
  This software may only be used in accordance with the terms and conditions of a
  written license agreement with Synopsys, Inc. All other use, reproduction, or
  distribution of this software is strictly prohibited.
  
  Enter the path to the source directory containing the downloaded EFT file(s) [/home/synopsys]: /home/scl
  
  Enter the full path to the directory where you want to
  install Synopsys products. If the directory does not exist,
  it will be created. [/usr/synopsys]: /home/synopsys
  Extracting release information from scl_v2018.06_linux64.spf
  Extracting release information from scl_v2018.06_linux64.spf successfully
  Extracting release information from scl_v2018.06_common.spf
  Extracting release information from scl_v2018.06_common.spf successfully
  
  Your site ID number is in the upper-right corner of your Synopsys license
  key certificate. If you have trouble locating it, contact your Synopsys
  representative.
  
  Site ID number [000]: 27000
  #####################################################
  ############### Installation Summary ################
  Product:    SCL (Synopsys Common Licensing) (scl)
  Release:    2018.06
  Platforms:   linux64 common
  Disk Space: 103 MB
  Target Dir: /home/synopsys/scl/2018.06
  
  Licensed Products communicate with Synopsys servers for the purpose of providing software updates,
  detecting software piracy and verifying that customers are using Licensed Products in conformity with
  the applicable License Key for such Licensed Products. Synopsys will use information gathered in
  connection with this process to deliver software updates and pursue software pirates and infringers.
  #####################################################
  If the information is correct, continue with the installation.
  Accept, Install? [yes]: yes
  INFO: Prepare for installing 2018.06 release of product scl ...
  INFO: Extracting linux64 package from scl_v2018.06_linux64.spf ...
  INFO: Extracting common package from scl_v2018.06_common.spf ...
  INFO: Verify SHA256 sum for scl.taz ....
  INFO: Verify SHA256 sum for linux64/scl.taz ....
  INFO: Installing 2018.06 release of product scl to /home/synopsys/scl/2018.06 ....
  INFO: Installing common package for 2018.06 release of product scl ...
  INFO: Installing linux64 package for 2018.06 release of product scl ...
  INFO: Installation for 2018.06 release of product scl has finished successfully.
  
  
  Synopsys tools require that a supported version of Synopsys Common
  Licensing (SCL) be installed and serving the necessary licenses.
  For information on how to obtain SCL, or your license key file,
  see http://www.synopsys.com/licensing
  
  For any postinstallation setup requirements, see the product-specific
  chapters in the Installation Guide at http://www.synopsys.com/install
  
  INFO: See installer log file /home/synopsys/installer.log
  
  ```
- 执行**installer**,安装**VCS**,**Site ID number**同样无关紧要  
    
    
  ```shell
  [usr@Tadokoro synopsys]$ ./installer
  
          Synopsys (R) Installer
              Version 5.0.0
  
  Copyright (c) 2005 - 2021 Synopsys, Inc.
  This software and the associated documentation are proprietary to Synopsys, Inc.
  This software may only be used in accordance with the terms and conditions of a
  written license agreement with Synopsys, Inc. All other use, reproduction, or
  distribution of this software is strictly prohibited.
  
  Enter the path to the source directory containing the downloaded EFT file(s) [/home/synopsys]: /home/vcs
  
  Enter the full path to the directory where you want to
  install Synopsys products. If the directory does not exist,
  it will be created. [/usr/synopsys]: /home/synopsys
  Extracting release information from vcs_vO-2018.09-SP2_linux64.spf
  Extracting release information from vcs_vO-2018.09-SP2_linux64.spf successfully
  Extracting release information from vcs_vO-2018.09-SP2_common.spf
  Extracting release information from vcs_vO-2018.09-SP2_common.spf successfully
  
  Your site ID number is in the upper-right corner of your Synopsys license
  key certificate. If you have trouble locating it, contact your Synopsys
  representative.
  
  Site ID number [000]: 27000
  
  Post installation setup for VCS - The high-performance, high-capacity Verilog® simulator:
  
  To use SmartSearch ,it is mandatory to download the Python package from SolvNet(Documentation --> VG SmartSearch). Enter the full path to the source directory:
  
  If Yes, please enter the full path to the source directory containing the VCS/VCS-MX Docs+SmartSearch tarball:
  
  Enter the full path where you want to install python [default location will be <VCS_HOME>/doc/UserGuide]:
  
  Do you wish to install the Docs+SmartSearch for VCS/VCS-MX ? : [yes]: no
  
  #####################################################
  ############### Installation Summary ################
  Product:    VCS - The high-performance, high-capacity Verilog® simulator (vcs)
  Release:    O-2018.09-SP2
  Platforms:   linux64 common
  Disk Space: 4431 MB
  Target Dir: /home/synopsys/vcs/O-2018.09-SP2
  
  Licensed Products communicate with Synopsys servers for the purpose of providing software updates,
  detecting software piracy and verifying that customers are using Licensed Products in conformity with
  the applicable License Key for such Licensed Products. Synopsys will use information gathered in
  connection with this process to deliver software updates and pursue software pirates and infringers.
  #####################################################
  If the information is correct, continue with the installation.
  Accept, Install? [yes]: yes
  INFO: Prepare for installing O-2018.09-SP2 release of product vcs ...
  INFO: Extracting linux64 package from vcs_vO-2018.09-SP2_linux64.spf ...
  INFO: Extracting common package from vcs_vO-2018.09-SP2_common.spf ...
  INFO: Verify SHA256 sum for vcs.bz2 ....
  INFO: Verify SHA256 sum for linux64/vcs.bz2 ....
  INFO: Installing O-2018.09-SP2 release of product vcs to /home/synopsys/vcs/O-2018.09-SP2 ....
  INFO: Installing common package for O-2018.09-SP2 release of product vcs ...
  INFO: Installing linux64 package for O-2018.09-SP2 release of product vcs ...
  INFO: Running post-installation script: /home/synopsys/vcs/O-2018.09-SP2/etc/post_install.sh -r /home/synopsys/vcs/O-2018.09-SP2 -plat "linux64"  -pythonVersion "" -docSourcePath "" -pythonDestinationPath "default location will be <VCS_HOME>/doc/UserGuide" -installDoc "no"
  INFO: Installation for O-2018.09-SP2 release of product vcs has finished successfully.
  
  
  Synopsys tools require that a supported version of Synopsys Common
  Licensing (SCL) be installed and serving the necessary licenses.
  For information on how to obtain SCL, or your license key file,
  see http://www.synopsys.com/licensing
  
  For any postinstallation setup requirements, see the product-specific
  chapters in the Installation Guide at http://www.synopsys.com/install
  
  INFO: See installer log file /home/synopsys/installer.log
  
  ```
- 需要说明的是,安装过程中会额外询问是否需要**Docs+SmartSearch**,如果不需要,目录可以随便写,**Do you wish to install**的时候不写**yes**即可  
    
    
  ```shell
  To use SmartSearch ,it is mandatory to download the Python package from SolvNet(Documentation --> VG SmartSearch). Enter the full path to the source directory:
  
  If Yes, please enter the full path to the source directory containing the VCS/VCS-MX Docs+SmartSearch tarball:
  
  Enter the full path where you want to install python [default location will be <VCS_HOME>/doc/UserGuide]:
  
  Do you wish to install the Docs+SmartSearch for VCS/VCS-MX ? : [yes]: no
  
  ```
- 执行**installer**,安装**Verdi**,**Site ID number**同样无关紧要  
    
    
  ```shell
  [usr@Tadokoro synopsys]$ ./installer
  
          Synopsys (R) Installer
              Version 5.0.0
  
  Copyright (c) 2005 - 2021 Synopsys, Inc.
  This software and the associated documentation are proprietary to Synopsys, Inc.
  This software may only be used in accordance with the terms and conditions of a
  written license agreement with Synopsys, Inc. All other use, reproduction, or
  distribution of this software is strictly prohibited.
  
  Enter the path to the source directory containing the downloaded EFT file(s) [/home/synopsys]: /home/verdo
  
  Enter the full path to the directory where you want to
  install Synopsys products. If the directory does not exist,
  it will be created. [/usr/synopsys]: ^Z
  [1]+  Stopped                 ./installer
  [usr@Tadokoro synopsys]$ ./installer
  
          Synopsys (R) Installer
              Version 5.0.0
  
  Copyright (c) 2005 - 2021 Synopsys, Inc.
  This software and the associated documentation are proprietary to Synopsys, Inc.
  This software may only be used in accordance with the terms and conditions of a
  written license agreement with Synopsys, Inc. All other use, reproduction, or
  distribution of this software is strictly prohibited.
  
  Enter the path to the source directory containing the downloaded EFT file(s) [/home/synopsys]: /home/verdi
  
  Enter the full path to the directory where you want to
  install Synopsys products. If the directory does not exist,
  it will be created. [/usr/synopsys]: /home/synopsys
  Extracting release information from verdi_vVerdi_O-2018.09-SP2_common.spf
  Extracting release information from verdi_vVerdi_O-2018.09-SP2_common.spf successfully
  Extracting release information from verdi_vVerdi_O-2018.09-SP2_linux64.spf
  Extracting release information from verdi_vVerdi_O-2018.09-SP2_linux64.spf successfully
  
  Your site ID number is in the upper-right corner of your Synopsys license
  key certificate. If you have trouble locating it, contact your Synopsys
  representative.
  
  Site ID number [000]: 27000
  #####################################################
  ############### Installation Summary ################
  Product:    VERDI - The Industry's Open Debug Platform (verdi)
  Release:    Verdi_O-2018.09-SP2
  Platforms:   common linux64
  Disk Space: 7535 MB
  Target Dir: /home/synopsys/verdi/Verdi_O-2018.09-SP2
  
  Licensed Products communicate with Synopsys servers for the purpose of providing software updates,
  detecting software piracy and verifying that customers are using Licensed Products in conformity with
  the applicable License Key for such Licensed Products. Synopsys will use information gathered in
  connection with this process to deliver software updates and pursue software pirates and infringers.
  #####################################################
  If the information is correct, continue with the installation.
  Accept, Install? [yes]: yes
  INFO: Prepare for installing Verdi_O-2018.09-SP2 release of product verdi ...
  INFO: Extracting common package from verdi_vVerdi_O-2018.09-SP2_common.spf ...
  INFO: Extracting linux64 package from verdi_vVerdi_O-2018.09-SP2_linux64.spf ...
  INFO: Verify SHA256 sum for verdi.bz2 ....
  INFO: Verify SHA256 sum for linux64/verdi.bz2 ....
  INFO: Installing Verdi_O-2018.09-SP2 release of product verdi to /home/synopsys/verdi/Verdi_O-2018.09-SP2 ....
  INFO: Installing common package for Verdi_O-2018.09-SP2 release of product verdi ...
  INFO: Installing linux64 package for Verdi_O-2018.09-SP2 release of product verdi ...
  INFO: Installation for Verdi_O-2018.09-SP2 release of product verdi has finished successfully.
  
  
  Synopsys tools require that a supported version of Synopsys Common
  Licensing (SCL) be installed and serving the necessary licenses.
  For information on how to obtain SCL, or your license key file,
  see http://www.synopsys.com/licensing
  
  For any postinstallation setup requirements, see the product-specific
  chapters in the Installation Guide at http://www.synopsys.com/install
  
  INFO: See installer log file /home/synopsys/installer.log
  
  ```
- 最后回到**root**用户,把没用的安装文件清理一下,此外,之后没有**usr**用户什么事了  
    
    
  ```shell
  [usr@Tadokoro synopsys]$ exit
  exit
  [root@Tadokoro synopsys]# ls
  batch_installer  container  container_setup.sh  doc  install_bin  installer  installer.log  scl  setup.sh  vcs  verdi
  [root@Tadokoro synopsys]# rm installer.log
  rm: remove regular file `installer.log'? y
  [root@Tadokoro synopsys]# cd ../
  [root@Tadokoro home]# ls
  scl  synopsyinstaller  synopsys  usr  vcs  verdi
  [root@Tadokoro home]# rm -rf scl
  [root@Tadokoro home]# rm -rf synopsyinstaller/
  [root@Tadokoro home]# rm -rf vcs
  [root@Tadokoro home]# rm -rf verdi
  [root@Tadokoro home]# chmod 755 synopsys/
  
  ```
  • 准备证书文件

  
  

- 在**Windows**下启动**scl\_keygen.exe**并填写内容,再点击**Generate**生成**Synopsys.dat**
  - **HOST ID Daemon**:填写去掉冒号的**mac**地址
  - **HOST ID Feature**:填写去掉冒号的**mac**地址
  - **HOST Name**:填写**hostname**
  - **Port**:填写一个大一点的数防撞
  - ![在Docker中安装Centos6与VCS的踩坑记录教程](https://www.icode9.com/i/l/?n=20&i=blog/2322553/202108/2322553-20210806121648856-813921887.jpg)
- 修改**Synopsys.dat**第二行,添加**SCL**的目录  
    
    
  ```shell
  DAEMON snpslmd
    ↓    ↓    ↓
  DAEMON snpslmd /home/synopsys/scl/2018.06/linux64/bin/snpslmd
  
  ```
- 将证书文件分别放到`/home/synopsys/vcs/license`和`/home/synopsys/verdi/license`  
    
    
  ```shell
  [root@Tadokoro license]# ls
  Synopsys.dat
  [root@Tadokoro license]# pwd
  /home/synopsys/vcs/license
  
  ```
  
    
    
    
  ```shell
  [root@Tadokoro license]# ls
  Synopsys.dat
  [root@Tadokoro license]# pwd
  /home/synopsys/verdi/license
  
  ```
  • 激活证书文件

  
  

- 切换到`/home/synopsys/scl/2018.06/linux64/bin`,执行下面的指令  
    
    
  ```shell
  ./lmgrd -c /home/synopsys/vcs/license/Synopsys.dat
  
  ```
- 在笔者使用的**Ubuntu20.04**中,这样可以成功激活证书,结果如下(结果较长,只需关注结尾部分)  
    
    
  ```shell
  ......
  2:59:30 (snpslmd) SLOG: Statistics Log Frequency is 240 minute(s).
  2:59:30 (snpslmd) SLOG: TS update poll interval is 0. TS update is detected by midnight reread only.
  2:59:30 (snpslmd) SLOG: Activation borrow reclaim percentage is 0.
  2:59:30 (snpslmd) (@snpslmd-SLOG@) ===============================================
  2:59:30 (snpslmd) (@snpslmd-SLOG@) === Vendor Daemon ===
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Vendor daemon: snpslmd
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Start-Date: Fri Aug 06 2021 02:59:30 UTC
  2:59:30 (snpslmd) (@snpslmd-SLOG@) PID: 83
  2:59:30 (snpslmd) (@snpslmd-SLOG@) VD Version: v11.14.1.3 build 212549 x64_lsb ( build 212549 (ipv6))
  2:59:30 (snpslmd) (@snpslmd-SLOG@)
  2:59:30 (snpslmd) (@snpslmd-SLOG@) === Startup/Restart Info ===
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Options file used: None
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Is vendor daemon a CVD: Yes
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Is TS accessed: No
  2:59:30 (snpslmd) (@snpslmd-SLOG@) TS accessed for feature load: -NA-
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Number of VD restarts since LS startup: 0
  2:59:30 (snpslmd) (@snpslmd-SLOG@)
  2:59:30 (snpslmd) (@snpslmd-SLOG@) === Network Info ===
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Listening port: 35911
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Daemon select timeout (in seconds): 1
  2:59:30 (snpslmd) (@snpslmd-SLOG@)
  2:59:30 (snpslmd) (@snpslmd-SLOG@) === Host Info ===
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Host used in license file: Tadokoro
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Running on Hypervisor: Not determined - treat as Physical
  2:59:30 (snpslmd) (@snpslmd-SLOG@) ===============================================
  
  ```
- 在**Docker**环境下,这样往往会失败,失败时结果如下(结果较长,只需关注结尾部分)  
    
    
  ```shell
  ......
  2:44:03 (snpslmd) Feature sparallel superseded by sparallel
  2:44:03 (snpslmd) Cannot open daemon lock file
  2:44:03 (snpslmd) EXITING DUE TO SIGNAL 41 Exit reason 9
  2:44:03 (lmgrd) snpslmd exited with status 41 (Exited because another server was running)
  2:44:03 (lmgrd) MULTIPLE "snpslmd" license server systems running.
  2:44:03 (lmgrd) Please kill, and run lmreread
  2:44:03 (lmgrd)
  2:44:03 (lmgrd) This error probably results from either:
  2:44:03 (lmgrd)   1. Another copy of the license server manager (lmgrd) is running.
  2:44:03 (lmgrd)   2. A prior license server manager (lmgrd) was killed with "kill -9"
  2:44:03 (lmgrd)       (which would leave the vendor daemon running).
  2:44:03 (lmgrd) To correct this, do a "ps -ax | grep snpslmd"
  2:44:03 (lmgrd)   (or equivalent "ps" command)
  2:44:03 (lmgrd) and kill the "snpslmd" process.
  2:44:03 (lmgrd)
  
  ```
- 对上述问题,可创建**gen-snpslmd-hack.c**(文件名无所谓),内容如下  
    
    
  ```c
  #define _GNU_SOURCE
  #include <stdio.h>
  #include <stdlib.h>
  #include <dirent.h>
  #include <dlfcn.h>
  #include <string.h>
  
  static int is_root = 0;
  static int d_ino = -1;
  
  static DIR *(*orig_opendir)(const char *name);
  static int (*orig_closedir)(DIR *dirp);
  static struct dirent *(*orig_readdir)(DIR *dirp);
  
  DIR *opendir(const char *name)
  {
      if (strcmp(name, "/") == 0)
          is_root = 1;
      return orig_opendir(name);
  }
  
  int closedir(DIR *dirp)
  {
      is_root = 0;
      return orig_closedir(dirp);
  }
  
  struct dirent *readdir(DIR *dirp)
  {
      struct dirent *r = orig_readdir(dirp);
      if (is_root && r)
      {
          if (strcmp(r->d_name, ".") == 0)
              r->d_ino = d_ino;
          else if (strcmp(r->d_name, "..") == 0)
              r->d_ino = d_ino;
      }
      return r;
  }
  
  static __attribute__((constructor)) void init_methods()
  {
      orig_opendir = dlsym(RTLD_NEXT, "opendir");
      orig_closedir = dlsym(RTLD_NEXT, "closedir");
      orig_readdir = dlsym(RTLD_NEXT, "readdir");
      DIR *d = orig_opendir("/");
      struct dirent *e = orig_readdir(d);
      while (e)
      {
          if (strcmp(e->d_name, ".") == 0)
          {
              d_ino = e->d_ino;
              break;
          }
          e = orig_readdir(d);
      }
      orig_closedir(d);
      if (d_ino == -1)
      {
          puts("Failed to determine root directory inode number");
          exit(EXIT_FAILURE);
      }
  }
  
  ```
- 使用下面的命令编译上面的文件,完成后的目录如下  
    
    
  ```shell
  [root@Tadokoro bin]# gcc -ldl -shared -fPIC gen-snpslmd-hack.c -o snpslmd-hack.so
  
  ```
  
    
    
    
  ```shell
  [root@Tadokoro bin]# ls
  config.xml           install_fnp.sh  lmgrd     lmstat  README.TXT  server_debug_conf.xml  ssdm_admin    sssverify      watchlog.conf
  FNPLicensingService  lmdiag          lmhostid  lmutil  sclsh       snpslmd                ssdm_collect  sssverify-trl  whatscl
  gen-snpslmd-hack.c   lmdown          lmreread  lmver   sclsort     snpslmd-hack.so        sshostid      watchlog
  [root@Tadokoro bin]# pwd
  /home/synopsys/scl/2018.06/linux64/bin
  
  ```
- 查看一下之前的打开的**lmgrd**是否已经关闭,如果没有关闭使用**lmdown**关闭  
    
    
  ```shell
  [root@Tadokoro bin]# ps -a
      PID TTY          TIME CMD
       65 pts/1    00:00:00 lmgrd
       78 pts/1    00:00:00 ps
  [root@Tadokoro bin]# ./lmdown
  lmdown - Copyright (c) 1989-2017 Flexera Software LLC. All Rights Reserved.
  
  Port@Host            Vendors
  1) 27000@Tadokoro       snpslmd
  
  Are you sure (y/n)?  y
  2:57:07 (lmgrd) SHUTDOWN request from root at node Tadokoro
  2:57:07 (lmgrd) lmgrd will now shut down all the vendor daemons
  
  2:57:07 (lmgrd) EXITING DUE TO SIGNAL 15
      1 FlexNet License Server shut down
  [root@Tadokoro bin]# ps -a
      PID TTY          TIME CMD
      80 pts/1    00:00:00 ps
  
  ```
- 再使用下面的命令重新激活证书,结果如下(结果较长,只需关注结尾部分),激活成功(对于这个问题的解决参考了[此贴](https://serverfault.com/questions/922532/running-flexlm-license-server-in-a-docker-container),感谢作者)  
    
    
  ```shell
  LD_PRELOAD=./snpslmd-hack.so ./lmgrd -c /home/synopsys/vcs/license/Synopsys.dat
  
  ```
  
    
    
    
  ```shell
  ......
  2:59:30 (snpslmd) SLOG: Statistics Log Frequency is 240 minute(s).
  2:59:30 (snpslmd) SLOG: TS update poll interval is 0. TS update is detected by midnight reread only.
  2:59:30 (snpslmd) SLOG: Activation borrow reclaim percentage is 0.
  2:59:30 (snpslmd) (@snpslmd-SLOG@) ===============================================
  2:59:30 (snpslmd) (@snpslmd-SLOG@) === Vendor Daemon ===
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Vendor daemon: snpslmd
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Start-Date: Fri Aug 06 2021 02:59:30 UTC
  2:59:30 (snpslmd) (@snpslmd-SLOG@) PID: 83
  2:59:30 (snpslmd) (@snpslmd-SLOG@) VD Version: v11.14.1.3 build 212549 x64_lsb ( build 212549 (ipv6))
  2:59:30 (snpslmd) (@snpslmd-SLOG@)
  2:59:30 (snpslmd) (@snpslmd-SLOG@) === Startup/Restart Info ===
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Options file used: None
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Is vendor daemon a CVD: Yes
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Is TS accessed: No
  2:59:30 (snpslmd) (@snpslmd-SLOG@) TS accessed for feature load: -NA-
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Number of VD restarts since LS startup: 0
  2:59:30 (snpslmd) (@snpslmd-SLOG@)
  2:59:30 (snpslmd) (@snpslmd-SLOG@) === Network Info ===
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Listening port: 35911
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Daemon select timeout (in seconds): 1
  2:59:30 (snpslmd) (@snpslmd-SLOG@)
  2:59:30 (snpslmd) (@snpslmd-SLOG@) === Host Info ===
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Host used in license file: Tadokoro
  2:59:30 (snpslmd) (@snpslmd-SLOG@) Running on Hypervisor: Not determined - treat as Physical
  2:59:30 (snpslmd) (@snpslmd-SLOG@) ===============================================
  
  ```
  • 设置环境变量

  
  

- 将下面的内容追加到`/root/.bashrc`文件中即可,如采用了不同想安装路径,则需修改下文中的路径,如采用了不同的**hostname**,则需修改下文中的**LM\_LICENSE\_FILE**  
    
    
  ```bash
  #SCL
  export PATH=$PATH:/home/synopsys/scl/2018.06/linux64/bin
  export VCS_ARCH_OVERRIDE=linux
  
  #DVE
  export PATH=$PATH:/home/synopsys/vcs/O-2018.09-SP2/gui/dve/bin
  alias dve='dve -full64'
  
  #VCS
  export PATH=$PATH:/home/synopsys/vcs/O-2018.09-SP2/bin
  alias vcs='vcs -full64 -cpp g++ -cc gcc -LDFLAGS -Wl,--no-as-needed'
  
  #VERDI
  export PATH=$PATH:/home/synopsys/verdi/Verdi_O-2018.09-SP2/bin
  export VCS_HOME=/home/synopsys/vcs/O-2018.09-SP2
  export VERDI_HOME=/home/synopsys/verdi/Verdi_O-2018.09-SP2
  export NOVAS_HOME=/home/synopsys/verdi/Verdi_O-2018.09-SP2
  alias verdi='verdi'
  
  #LICENCE
  export LM_LICENSE_FILE=27000@Tadokoro
  export LD_PRELOAD='/home/synopsys/scl/2018.06/linux64/bin/snpslmd-hack.so'
  alias lmg_vcs='/home/synopsys/scl/2018.06/linux64/bin/lmgrd -c /home/synopsys/vcs/license/Synopsys.dat'
  
  ```
- 使用下面的命令使新增的环境变量生效  
    
    
  ```bash
  source /root/.bashrc
  
  ```
- 此后再次需要激活证书时(如重启容器后),只要使用下面的命令即可,此外,可根据需要制作镜像,从镜像运行容器时只要保证**hostname**和**mac**地址不发生变化,就可直接使用次命令激活证书并使用  
    
    
  ```shell
  [root@Tadokoro /]# lmg_vcs
  3:10:27 (lmgrd) -----------------------------------------------
  3:10:27 (lmgrd)   Please Note:
  3:10:27 (lmgrd)
  3:10:27 (lmgrd)   This log is intended for debug purposes only.
  3:10:27 (lmgrd)   In order to capture accurate license
  3:10:27 (lmgrd)   usage data into an organized repository,
  3:10:27 (lmgrd)   please enable report logging. Use Flexera Software LLC's
  ......
  ```=
  
  ```
  • 检查安装是否成功

  
  

- 使用下面的文件进行测试,测试目录如下  
    
    
  ```verilog
  module tb();
  
  initial begin
      $display("hello world");
      $finish;
  end
  
  endmodule
  
  ```
  
    
    
    
  ```shell
  [root@Tadokoro test]# ls
  tb.v
  [root@Tadokoro test]# pwd
  /home/test
  
  ```
- 使用下面的命令编译文件,结果如下(结果较长,只需关注结尾部分)  
    
    
  ```shell
  vcs tb.v -full64 -cpp g++ -cc gcc +lint=TFIPC-L -override_timescale=1ns/1ps
  
  ```
  
    
    
    
  ```shell
  rm -f _csrc*.so pre_vcsobj_*.so share_vcsobj_*.so
  if [ -x ../simv ]; then chmod -x ../simv; fi
  g++  -o ../simv    -Wl,-rpath-link=./ -Wl,-rpath='$ORIGIN'/simv.daidir/ -Wl,-rpath=./simv.daidir/ -Wl,-rpath='$ORIGIN'/simv.daidir//scsim.db.dir  -Wl,--no-as-needed -rdynamic  -Wl,-rpath=/home/synopsys/vcs/O-2018.09-SP2/linux64/lib -L/home/synopsys/vcs/O-2018.09-SP2/linux64/lib   objs/amcQw_d.o   _485_archive_1.so  SIM_l.o       rmapats_mop.o rmapats.o rmar.o rmar_nd.o  rmar_llvm_0_1.o rmar_llvm_0_0.o          -lzerosoft_rt_stubs -lvirsim -lerrorinf -lsnpsmalloc -lvfs    -lvcsnew -lsimprofile -luclinative /home/synopsys/vcs/O-2018.09-SP2/linux64/lib/vcs_tls.o   -Wl,-whole-archive -lvcsucli -Wl,-no-whole-archive          /home/synopsys/vcs/O-2018.09-SP2/linux64/lib/vcs_save_restore_new.o -ldl  -lc -lm -lpthread -ldl
  ../simv up to date
  CPU time: .206 seconds to compile + .302 seconds to elab + .203 seconds to link
  
  ```
- 使用下面的命令执行文件,结果如下表明成功  
    
    
  ```shell
  ./simv
  
  ```
  
    
    
    
  ```shell
  4:03:57 (snpslmd) OUT: "VCSRuntime_Net" root@Tadokoro  [snps_checkout_1628222637]
  Chronologic VCS simulator copyright 1991-2018
  Contains Synopsys proprietary information.
  Compiler version O-2018.09-SP2_Full64; Runtime version O-2018.09-SP2_Full64;  Aug  6 04:03 2021
  hello world
  $finish called from file "tb.v", line 5.
  $finish at simulation time                    0
          V C S   S i m u l a t i o n   R e p o r t
  Time: 0 ps
  CPU Time:      0.370 seconds;       Data structure size:   0.0Mb
  Fri Aug  6 04:03:57 2021
  4:03:57 (snpslmd) IN: "VCSRuntime_Net" root@Tadokoro  [snps_checkout_1628222637]
  
  ```


标签: docker, root, home, Centos6, VCS, synopsys

相关文章推荐

评论已关闭