如何在自定义@INC 中使用 DBI 构建 DBD::mysql?
How to build DBD::mysql with DBI in a custom @INC?
我在持续集成构建服务器中构建 DBI 和 DBD::mysql。 DBI 的构建是成功的,如下面的构建日志摘录所示。它清楚地将 DBI/DBD.pm 安装在正确的位置。
pushd DBI-1.643
perl Makefile.PL INSTALL_BASE=/data/pods/mysql-tools/mysql-tools/current
...
Installing /data/pods/mysql-tools/mysql-tools/current/lib/perl5/x86_64-linux-thread-multi/DBI/DBD.pm
...
Appending installation info to /data/pods/mysql-tools/mysql-tools/current/lib/perl5/x86_64-linux-thread-multi/perllocal.pod
但是 DBD::mysql 的下一部分构建失败了,因为它找不到 DBI 安装的文件。
pushd DBD-mysql-4.050
perl Makefile.PL INSTALL_BASE=/data/pods/mysql-tools/mysql-tools/current --ssl
Can't locate DBI/DBD.pm in @INC (@INC contains:
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5 .)
at Makefile.PL line 15.
您可以看到,DBD::mysql 的 MakeMaker 根本没有将安装位置添加到其 @INC
。它只有默认目录。
有没有办法将参数传递给 MakeMaker 以将安装目录添加到 @INC
?我想我可以对其进行硬编码,但这似乎不合适且难以维护。有没有更好的方法自动将INSTALL_BASE/lib/perl5/<arch>
添加到@INC
?
环境:
- CentOS 7 Linux
- Perl 5.16.3
我当然更愿意使用 cpanm。但由于我雇主的安全政策,CI 构建服务器与互联网隔离。不允许来自 CI.
的 http 代理
根据the documentation,INSTALL_BASE
用于告诉make install
安装模块的位置:
INSTALL_BASE
INSTALL_BASE
can be passed into Makefile.PL
to change where your
module will be installed. INSTALL_BASE
is more like what everyone else
calls "prefix" than PREFIX
is.
但它不会告诉 perl
到哪里寻找已安装的模块。为此,您可以使用环境变量 PERL5LIB
,根据 the documentation :
PERL5LIB
A list of directories in which to look for Perl library files before
looking in the standard library. Any architecture-specific and
version-specific directories, such as version/archname/
, version/
, or
archname/
under the specified locations are automatically included if
they exist, with this lookup done at interpreter startup time. In
addition, any directories matching the entries in
$Config{inc_version_list}
are added.
我在持续集成构建服务器中构建 DBI 和 DBD::mysql。 DBI 的构建是成功的,如下面的构建日志摘录所示。它清楚地将 DBI/DBD.pm 安装在正确的位置。
pushd DBI-1.643
perl Makefile.PL INSTALL_BASE=/data/pods/mysql-tools/mysql-tools/current
...
Installing /data/pods/mysql-tools/mysql-tools/current/lib/perl5/x86_64-linux-thread-multi/DBI/DBD.pm
...
Appending installation info to /data/pods/mysql-tools/mysql-tools/current/lib/perl5/x86_64-linux-thread-multi/perllocal.pod
但是 DBD::mysql 的下一部分构建失败了,因为它找不到 DBI 安装的文件。
pushd DBD-mysql-4.050
perl Makefile.PL INSTALL_BASE=/data/pods/mysql-tools/mysql-tools/current --ssl
Can't locate DBI/DBD.pm in @INC (@INC contains:
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5 .)
at Makefile.PL line 15.
您可以看到,DBD::mysql 的 MakeMaker 根本没有将安装位置添加到其 @INC
。它只有默认目录。
有没有办法将参数传递给 MakeMaker 以将安装目录添加到 @INC
?我想我可以对其进行硬编码,但这似乎不合适且难以维护。有没有更好的方法自动将INSTALL_BASE/lib/perl5/<arch>
添加到@INC
?
环境:
- CentOS 7 Linux
- Perl 5.16.3
我当然更愿意使用 cpanm。但由于我雇主的安全政策,CI 构建服务器与互联网隔离。不允许来自 CI.
的 http 代理根据the documentation,INSTALL_BASE
用于告诉make install
安装模块的位置:
INSTALL_BASE
INSTALL_BASE
can be passed intoMakefile.PL
to change where your module will be installed.INSTALL_BASE
is more like what everyone else calls "prefix" thanPREFIX
is.
但它不会告诉 perl
到哪里寻找已安装的模块。为此,您可以使用环境变量 PERL5LIB
,根据 the documentation :
PERL5LIB
A list of directories in which to look for Perl library files before looking in the standard library. Any architecture-specific and version-specific directories, such as
version/archname/
,version/
, orarchname/
under the specified locations are automatically included if they exist, with this lookup done at interpreter startup time. In addition, any directories matching the entries in$Config{inc_version_list}
are added.