-
Notifications
You must be signed in to change notification settings - Fork 138
/
install_files.pl
225 lines (187 loc) · 6.14 KB
/
install_files.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#! perl
################################################################################
# Copyright (C) 2001-2009, Parrot Foundation.
################################################################################
=head1 NAME
tools/dev/install_files.pl - Copy files to their correct locations
=head1 SYNOPSIS
% perl tools/dev/install_files.pl [options]
=head1 DESCRIPTION
Use a detailed MANIFEST to install a set of files.
=head2 Options
=over 4
=item C<buildprefix>
The build prefix. Defaults to ''.
=item C<prefix>
The install prefix. Defaults to '/usr'.
=item C<exec_prefix>
The exec prefix. Defaults to '/usr'.
=item C<bindir>
The executables directory. Defaults to '/usr/bin'.
=item C<libdir>
The library directory. Defaults to '/usr/lib'.
=item C<includedir>
The header directory. Defaults to '/usr/include'.
=back
=head1 SEE ALSO
See F<lib/Parrot/Manifest.pm> for a detailed description of the MANIFEST
format.
F<tools/dev/mk_manifests.pl>
=cut
################################################################################
use strict;
use warnings;
use File::Basename qw(basename);
use lib qw( lib );
use Parrot::Install qw(
install_files
create_directories
lines_to_files
);
# When run from the makefile, which is probably the only time this
# script will ever be used, all of these defaults will get overridden.
my %options = (
buildprefix => '',
prefix => '/usr',
destdir => '',
exec_prefix => '/usr',
bindir => '/usr/bin',
libdir => '/usr/lib', # parrot/ subdir added below
includedir => '/usr/include', # parrot/ subdir added below
docdir => '/usr/share/doc', # parrot/ subdir added below
versiondir => '',
'dry-run' => 0,
packages => 'main|library|pge',
);
my @manifests;
foreach (@ARGV) {
if (/^--([^=]+)=(.*)/) {
$options{$1} = $2;
}
else {
push @manifests, $_;
}
}
my $parrotdir = $options{versiondir};
# Set up transforms on filenames
my(@transformorder) = qw(lib bin include doc pkgconfig ^compilers);
my(%metatransforms) = (
lib => {
ismeta => 1,
optiondir => 'lib',
transform => sub {
my($filehash) = @_;
local($_) = $filehash->{Dest};
if ( /^install_config\.fpmc/ ) {
s/^install_//; # parrot with different config
$filehash->{DestDirs} = [$parrotdir, 'include'];
$filehash->{Dest} = $_;
}
elsif ( /install_config/ ) {
s/install_config/parrot_config/;
s/^src//; # strip off leading src/ dir
$filehash->{DestDirs} = [$parrotdir];
$filehash->{Dest} = $_;
}
else {
# don't allow libraries to be installed into subdirs of libdir
$filehash->{Dest} = basename($_);
}
return($filehash);
},
},
bin => {
ismeta => 1,
optiondir => 'bin',
transform => sub {
my($filehash) = @_;
# parrot with different config
$filehash->{Installable} = $filehash->{Dest} =~ s/^installable_//;
return($filehash);
},
isbin => 1,
},
include => {
ismeta => 1,
optiondir => 'include',
transform => sub {
my($filehash) = @_;
$filehash->{Dest} =~ s/^include//;
$filehash->{DestDirs} = [$parrotdir];
return($filehash);
},
},
doc => {
ismeta => 1,
optiondir => 'doc',
transform => sub {
my($filehash) = @_;
$filehash->{DestDirs} = [$parrotdir];
return($filehash);
},
},
pkgconfig => {
ismeta => 1,
optiondir => 'lib',
transform => sub {
my($filehash) = @_;
# For the time being this is hardcoded as being installed under
# libdir as it is typically done with automake installed packages.
# If the --pkgconfigdir option is used, then the default value will
# be overwritten with the specified subdirectory under libdir.
$filehash->{DestDirs} = ['pkgconfig', $parrotdir];
$filehash->{DestDirs} = [$options{pkgconfigdir}]
if $options{pkgconfigdir};
return($filehash);
},
},
'^compilers' => {
optiondir => 'lib',
transform => sub {
my($filehash) = @_;
$filehash->{Dest} =~ s/^compilers/languages/;
$filehash->{DestDirs} = [$parrotdir];
return($filehash);
},
},
);
my($filehashes, $directories) = lines_to_files(
\%metatransforms, \@transformorder, \@manifests, \%options, $parrotdir
);
unless ( $options{'dry-run'} ) {
create_directories($options{destdir}, $directories);
}
# TT #347
# 1. skip build_dir-only binaries for files marked Installable
my($filehash, @removes, $removes);
foreach $filehash (grep { $_->{Installable} } @$filehashes) {
my( $src, $dest ) = map { $filehash->{$_} } qw(Source Dest);
my ($file) = $src =~ /installable_(.+)$/;
next unless $file;
if((grep { $_->{Source} =~ /^$file$/ } @$filehashes) and -e $file) {
print "skipping $file, using installable_$file instead\n";
push @removes, $file;
}
}
$removes = join '|', @removes;
@$filehashes = grep { $_->{Source} !~ /^($removes)$/ } @$filehashes;
# 2. for every .exe check if there's an installable. Fail if not
my $i;
foreach $filehash (grep { ! $_->{Installable} } @$filehashes ) {
my( $src, $dest ) = map { $filehash->{$_} } qw(Source Dest);
next unless $src =~ /\.exe$/;
# This logic will fail on non-win32 if the generated files are really
# generated as with rt #40817. We don't have [main]bin here.
$i = "installable_$src";
unless (map {$_->{Source} =~ /^$i$/} grep { $_->{Installable} } @$filehashes) {
die "$i is missing in MANIFEST or MANIFEST.generated\n";
}
}
install_files($options{destdir}, $options{'dry-run'}, $filehashes);
print "Finished install_files.pl\n";
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: