Perl"使用if" cygwin break中的语句配置脚本

时间:2017-09-15 18:54:57

标签: perl cygwin packages package-managers

我正在尝试从cygwin上的源代码编译openssl。随openssl-1.1.0f一起提供的配置脚本似乎在有条件的情况下中断"使用if ..."在cygwin中运行时的包含语句。

在Linux上(成功):

$ perl -v

This is perl 5, version 26, subversion 0 (v5.26.0) built for i686-linux-gnu-
thread-multi-64int
....
$ CC='/usr/bin/gcc -static' ./Configure no-shared no-async linux-x86_64
File::Glob::glob() will disappear in perl 5.30. Use File::Glob::bsd_glob() 
instead. at ./Configure line 272.
Configuring OpenSSL version 1.1.0f (0x1010006fL)
    no-asan         [default]  OPENSSL_NO_ASAN
....
Configured for linux-x86_64.

在Cygwin上(失败):

$ perl -v

This is perl 5, version 22, subversion 4 (v5.22.4) built for cygwin-thread-
multi
...
$ CC='/usr/bin/gcc -static' ./Configure no-shared no-async mingw
Can't locate if.pm in @INC (you may need to install the if module) (@INC 
contains: /usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads 
/usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-
threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-
threads /usr/lib/perl5/5.22 .) at ./Configure line 17.
BEGIN failed--compilation aborted at ./Configure line 17.

$ head -n 17 Configure
#! /usr/bin/env perl
# -*- mode: perl; -*-
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html

##  Configure -- OpenSSL source tree configuration script

use 5.10.0;
use strict;
use File::Basename;
use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
use File::Path qw/mkpath/;
use if $^O ne "VMS", 'File::Glob' => qw/glob/;

更换

use if $^O ne "VMS", 'File::Glob' => qw/glob/;

use File::Glob qw/glob/;

导致脚本成功,直到下一次"使用if"声明:

$ head -n 17 Configure
#! /usr/bin/env perl
# -*- mode: perl; -*-
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html

##  Configure -- OpenSSL source tree configuration script

use 5.10.0;
use strict;
use File::Basename;
use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
use File::Path qw/mkpath/;
use File::Glob qw/glob/;

$ CC='/usr/bin/gcc -static' ./Configure no-shared no-async mingw
CC='/usr/bin/gcc -static' ./Configure no-shared no-async mingw
Configuring OpenSSL version 1.1.0f (0x1010006fL)
no-asan         [default]  OPENSSL_NO_ASAN
...
no-zlib-dynamic [default]
Configuring for mingw
Warning: failed to load Config_git.pl, something strange about this perl...
Something wrong with this line:
Program fragment delivered error ``Can't locate if.pm in @INC (you may need 
to install the if module) (@INC contains: util 
/usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads 
/usr/lib/perl5/site_perl/5.22 /usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-
threads /usr/lib/perl5/vendor_perl/5.22 /usr/lib/perl5/5.22/x86_64-cygwin-
threads /usr/lib/perl5/5.22 .) at /home/tester/socat/build/openssl-
1.1.0f/test/build.info line 296.
at /home/tester/socat/build/openssl-1.1.0f/test/build.info at ./Configure 
line 1616.

如何使这个cygwin Perl像这个Linux Perl一样?还有其他方法可以使这个配置脚本成功吗?

以下是我安装的模块:

$ perl -E'say for @INC' | xargs ls
ls: cannot access '/usr/lib/perl5/site_perl/5.22/x86_64-cygwin-threads': No such file or directory
ls: cannot access '/usr/lib/perl5/site_perl/5.22': No such file or directory
ls: cannot access '/usr/lib/perl5/vendor_perl/5.22/x86_64-cygwin-threads': No such file or directory
.:
(redacted)

/usr/lib/perl5/5.22:
AutoLoader.pm   Carp.pm      DirHandle.pm  FileHandle.pm  Locale          Params     SelectSaver.pm  Tie            version
AutoSplit.pm    Class        Exporter      FindBin.pm     locale.pm       parent.pm  SelfLoader.pm   Time           version.pm
B               Config       Exporter.pm   Getopt         Math            Parse      strict.pm       unicore        warnings
base.pm         constant.pm  ExtUtils      I18N           Module          PerlIO     Symbol.pm       UNIVERSAL.pm   warnings.pm
bytes.pm        CPAN         feature.pm    integer.pm     overload        PerlIO.pm  Term            utf8.pm        Win32API
bytes_heavy.pl  Digest       fields.pm     IO             overload.pm     Pod        Test            utf8_heavy.pl  x86_64-cygwin-threads
Carp            Digest.pm    File          IPC            overloading.pm  Safe.pm    Text            vars.pm        XSLoader.pm

/usr/lib/perl5/5.22/x86_64-cygwin-threads:
attributes.pm  Config.pm        Data           Encode     Fcntl.pm  IO      List    Opcode.pm  re.pm      Storable.pm  Win32API
auto           Config_heavy.pl  Digest         Encode.pm  File      IO.pm   MIME    PerlIO     Scalar     Time
B.pm           Cwd.pm           DynaLoader.pm  Errno.pm   I18N      lib.pm  mro.pm  POSIX.pm   Socket.pm  Win32.pm

/usr/lib/perl5/vendor_perl/5.22:
CPAN

2 个答案:

答案 0 :(得分:1)

if.pm是标准perl包的一部分

$ cygcheck -f /usr/lib/perl5/5.22/if.pm
perl-5.22.4-1

您应该检查包是否正确安装

$ cygcheck -c perl
Cygwin Package Information
Package              Version        Status
perl                 5.22.4-1       OK

如果没有,就像看起来一样,重新安装它。

此外,正如您在setup.ini内所见,在设置 - arch。exe上有3个可用的软件包版本,您应该注意混合它们。

@ perl
sdesc: "Perl programming language interpreter"
...
version: 5.22.4-1
...
[prev]
version: 5.22.3-1
..
[test]
version: 5.24.1-1

当前版本为5.22.4-15.24.1-1是未来可能使用的测试版本。由于您显然不需要test版本,因此只需使用当前稳定版5.22.4-1即可。 混合对你不利......

答案 1 :(得分:-1)

解决方案:安装了错误版本的perl软件包。

问题是由于未选择perl_base包而引起的。

指示症状:

$ perl -v

This is perl 5, version 22, subversion 4 (v5.22.4) built for cygwin-
thread-multi

通过手动选择perl_base包解决了问题。然后Perl升级到v5.24.1并在if.pm中包含@INC模块:

enter image description here

解决方案的指示:     $ perl -v

This is perl 5, version 24, subversion 1 (v5.24.1) built for x86_64-cygwin-
threads-multi

安装perl_base软件包后,配置脚本已完成,但没有Can't locate if.pm in @INC错误。