代码之家  ›  专栏  ›  技术社区  ›  not2qubit

Perl中的核心位置、供应商位置和站点位置之间有什么区别?

  •  6
  • not2qubit  · 技术社区  · 7 年前

    我最近在安装一些模块时遇到了一些问题,我惊讶地发现,许多已经安装的模块都有重复的安装和版本。在标准(如果有这样的东西)安装中,使用 cpanm ,我发现以下结果非常令人困惑。

    报告显示了以下位置:

    • 使用 cpan -V
    # cpan -V
    
    /usr/bin/cpan script version 1.672, CPAN.pm version 2.22
    --------------------------------------------------
    Checking install dirs...
    Checking core
            + /usr/share/perl5/5.26
            + /usr/lib/perl5/5.26/x86_64-cygwin-threads
    Checking vendor
            + /usr/share/perl5/vendor_perl/5.26
            + /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
    Checking site
            + /usr/local/share/perl5/site_perl/5.26
            + /usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
    Checking PERL5LIB
            no directories for PERL5LIB
    Checking PERLLIB
            no directories for PERLLIB
    
    • perl -V:.*site.* :
    # perl -V:.*site.* |column -t -s "=" |sort -d -i -k 1.22
    
    d_sitearch           'define';
    usesitecustomize     'undef';
    siteprefix           '/usr/local';
    siteprefixexp        '/usr/local';
    installsitebin       '/usr/local/bin';
    installsitescript    '/usr/local/bin';
    sitebin              '/usr/local/bin';
    sitebinexp           '/usr/local/bin';
    sitescript           '/usr/local/bin';
    sitescriptexp        '/usr/local/bin';
    installsitearch      '/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads';
    sitearch             '/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads';
    sitearchexp          '/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads';
    installsitehtml1dir  '/usr/local/share/doc/perl/html/html1';
    sitehtml1dir         '/usr/local/share/doc/perl/html/html1';
    sitehtml1direxp      '/usr/local/share/doc/perl/html/html1';
    installsitehtml3dir  '/usr/local/share/doc/perl/html/html3';
    sitehtml3dir         '/usr/local/share/doc/perl/html/html3';
    sitehtml3direxp      '/usr/local/share/doc/perl/html/html3';
    installsiteman1dir   '/usr/local/share/man/man1';
    siteman1dir          '/usr/local/share/man/man1';
    siteman1direxp       '/usr/local/share/man/man1';
    installsiteman3dir   '/usr/local/share/man/man3';
    siteman3dir          '/usr/local/share/man/man3';
    siteman3direxp       '/usr/local/share/man/man3';
    installsitelib       '/usr/local/share/perl5/site_perl/5.26';
    sitelib              '/usr/local/share/perl5/site_perl/5.26';
    sitelib_stem         '/usr/local/share/perl5/site_perl/5.26';
    sitelibexp           '/usr/local/share/perl5/site_perl/5.26';
    
    • 使用 @INC :
    # perl -e 'print join("\n",@INC,"")'
    
    /usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
    /usr/local/share/perl5/site_perl/5.26
    /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
    /usr/share/perl5/vendor_perl/5.26
    /usr/lib/perl5/5.26/x86_64-cygwin-threads
    /usr/share/perl5/5.26
    

    结果是 cpan-outdated -p --verbose 显示完全不同(且更短)的过时模块列表 cpan -lO 应该


    1. 那么,两者之间的区别是什么呢 core , vendor site 路径的选择?
    2. 为什么每种类型有两条路径?
    2 回复  |  直到 7 年前
        1
  •  11
  •   not2qubit    7 年前

    这些安装位置的最佳参考可能是 ExtUtils::MakeMaker

    • core (也称为 特权 )-是使用Perl安装的核心模块所在的位置。在早于5.12的Perls上,双寿命模块的更新也需要安装在核心版本上,而不是安装在站点或供应商库中,因为privlib是最早出现的 @INC
    • vendor -分发供应商可以在其中安装模块。这通常是系统包管理器安装非核心模块的地方。
    • site -是CPAN客户端在直接调用时将模块安装到的位置,不包括上述双寿命模块的异常配置。

    (双寿命模块是核心模块,也可在CPAN上单独提供,这意味着您可以安装更新版本。)

    每个库位置都有一个 arch variant,安装具有特定于生成的输出文件的发行版的位置。没有动态配置的纯perl发行版被安装到标准的体系结构无关目录中,并且通常可以在其他perl和体系结构安装中不加修改地运行,只要它们的需求仍然得到满足(尽管这不是一个好主意,除非您真的知道自己在做什么)。 目录和从另一个Perl使用是不安全的。

    所有这些位置都是在构建Perl时配置的,可以使用 perl -V 如您所示的选项。他们每个人都有随行人员 script bin

    至于价格的差异 cpan-outdated -此工具(与许多使用 ExtUtils::Installed ,在使用CPAN客户端安装模块时包括,但不包括核心模块,它们通常从供应商软件包中剥离。所以很可能 cpan过时 ,但这通常是您需要找到的全部内容。我不确定cpan命令使用什么机制。

        2
  •  3
  •   not2qubit    7 年前

    :

    幸亏 池上

    # perl -V:'install(privlib|archlib|vendorlib|vendorarch|sitelib|sitearch)' |column -t -s "="
    
    installarchlib     '/usr/lib/perl5/5.26/x86_64-cygwin-threads';
    installprivlib     '/usr/share/perl5/5.26';
    installsitearch    '/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads';
    installsitelib     '/usr/local/share/perl5/site_perl/5.26';
    installvendorarch  '/usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads';
    installvendorlib   '/usr/share/perl5/vendor_perl/5.26';
    

    然后,为了了解这些内容的含义,我们可以(在perl源代码中)查看以下文件: ./Porting/Glossary :

    installarchlib    '- is the same for modules with arch- or build-dependent components.'
    installprivlib    '- contains the "pure Perl" modules that came with Perl.'
    installsitearch   '- is the same for modules with arch- or build-dependent components.'
    installsitelib    '- contains the "pure Perl" modules installed by you.'
    installvendorarch '- is the same for modules with arch- or build-dependent components.'
    installvendorlib  '- contains the "pure Perl" modules installed by your distro.'
    

    选项:

    installstyle (installstyle.U):

    风格 perl安装的一部分。这 对于需要操作整个perl的工具非常有用 只有两种样式: lib lib/perl5 . 默认值 库位置(例如privlib、sitelib)为 $prefix/lib $prefix/lib/perl5 . 前者在以下情况下有用: 是一个 专用于perl的目录(例如/opt/perl),而后者是 如果$prefix由多个包共享,则非常有用,例如,如果 $prefix=/usr/local

    不幸的是,虽然这个“style”变量用于设置 所有三个目录层次结构(核心、供应商和站点)都没有 确保相同的样式实际上适用于所有这些 $siteprefix 可能是/usr/local。(回想起来,也许是“自由党” 风格本不应该得到支持,但它确实看起来是一个不错的选择

    对于像MakeMaker这样能够 例如,如果用户打算将模块安装到专用计算机中 目录(可能通过在Makefile.PL命令行上设置前缀), 那么就没有理由假设配置时间 $installstyle设置将与该前缀相关。

    对结果进行模式匹配。

    为了与perl5.005及更早版本兼容,默认设置为 基于$prefix是否包含字符串“perl”。

    所有的细节都可以在 INSTALLATION 文件,在 Installation Directories

    • Directories for the perl distribution :
      默认情况下,“配置”将使用以下目录(5.28.1):

          Configure variable  Default value
          $prefixexp          /usr/local
          $binexp             $prefixexp/bin
          $scriptdirexp       $prefixexp/bin
          $privlibexp         $prefixexp/lib/perl5/$version
          $archlibexp         $prefixexp/lib/perl5/$version/$archname
      
    • Directories for site-specific add-on files :

         Configure        Default
         variable          value
       $siteprefixexp    $prefixexp
       $sitebinexp       $siteprefixexp/bin
       $sitescriptexp    $siteprefixexp/bin
       $sitelibexp       $siteprefixexp/lib/perl5/site_perl/$version
       $sitearchexp      $siteprefixexp/lib/perl5/site_perl/$version/$archname
      
    • Directories for vendor-supplied add-on files :

      如果要构建用于分发的perl二进制分发,请配置 您可以选择设置以下目录以用于 分发附加模块。

         Configure          Default
         variable            value
       $vendorprefixexp    (none)
      
       (The next ones are set only if vendorprefix is set.)
      
       $vendorbinexp       $vendorprefixexp/bin
       $vendorscriptexp    $vendorprefixexp/bin
       $vendorlibexp       $vendorprefixexp/lib/perl5/vendor_perl/$version
       $vendorarchexp      $vendorprefixexp/lib/perl5/vendor_perl/$version/$archname
      
    • otherlibdirs :
      最后,Configure还提供了 $otherlibdirs 此变量包含以冒号分隔的附加目录列表 . 默认情况下,它将为空。

    • APPLLIB_EXP
      在perl构建中,还有另一种向@INC添加路径的方法 时间,这是通过设置APPLLIB_EXP C预处理器来实现的 代币APPLLIB_EXP定义的目录将添加到 @公司 第一
      sh Configure -Accflags='-DAPPLLIB_EXP=\"/usr/libperl\"'

    推荐文章