Skip to content

Commit 576b890

Browse files
committed
Replace calls to external dir program with perlish globs and File::Find
calls. Fixes complaint fron Hannes Eder, whose environment found a different dir program.
1 parent 90c156f commit 576b890

File tree

1 file changed

+38
-31
lines changed

1 file changed

+38
-31
lines changed

src/tools/msvc/Install.pm

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package Install;
33
#
44
# Package that provides 'make install' functionality for msvc builds
55
#
6-
# $PostgreSQL: pgsql/src/tools/msvc/Install.pm,v 1.19 2007/09/12 13:58:23 mha Exp $
6+
# $PostgreSQL: pgsql/src/tools/msvc/Install.pm,v 1.20 2007/09/22 20:38:10 adunstan Exp $
77
#
88
use strict;
99
use warnings;
1010
use Carp;
1111
use File::Basename;
1212
use File::Copy;
13+
use File::Find ();
1314

1415
use Exporter;
1516
our (@ISA,@EXPORT_OK);
@@ -43,20 +44,31 @@ sub Install
4344

4445
CopySolutionOutput($conf, $target);
4546
copy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
46-
CopySetOfFiles('config files', "*.sample", $target . '/share/');
47+
my $sample_files = [];
48+
File::Find::find({wanted =>
49+
sub { /^.*\.sample\z/s &&
50+
push(@$sample_files, $File::Find::name);
51+
}
52+
},
53+
"../.." );
54+
CopySetOfFiles('config files', $sample_files , $target . '/share/');
4755
CopyFiles(
4856
'Import libraries',
4957
$target .'/lib/',
5058
"$conf\\", "postgres\\postgres.lib","libpq\\libpq.lib", "libecpg\\libecpg.lib", "libpgport\\libpgport.lib"
5159
);
52-
CopySetOfFiles('timezone names', 'src\timezone\tznames\*.txt',$target . '/share/timezonesets/');
60+
CopySetOfFiles('timezone names',
61+
[ glob('src\timezone\tznames\*.txt') ] ,
62+
$target . '/share/timezonesets/');
5363
CopyFiles(
5464
'timezone sets',
5565
$target . '/share/timezonesets/',
5666
'src/timezone/tznames/', 'Default','Australia','India'
5767
);
58-
CopySetOfFiles('BKI files', "src\\backend\\catalog\\postgres.*", $target .'/share/');
59-
CopySetOfFiles('SQL files', "src\\backend\\catalog\\*.sql", $target . '/share/');
68+
CopySetOfFiles('BKI files', [ glob("src\\backend\\catalog\\postgres.*") ],
69+
$target .'/share/');
70+
CopySetOfFiles('SQL files', [ glob("src\\backend\\catalog\\*.sql") ],
71+
$target . '/share/');
6072
CopyFiles(
6173
'Information schema data',
6274
$target . '/share/',
@@ -65,8 +77,12 @@ sub Install
6577
GenerateConversionScript($target);
6678
GenerateTimezoneFiles($target,$conf);
6779
GenerateTsearchFiles($target);
68-
CopySetOfFiles('Stopword files', "src\\backend\\snowball\\stopwords\\*.stop", $target . '/share/tsearch_data/');
69-
CopySetOfFiles('Dictionaries sample files', "src\\backend\\tsearch\\\*_sample.*", $target . '/share/tsearch_data/');
80+
CopySetOfFiles('Stopword files',
81+
[ glob ("src\\backend\\snowball\\stopwords\\*.stop") ],
82+
$target . '/share/tsearch_data/');
83+
CopySetOfFiles('Dictionaries sample files',
84+
[ glob ("src\\backend\\tsearch\\\*_sample.*" ) ],
85+
$target . '/share/tsearch_data/');
7086
CopyContribFiles($config,$target);
7187
CopyIncludeFiles($target);
7288

@@ -106,26 +122,17 @@ sub CopyFiles
106122
sub CopySetOfFiles
107123
{
108124
my $what = shift;
109-
my $spec = shift;
125+
my $flist = shift;
110126
my $target = shift;
111-
my $silent = shift;
112-
my $norecurse = shift;
113-
my $D;
114-
115-
my $subdirs = $norecurse?'':'/s';
116-
print "Copying $what" unless ($silent);
117-
open($D, "dir /b $subdirs $spec |") || croak "Could not list $spec\n";
118-
while (<$D>)
127+
print "Copying $what" if $what;
128+
foreach (@$flist)
119129
{
120-
chomp;
121130
next if /regress/; # Skip temporary install in regression subdir
122131
next if /ecpg.test/; # Skip temporary install in regression subdir
123132
my $tgt = $target . basename($_);
124133
print ".";
125-
my $src = $norecurse?(dirname($spec) . '/' . $_):$_;
126-
copy($src, $tgt) || croak "Could not copy $src: $!\n";
134+
copy($_, $tgt) || croak "Could not copy $_: $!\n";
127135
}
128-
close($D);
129136
print "\n";
130137
}
131138

@@ -375,7 +382,9 @@ sub CopyIncludeFiles
375382
$target . '/include/server/',
376383
'src/include/', 'pg_config.h', 'pg_config_os.h'
377384
);
378-
CopySetOfFiles('', "src\\include\\*.h", $target . '/include/server/', 1, 1);
385+
CopySetOfFiles('',
386+
[ glob( "src\\include\\*.h" ) ],
387+
$target . '/include/server/');
379388
my $D;
380389
opendir($D, 'src/include') || croak "Could not opendir on src/include!\n";
381390

@@ -419,21 +428,21 @@ sub GenerateNLSFiles
419428

420429
print "Installing NLS files...";
421430
EnsureDirectories($target, "share/locale");
422-
open($D,"dir /b /s nls.mk|") || croak "Could not list nls.mk\n";
423-
while (<$D>)
431+
my @flist;
432+
File::Find::find({wanted =>
433+
sub { /^nls\.mk\z/s &&
434+
! push(@flist, $File::Find::name);
435+
}
436+
}, ".");
437+
foreach (@flist)
424438
{
425-
chomp;
426439
s/nls.mk/po/;
427440
my $dir = $_;
428441
next unless ($dir =~ /([^\\]+)\\po$/);
429442
my $prgm = $1;
430443
$prgm = 'postgres' if ($prgm eq 'backend');
431-
my $E;
432-
open($E,"dir /b $dir\\*.po|") || croak "Could not list contents of $_\n";
433-
434-
while (<$E>)
444+
foreach (glob("$dir/*.po"))
435445
{
436-
chomp;
437446
my $lang;
438447
next unless /^(.*)\.po/;
439448
$lang = $1;
@@ -445,9 +454,7 @@ sub GenerateNLSFiles
445454
&& croak("Could not run msgfmt on $dir\\$_");
446455
print ".";
447456
}
448-
close($E);
449457
}
450-
close($D);
451458
print "\n";
452459
}
453460

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy