Changeset 28375

Show
Ignore:
Timestamp:
10.10.2013 13:57:59 (6 years ago)
Author:
davidb
Message:

A set of changes to help Greenstone building code (perl) run under Cygwin. The test is designed to be mutually to when run natively on Windows. In effect the refined test is saying: if you're windows but not cygwin then do as you used to do for Windows, otherwise go with Unix (as Cygwin is effectively giving you a Unix like operating system to run in)

Location:
main/trunk/greenstone2/perllib
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/mgbuilder.pm

    r28215 r28375  
    139139 
    140140    my $osextra = ""; 
    141     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     141    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    142142    $fulltextprefix =~ s@/@\\@g; 
    143143    } else { 
     
    354354 
    355355    my $osextra = ""; 
    356     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     356    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    357357    $fullindexprefix =~ s@/@\\@g; 
    358358    } else { 
  • main/trunk/greenstone2/perllib/mgppbuilder.pm

    r28215 r28375  
    180180     
    181181    my $osextra = ""; 
    182     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     182    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    183183    $fulltextprefix =~ s@/@\\@g; 
    184184    }  
     
    419419 
    420420    my $osextra = ""; 
    421     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     421    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    422422    $fullindexprefix =~ s@/@\\@g; 
    423423    } else { 
  • main/trunk/greenstone2/perllib/plugins/BasePlugin.pm

    r27973 r28375  
    671671    print $outhandle "Calling method: $cfilename:$cline $cpackage->$csubr\n"; 
    672672 
    673  
    674673    my ($filemeta) = $file =~ /([^\\\/]+)$/; # getting the tail of the filepath (skips all string parts containing slashes upto the end) 
    675674    $filemeta = $self->filepath_to_utf8($filemeta, $file_encoding); 
     
    891890    # Win32::GetLongFilePath() -- then the underlying file system is UTF16 
    892891 
    893     if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 
     892    if (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin")) { 
    894893        # Can do better than working with the DOS character encoding returned by locale      
    895894        $deduced_filename_encoding = "unicode"; 
     
    963962    # abbreviated DOS form 
    964963 
    965     if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 
     964    if (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin")) { 
    966965    if ((defined $filename_encoding) && ($filename_encoding eq "unicode")) { 
    967966        if (-e $raw_filename) { 
  • main/trunk/greenstone2/perllib/util.pm

    r28236 r28375  
    149149    my $real_filename; 
    150150 
    151     if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 
     151    if (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin")) { 
    152152    require Win32; 
    153153 
     
    368368 
    369369    my $join_char; 
    370     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     370    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    371371    $join_char = ";"; 
    372372    } else { 
     
    377377 
    378378    # remove duplicate slashes 
    379     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     379    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    380380    $pathname =~ s/[\\\/]+/\\/g; 
    381381    } else { 
     
    412412 
    413413    # 64 bit linux can't handle ";" as path separator, so make sure to set this to the right one for the OS 
    414     my $pathsep = (defined $ENV{'GSDLOS'} && $ENV{'GSDLOS'} !~ m/windows/) ? ":" : ";"; 
     414##    my $pathsep = (defined $ENV{'GSDLOS'} && $ENV{'GSDLOS'} !~ m/windows/) ? ":" : ";"; 
     415 
     416    # Rewritten above to make ":" the default (Windows is the special 
     417    # case, anything else 'unusual' such as Solaris etc is Unix) 
     418    my $pathsep = (defined $ENV{'GSDLOS'} && (($ENV{'GSDLOS'} =~ m/windows/) && ($^O ne "cygwin"))) ? ";" : ":"; 
    415419 
    416420    # do not prepend any value/path that's already in the environment variable 
     
    462466    my ($base_dir, $file) = @_; 
    463467     
     468#    my ($cpackage,$cfilename,$cline,$csubr,$chas_args,$cwantarray) = caller(0); 
     469#    my ($lcfilename) = ($cfilename =~ m/([^\\\/]*)$/); 
     470#    print STDERR "** Calling method: $lcfilename:$cline $cpackage->$csubr\n"; 
     471 
     472 
    464473    my $filename_full_path = $file; 
    465474    # add on directory if present 
     
    477486    my $filename = shift(@_); 
    478487 
    479     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     488    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    480489    $filename =~ s/[^\\\\]*$//; 
    481490    } 
     
    561570{ 
    562571    my ($filepath) = @_; 
    563     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     572    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    564573        # Only need to worry about Windows, as Unix style directories already in url-format 
    565574        # Convert Windows style \ => / 
     
    573582{ 
    574583    my ($filepath) = @_; 
    575     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     584    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    576585    # Only need to worry about Windows, as Unix style directories already in url-format 
    577586    # Convert Windows style \\ => / 
     
    629638    my $filename_full_path = &FileUtils::filenameConcatenate($base_dir,$file); 
    630639 
    631     if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 
     640    if (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin")) { 
    632641    require Win32; 
    633642 
     
    651660    my ($filename_full_path,$and_encode) = @_; 
    652661 
    653     if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 
     662    if (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin")) { 
    654663    # Ensure any DOS-like filename, such as test~1.txt, has been upgraded 
    655664    # to its long (Windows) version 
     
    673682    my ($filename_full_path) = @_; 
    674683 
    675     if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 
     684    if (($ENV{'GSDLOS'} =~ m/^windows$/i) && ($^O ne "cygwin")) { 
    676685    require Win32; 
    677686 
     
    695704    my ($block_hash,$filename) = @_; 
    696705     
    697     if ($ENV{'GSDLOS'} =~ m/^windows$/) { 
     706    if (($ENV{'GSDLOS'} =~ m/^windows$/) && ($^O ne "cygwin")) { 
    698707     
    699708    # lower case the entire thing, eg for cover.jpg when its actually cover.JPG 
     
    755764sub get_dirsep { 
    756765 
    757     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     766    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    758767    return "\\"; 
    759768    } else { 
     
    764773sub get_os_dirsep { 
    765774 
    766     if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     775    if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")) { 
    767776    return "\\\\"; 
    768777    } else { 
     
    798807# .exe, otherwise they don't have to end in any extension 
    799808sub get_os_exe { 
    800     return ".exe" if $ENV{'GSDLOS'} =~ /^windows$/i; 
     809    return ".exe" if (($ENV{'GSDLOS'} =~ /^windows$/i) && ($^O ne "cygwin")); 
    801810    return ""; 
    802811} 
     
    11381147    #my $perl_command = "(cd $GSDLHOME; export GSDLHOME=; . ./setup.bash > /dev/null; env)"; 
    11391148    my $perl_command = "(cd $GSDLHOME; /bin/bash -c \"export GSDLHOME=; source setup.bash > /dev/null; env\")";      
    1140     if($GSDLOS =~ m/windows/i) { 
     1149    if (($GSDLOS =~ m/windows/i) && ($^O ne "cygwin")) { 
    11411150        #$perl_command = "cmd /C \"cd $GSDLHOME&& set GSDLHOME=&& setup.bat > nul&& set\""; 
    11421151        $perl_command = "(cd $GSDLHOME&& set GSDLHOME=&& setup.bat > nul&& set)"; 
     
    11691178    if($ENV{'PERLPATH'}) { 
    11701179        # OR: # $perl_exec = &FileUtils::filenameConcatenate($ENV{'PERLPATH'},"perl"); 
    1171         if($ENV{'GSDLOS'} =~ m/windows/) { 
     1180        if (($ENV{'GSDLOS'} =~ m/windows/) && ($^O ne "cygwin")) { 
    11721181            $perl_exec = "$ENV{'PERLPATH'}\\Perl.exe"; 
    11731182        } else {