CPAN 使用旧版本的 perl 来安装模块

CPAN 使用旧版本的 perl 来安装模块

本周末早些时候,我安装了 Ubuntu,并且必须为正在使用的脚本安装更新版本的 perl(5.22.0)。但是,当我使用 CPAN 安装所需的模块时,我发现它们安装在 Ubuntu 的默认 perl(5.18.2) 中。我运行后perl -l显示已更新的 perl5,但出于某种原因,CPAN 拒绝使用它。

我确信这是一个配置问题,或者我误解了 CPAN 的工作原理。无论如何,我浏览了谷歌的一页又一页,试图找到解决方案,但无济于事。我希望这里有人可以给我指明正确的方向,也许这对遇到类似问题的人有所帮助。

答案1

我也遇到了同样的问题。 警告:我正在使用 Fedora。 但是,fc22 破坏了我的 perl 脚本 [perl 5.20.3 解释器会出现段错误],所以我不得不安装 5.22.0,所以我对此有一些直接的经验。


了解新解释器的配置

首先,你是如何安装的。我猜你使用安装程序安装了 5.22.0 的二进制包。这是否覆盖了/usr/bin/perl?我想是的。或者,它是否被安装为(例如)/usr/bin/perl-5.22.0

在 中/usr/lib64/perl/Config.pm,查看底部以找到绑定的哈希。这将具有配置。获取此配置的另一种 [也许更好] 方法是转储@INC并执行并从 [当然是 perl] 脚本中use Config;转储哈希。Config

特别令人感兴趣的是privlibexp、、和变量。sitearchexpsitelibexparchlibexp

倾销@INC是最确定的。

需要注意/回答的问题是:5.22.0 perl 解释器是否使用 5.22.0 目录或某些配置是否仍然指向 5.18.2?

这些目录中应该有一个或多个CPAN.pmCPAN子目录一起。我猜你会找到它仅有的5.18.2相关目录下。

事实上,通过一些调查,你可能会发现你现在有一个“杂交种”安装既不是 5.18.2,也不是 5.22.0。如果您 [决定] 遵循我的“推荐最佳实践”[见下文],您可能希望卸载 5.22.0,以便您拥有原始/标准的 5.18.2 安装。如果 Ubuntu 确实发布了补丁,这将最大限度地减少麻烦。


关于 CPAN 的一些知识

当发行版安装 perl 软件包时重叠使用 CPAN 提供的软件包,它在某种程度上是可行的。但实际上,它们经常发生冲突。此外,使用非标准 perl 版本来对抗发行版需要更加小心。

您可能必须使用新解释器在 5.22.0 目录下安装 CPAN。这可能是简短的答案。

因此,这引出了一个问题:CPAN 最初是如何安装的。它是从发行版安装的,还是手动安装的?如果是从发行版安装的,则“升级”可能有效。否则,从新的 perl 解释器手动安装它 — — 这应该会将它 [以及它安装的任何东西] 发送到正确的位置。

此外,$HOME您应该在下面找到一个.cpan目录 [如果您已经运行过它]。特别有趣的是$HOME/.cpan/CPANsubdir。它应该有一个 cpan 配置文件(例如$HOME/.cpan/CPAN/MyConfig.pm)。有许多变量,但make_install_make_command可能有些用处


我所做的事情——推荐最佳实践

[旁注:我已经使用 perl 20 多年了——我当前的脚本库中有 250,000 行代码]。

我已经多次遇到过这种问题。坦白说,我不再与发行版“作对”,因为你遇到的问题。尽管从理论上讲,发行版宣称能够同时安装多个软件包版本,但我一直对此不太走运,尤其是 perl。

在我看来,根据我的经验,你遇到的问题只是冰山一角。即使你解决了,以后可能还会有更多类似的问题。

如果我需要备用的 perl 版本,我会去 perl 网站下载来源tarball 并重建它。注意:[来自 perl 网站] 的建议是从 perl 网站下载源代码,然后不是尝试从发行版源包重建。

我为脚本指定了一个备用前缀./Configure,以便所有内容都放在新位置。然后,执行makeand make install

例如,我的 5.22.0 perl 位于 下,其下/home/alt/perl/perl-5.22.0有、 和。我可以根据需要维护任意数量的不同版本,因为它们各自都bin/perllib/CPAN.pmlib/CPAN/home/alt/perl/<version>

之后,我可以执行(例如):ln -sf /home/alt/perl/perl-5.22.0/bin/perl /usr/bin/perl22并更改我想要使用的脚本#!/usr/bin/perl22

以下是我用来配置 perl 的选项。前三个是最重要的 [*]:

-Dprefix=/home/alt/perl/perl-5.22.0
-Dstartperl=/home/alt/perl/perl-5.22.0/bin/perl
-Dusethreads=y
-DEBUGGING=both
-Doptimize=-gdwarf-2
-Dman1dir=none
[email protected]
-Dpager=/usr/bin/less
'-Dstatic_ext=threads threads/shared'
-d
-e
-s

请注意,由于我在使用 Fedora 5.20.3 时遇到了问题,我可能添加了一些您不需要的额外调试选项。

/home/myself/perl/perl-5.22.0如果您想要一份私人/实验性副本,也可以将其放在另一个地方。

注意:因为我使用了完全不同的地方来安装 5.22.0、5.22.0 和 5.20.3共存完全和谐。他们不会以任何方式干扰[AFAICT]。

你甚至可以尝试一下没有干扰您已经安装的 5.22.0。


我的实际重建脚本

[*] PS 当然,我有一个完全自动化的 perl 脚本来完成所有这些配置、构建、安装 [并从网站提取 tarball]

这些将不是可以按原样运行,因为它们需要/假设我现有的很多基础设施。它们仅供参考。如果您有兴趣查看,请忽略您无法立即识别的约 99.44% 的内容。

这是 perl 特定的脚本:

#!/usr/bin/perl
# altbld/qprlmkx -- connect to CPAN
#
# xperl -- execute script with alternate perl interpreter
#   "-b" -- use base script name (e.g. skip XBIN)
#   "-ddd" -- run ddd on perl
#   "-db" -- run perl script debugger (perl's -d)
#   "-D" -- perl -D options (see perlrun manpage)
#   "-E" -- environment variables
#   "-Lc" -- use alternate glibc (BROKEN)
#   "-Ld" -- set up PERLIO_DEBUG
#   "-Le" -- force glibc to use stderr for fatal errors
#   "-S" -- do vxshazam (recommended for debug on vxshazam programs)
#
# pathx -- dump the path
#
# qprlmkc -- configure perl interpreter
# qprlmkx -- remake perl interpreter

use qslib::qsinit;
use qpile::qpchk;
use qsnet::rshlib;
use pjx::pjxlib;
use qpile::qploc;
use altbld::altlib;
use gtx::gtxlib;

master(@ARGV);
exit(0);

# master -- master control
sub master
{
    my(@argv) = @_;
    my($proc);
    my(@opts);

    unshift(@argv,"-ddd")
        if ($pgmtail eq "qprlgdb");

    while (1) {
        vbqdash(\@argv);
        vbqnumdcd($_,"-S",1,\$keyS);

        vbqnumdcd($_,"-go",1,\$keygo);

        if (($pgmtail eq "xperl") || ($pgmtail =~ /^tskdir/)) {
            vbqnumdcd($_,"-b",1,\$keyb);
            vbqnumdcd($_,"-db",1,\$keydb);
            vbqvstrdcd($_,"-D","tlsRSD",\@keyD);
            vbqvstrdcd($_,"-E",undef,\@keyE);

            vbqnumdcd($_,"-Le",1,\$keyLe);
            vbqnumdcd($_,"-Lc",1,\$keyLc);
            vbqnumdcd($_,"-Ld",1,\$keyLd);

            pjxdddopt($_);
            vbqnumdcd($_,"-help",1,\$keyhelp);
            vbqnumdcd($_,"-Q",1,\$keyQ);
            vbqnumdcd($_,"-S",1,\$keyS);
        }

        if ($pgmtail eq "qprlmkc") {
            vbqvstrdcd($_,"-D",undef,\@keyD);
            vbqnumdcd($_,"-publish",1,\$keypublish);
        }

        vbqnumdcd($_,"-ask",1,\$keyask);
        vbqnumdcd($_,"-sh",1,\$keysh);

        altoptdcd($_);

        sysusage($_);
    }

    vxshazam()
        if ($keyS);

    push(@opts,"-V$keyV")
        if ($keyV ne "");
    $APL = altverget(@opts,"perl");
    $ALTPERL = $APL->{alt_xfile};

    $APL->{alt_bld} = $APL->{alt_src};

    $APL->{alt_remhost} = "ftp.cpan.org";
    $APL->{alt_remtop} = "pub/CPAN/src";
    ###$APL->{alt_remdir} = "/gcc-" . $APL->{alt_revuse};
    $APL->{alt_remsuf} = ".tar.gz";

    $proc = "cmd_" . $pgmtail;
    &$proc(@argv);
}

# cmd_qprlwget -- pull perl
sub cmd_qprlwget
{

    altwget($APL);
}

# cmd_qmetacfg -- pull perl
sub cmd_qmetacfg
{
    my($sdir);
    my($tail);

    $sdir = $APL->{alt_top};
    msg("$pgmtail: chdir %s ...\n",$sdir);
    xchdir($sdir);

    # get metaconfig
    {
        if (-d $tail) {
            msg("$pgmtail: project dir already exists\n");
            last;
        }

        last;

        vxsystem("git","clone",
            "git://perl5.git.perl.org/$tail.git",
            $tail);
    }
}

# cmd_qprlver -- show versions
sub cmd_qprlver
{
}

# cmd_qprldis -- disassemble executable
sub cmd_qprldis
{

    vxsystem("-x","asmdis",$APL->{alt_xfile});
}

# cmd_qprlmkc -- configure perl
sub cmd_qprlmkc
{
    my(@opts);
    my(@shopts);
    push(@lnklist);
    my($src,$ins,$bld,$xfile);
    my($tail,$lnkto);

    $keygo = 0
        if ($keypublish);

    $src = $APL->{alt_src};
    $ins = $APL->{alt_ins};
    $bld = $APL->{alt_bld};
    $xfile = $APL->{alt_xfile};

    xchdir($src);
    ###sysrmdir($bld);
    ###xmkdir($bld);
    ###xchdir($bld);

    # make depend fails [due to bug] without some symlinks
    ###push(@lnklist,qw(makedepend.SH Makefile.SH perl_exp.SH config_h.SH));
    foreach $tail (@lnklist) {
        $lnkto = "$src/$tail";
        symlink($lnkto,$tail) ||
            sysfault("qprlmkc: unable to symlink to '%s' -- $!\n",$lnkto);
    }

    # save us some complaints
    if ($keygo) {
        xmkdir($ins);
        xmkdir("$ins/bin");
    }

    push(@opts,"-Dprefix=$ins");
    push(@opts,"-Dstartperl=$xfile");

    push(@opts,"-Dusethreads=y");
    ###push(@opts,"-Duseithreads=y");
    ###push(@opts,"-Duselargefiles");
    ###push(@opts,"-Duse64bitall=y");

    ###push(@opts,"-Dusedevel");
    push(@opts,"-DEBUGGING=both");
    push(@opts,"-Doptimize=-gdwarf-2");

    ###push(@keyD,"DEBUG_LEAKING_SCALARS");

    foreach $opt (@keyD) {
        push(@opts,"-A","ccflags=-D$opt");
    }

    # hard to breakpoint on dynamically loaded stuff
    if (1) {
        push(@sext,"threads");
        push(@sext,"threads/shared");
    }

    push(@opts,"-Dman1dir=none");
    $env = gtxconfig("user");
    $email = $env->{email};
    $email = "anybody\@gmail.com"
        if ($keypublish);
    push(@opts,"-Dcf_email=" . $email);

    if (0) {
        push(@opts,"-Dnetdb_host_type=const void *");
        push(@opts,"-Dnetdb_hlen_type=socklen_t");
    }

    push(@opts,"-Dpager=/usr/bin/less");

    if (@sext > 0) {
        $opt = join(" ",@sext);
        push(@opts,"-Dstatic_ext=$opt");
    }

    # NOTE: to use threads, one must also use perlio :-(
    ###push(@opts,"-Duseperlio=n");

    ###push(@opts,$APL->{alt_src});

    # whip through defaults
    push(@opts,"-d","-e","-s")
        unless ($keyask);

    msgv("$pgmtail: OPTS",@opts);

    if ($keypublish) {
        foreach $opt (@opts) {
            $opt = $quo_1 . $opt . $quo_1
                 if ($opt =~ /\s/);
            printf("%s\n",$opt);
        }
    }

    unless ($keygo) {
        sysfault("$pgmtail: rerun with -go to actually do it\n");
    }

    sleep(5)
        if (sysisatty(1));

    push(@shopts,"-x")
        if ($keysh);

    {

        last unless ($keygo);

        vxsystem("sh",@shopts,"$APL->{alt_src}/Configure",@opts);
    }

    # complains on the second round
    {
        last unless ($keygo);

        last if (-e "$src/MANIFEST_NOT");

        msg("$pgmtail: renaming manifest ...\n");
        rename("$src/MANIFEST","$src/MANIFEST_NOT");

        $xfdst = xfopen(">$src/MANIFEST","qprlmkc");
        $xfdst = xfclose($xfdst,"qprlmkc");
    }
}

# cmd_qprlmkx -- make perl executable
sub cmd_qprlmkx
{
    my(@opts);

    xchdir($APL->{alt_bld});

    vxsystem("-x","make");
}

# cmd_xperl -- invoke alternate perl
sub cmd_xperl
{
    my(@argv) = @_;
    my(@opts);

    unshift(@argv,"-V")
        if ($keyQ);

    @opts = altperl(@argv);

    enveval("ALTPERL",$ALTPERL);

    {
        last if (defined($keyddd));
        xperlenv();
        exec($ALTPERL,@opts);
        sysfault("$pgmtail: exec of '%s' failed -- $!\n",$ALTPERL);
    }

    pjxgdbinit("-alien=$APL->{alt_src}",@opts);
    pjxdddloc();

    xperlenv();
    vxsystem("-x",@ddd,$ALTPERL);
}

# xperlenv -- set up environment
sub xperlenv
{
    my($opt);

    foreach $opt (@keyE) {
        if ($opt =~ /$keyval_rgx/o) {
            enveval($1,$2);
        }
    }
}

# altperl -- get alternate perl
sub altperl
{
    my(@argv) = @_;
    my(@keyD);
    local(@opts);
    my($tail,$file);
    my($logf);

    zprt(ZPXHOWEXEC,"altperl: ENTER\n");

    zprtlist(ZPXHOWEXEC,"altperl/ARGV",\@argv);

    envchk(qw(XLBIN));

    # turn on perl's internal tracing
    # NOTE: perl must be compiled with -DEBUGGING for this to work
    foreach $opt (@keyD) {
        push(@opts,"-D$opt");
        $keyLe = 1;
    }

    # run the script debugger
    push(@opts,"-dt")
        if ($keydb);

    while (1) {
        vbqdash(\@argv);
        push(@opts,$_);
        zprt(ZPXHOWEXEC,"altperl: PUSHOPT '%s'\n",$_);
    }

    # locate the script
    {
        $tail = shift(@argv);

        $file = tstloc($tail);
        last if (defined($file));

        if ($tail =~ m,^[./],) {
            $file = $tail;
            last;
        }

        # skip the XBIN entries and go direct to the final script
        if ($keyb) {
            $file = basescan($tail);
            last;
        }

        $file = "$XLBIN/$tail";
    }
    push(@opts,$file);

    # tell tskdirbug to _not_ fork/exec
    {
        last unless ($keyddd || $keydb);
        last unless (defined($tst_xfile));
        push(@opts,"-d");
    }

    enveval("LIBC_FATAL_STDERR_",1)
        if ($keyLe);

    $keyLd = 1
        if (zprtok(ZPXHOWGDB));

    if ($keyLd) {
        $logf = logfile("qprldbg");
        msg("altperl: PERLIO_DEBUG %s ...\n",$logf);
        unlink($logf);
        enveval("PERLIO_DEBUG",$logf);
    }

    # FIXME/CAE -- this needs work
    ###$glibc_ins = "/home/libc";
    ###$dir = "$glibc_ins/lib";
    ###enveval("LD_LIBRARY_PATH",$dir)
        ###if ($keyLc);

    push(@opts,@argv);
    msgv("altperl: OPTS",@opts,"...");

    zprt(ZPXHOWEXEC,"altperl: EXIT\n");

    @opts;
}

# basescan -- run perl debugger on base script
sub basescan
{
    my($basetail) = @_;
    my($topdir);
    my($basefile);
    my($bindir,@binpath);
    my($lnkfile);

    $topdir = syshome("altperl");
    sysrmdir($topdir);
    xmkdir($topdir);

    @binpath = qpbinpath();
    foreach $bindir (@binpath) {
        push(@opts,"-I$bindir");
    }

    $basefile = qplocate($basetail);
    sysfault("basescan: unable to locate '%s'\n",$basetail)
        unless (-e $basefile);
    msg("basescan: %s --> %s ...\n",$basetail,$basefile);

    # we have to create a link with the correct command name in it
    $lnkfile = "$topdir/$basetail";
    symlink($basefile,$lnkfile) ||
        sysfault("basescan: unable to symlink '%s' to '%s' -- $!\n",
            $lnkfile,$basefile);

    $lnkfile;
}

# cmd_pathx -- show path
sub cmd_pathx
{
    my(@argv) = @_;

    # execute ourself with the alternate interpreter -- we will _not_
    # recurse further because we're leaving off the -P
    {
        last if ($keyV eq "");
        exec($ALTPERL,$0);
        sysfault("$pgmtail: exec failure -- $!\n");
    }

    showpath("INC",\@INC);
    showpath("PATH");
    showpath("LD_LIBRARY_PATH");
}

# showpath -- show a path
sub showpath
{
    my($sym,$path) = @_;
    my(@path);

    printf("%s:\n",$sym);

    {
        if (ref($path)) {
            @path = @$path;
            last;
        }

        $path = $ENV{$sym};
        @path = syspathsplit($path);
    }

    foreach $path (@path) {
        printf("  %s\n",$path);
    }
}

# cmd_tskdirbug -- wrapper for tskdirbug
sub cmd_tskdirbug
{
    my($xfile);

    $xfile = tstloc();

    if ($keyhelp) {
        sysusage_less(pgmbase(),$xfile);
    }
}

# tstloc -- locate script
sub tstloc
{
    my($tail) = @_;
    my($code);
    my($xfile);

    $tail //= "tskdirbug";

    $tst_top = cdxgo("cdt");

    {
        if ($tail =~ /^tskdir/) {
            $tst_dir = "$tst_top/tskdirbug";
            last;
        }

        $tst_dir = "$tst_top/$tail";
    }

    $xfile = "$tst_dir/$tail";
    undef($xfile)
        unless (-e $xfile);

    $tst_xfile = $xfile;

    {
        last if ($keyhelp);

        last unless (defined($xfile));

        $code = qpchkgo($xfile);
        exit(1) if ($code);
    }

    $xfile;
}

这是它的主要库 [它是构建其他东西的基础,例如 glibc、gcc 等]:

# altbld/altlib.pm -- common alternate make control
#
#@+
#   "-a" -- push all versions
#   "-go" -- actually do it (install)
#   "-j" -- suppress parallel build
#   "-url" -- output top url
#   "-V" -- target version to build (DEFAULT: highest)
#   "-x" -- extractable versions
#@-

_altsetup();

# _altsetup -- passive setup
sub _altsetup
{

    $altsuf{".tar.gz"} = "z";
    $altsuf{".tgz"} = "z";

    $altsuf{".tar.bz"} = "j";
    $altsuf{".tbz"} = "j";

    @altsuf = reverse(sort(keys(%altsuf)));
}

# altoptdcd -- decode options
sub altoptdcd
{
    my($arg) = @_;

    vbqnumdcd($arg,"-a",1,\$keya);
    vbqnumdcd($arg,"-go",1,\$keygo);
    vbqstrdcd($arg,"-install","",\$keyinstall);
    vbqnumdcd($arg,"-j",1,\$keyj);
    vbqstrdcd($arg,"-V","",\$keyV);
    vbqnumdcd($arg,"-x",1,\$keyx);
    vbqnumdcd($arg,"-url",1,\$keyurl);
}

# altwget -- get versions
sub altwget
{
    local($alt) = @_;
    local($remtop);
    local($foundcnt);
    my($rev,@revlist);

    sysfault("!altwget: bad pointer\n")
        unless (ref($alt));

    # most sites allow ftp with some exceptions (e.g. python.org)
    $remtop = $alt->{alt_remproto};
    $remtop //= "ftp";

    $remtop .= "://" . $alt->{alt_remhost} . "/" . $alt->{alt_remtop};

    {
        if ($keyurl) {
            printf("%s\n",$remtop);
            last;
        }

        if ($keya) {
            @revlist = @{$alt->{alt_revlist}};
            last;
        }

        push(@revlist,$alt->{alt_revuse});
    }

    foreach $rev (@revlist) {
        _altwget($rev);
    }
}

# _altwget -- pull version from website
sub _altwget
{
    my($rev) = @_;
    my($remurl,$remtail);
    my($tgzfile);
    my($dir,@dirs);
    my($subdir);
    my($cmd);

    $remurl .= $remtop;
    $remurl .= $alt->{alt_remdir};
    $remtail = $alt->{alt_name} . "-$rev" . $alt->{alt_remsuf};
    $remurl .= "/$remtail";

    xchdir($alt->{alt_netsave});
    $tgzfile = $alt->{alt_netsave} . "/$remtail";

    {
        $cmd = $altsuf{$alt->{alt_remsuf}};

        if (defined($cmd)) {
            $cmd .= "xf";
            last;
        }

        sysfault("_altwget: unknown suffix -- %s\n",$remurl);
    }

    {
        # pull the file
        unless (-e $tgzfile) {
            msgv("altwget:",NOGO("pulling"),$remurl,"...");
            if ($keygo) {
                $code = vxsystem("wget",$remurl);
                last if ($code);
            }
        }

        {
            ($dir) = homesrc("-d",$alt->{alt_name});

            unless (defined($dir)) {
                msgv("altwget: no directory found --",@dirs);
                last;
            }

            zprtx("\n")
                if ($keya);

            $subdir = "$dir/" . $alt->{alt_name} . "-$rev";
            if (-d $subdir) {
                msgv("altwget:",NOGO("removing"),$subdir);
                sysrmdir($subdir)
                    if ($keygo);
            }

            msgv("altwget:",NOGO("extracting"),$rev,"in",$dir,"...");
            $code = vxsystem("-C$dir","tar",$cmd,$tgzfile)
                if ($keygo);

            $foundcnt++;
        }

        unless ($keygo) {
            msg("altwget: rerun with -go to actually do it\n");
            last;
        }
    }

    msg("altwget: %s\n",$code ? "errors" : "complete");
}

# altverget -- get version
sub altverget
# "-ins" -- scan install directories
# "-q" -- quiet mode
{
    my(@argv) = @_;
    my($keyins,$keyq) = (0,0);
    my($keyV);
    my($svmsg);
    my($pjname);
    my($tail,@tails);
    my($dir,@dirs);
    my(@revlist);
    my($revfound);
    my($revuse);
    my($sym,$val);
    my($suf);
    my($alt);

    while (1) {
        vbqdash(\@argv);
        vbqnumdcd($_,"-ins",1,\$keyins);
        vbqstrdcd($_,"-V","",\$keyV);
        vbqnumdcd($_,"-q",1,\$keyq);
        vbqusage($_,"altverget");
    }

    $svmsg = msgqtpush($keyq);

    $pjname = shift(@argv);
    msg("altverget: project %s ...\n",$pjname);
    $alt = {};
    $alt->{alt_name} = $pjname;

    envchk(qw(NETSAVE));
    $alt->{alt_netsave} = filejoin($NETSAVE,$pjname);
    msg("altverget: netsave %s ...\n",$alt->{alt_netsave});

    $alt->{alt_ins} = "/home/alt/$pjname";

    $revlist = [];
    $alt->{alt_revlist} = $revlist;

    {
        if ($keyins) {
            @dirs = ($alt->{alt_ins});
            msg("altverget: from install ...\n");
            last;
        }

        if ($keya) {
            $keyx = 1;
        }
        else {
            last if ($pgmtail =~ /wget/);
        }

        if ($keyx) {
            msg("altverget: from netsave ...\n");
            @dirs = ($alt->{alt_netsave});
            last;
        }

        msg("altverget: from src ...\n");
        @dirs = homesrc($pjname);
    }

    foreach $dir (@dirs) {
        $alt->{alt_top} = $dir;
        $alt->{alt_src} = $dir;

        # get known versions
        if (-e $alt->{alt_src}) {
            @tails = xfdirload($alt->{alt_src},"altverget");

            foreach $tail (@tails) {
                next unless ($tail =~ s/^$pjname-//);
                foreach $suf (@altsuf) {
                    last if ($tail =~ s,$suf$,,);
                }
                push(@$revlist,$tail);
            }

            @$revlist = revsort(@$revlist);
            msgv("altverget: versions",@$revlist);

            $revfound = $revlist->[$#$revlist];

            last;
        }
    }

    # do final selection on revision
    {
        {
            # explicit command line override
            if ($keyV ne "") {
                $revuse = $keyV;
                last;
            }

            # grab an override from the environment
            $sym = "ALTREV_" . $pjname;
            $val = $ENV{$sym};
            if ($val ne "") {
                $revuse = $val;
                last;
            }

            $sym = "PJNAME";
            $val = $ENV{$sym};
            if ($val =~ s/^$pjname-//) {
                $revuse = $val;
                last;
            }

            # use searched for value
            $revuse = $revfound;
        }

        if ($revuse eq "") {
            $revuse = "unknown";
            $alt->{alt_revuse} = $revuse;
            last if ($keyins);
            last if ($keyurl);
            sysfault("altverget: no version specified\n");
        }

        msg("altverget: VERSION %s ...\n",$revuse);
        $alt->{alt_revuse} = $revuse;
    }

    $alt->{alt_src} .= "/$pjname-$revuse";
    msg("altverget: source %s ...\n",$alt->{alt_src});

    $alt->{alt_bld} = syshome("-xt","alt/build/$pjname/$pjname-$revuse");
    msg("altverget: build %s ...\n",$alt->{alt_bld});

    $alt->{alt_ins} .= "/$pjname-$revuse";
    ###$alt->{alt_ins} .= "/$pjname";
    msg("altverget: install %s ...\n",$alt->{alt_ins});

    {
        if ($revuse eq "std") {
            $alt->{alt_xfile} = "/usr/bin/$pjname";
            $alt->{alt_std} = 1;
            last;
        }

        $pjname =~ s/-.+$//;
        $alt->{alt_xfile} = $alt->{alt_ins} . "/bin/$pjname";
    }
    msg("altverget: xfile %s ...\n",$alt->{alt_xfile});

    msgqtpop($svmsg);

    $alt;
}

1;

相关内容