author | Alan Coopersmith <Alan.Coopersmith@Oracle.COM> |
Fri, 05 Nov 2010 18:28:04 -0700 | |
changeset 1038 | d00846ec141b |
parent 994 | ebd9341332ef |
child 1071 | 79918bb93075 |
permissions | -rwxr-xr-x |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
1 |
#! /usr/perl5/bin/perl |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
2 |
# |
943
294f64612d23
6948254 Mass update of X gate sources to Oracle copyright format
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
919
diff
changeset
|
3 |
# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
4 |
# |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
5 |
# Permission is hereby granted, free of charge, to any person obtaining a |
919
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
6 |
# copy of this software and associated documentation files (the "Software"), |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
7 |
# to deal in the Software without restriction, including without limitation |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
8 |
# the rights to use, copy, modify, merge, publish, distribute, sublicense, |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
9 |
# and/or sell copies of the Software, and to permit persons to whom the |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
10 |
# Software is furnished to do so, subject to the following conditions: |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
11 |
# |
919
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
12 |
# The above copyright notice and this permission notice (including the next |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
13 |
# paragraph) shall be included in all copies or substantial portions of the |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
14 |
# Software. |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
15 |
# |
919
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
16 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
17 |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
18 |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
19 |
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
20 |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
21 |
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
425233ae7236
6931307 Standardize Sun copyright & license notices in X gate on current format
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
907
diff
changeset
|
22 |
# DEALINGS IN THE SOFTWARE. |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
23 |
# |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
24 |
# |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
25 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
26 |
# |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
27 |
# Set version information in ELF files to give hints to help in troubleshooting |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
28 |
# |
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
29 |
# Usage: set-elf-comments.pl [-B <pkgversion>] -M "module version" \ |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
30 |
# [-X <exclude regexp>] <path> |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
31 |
# |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
32 |
# <pkgversion> may either be a path to a file containing BUILD="<version>" |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
33 |
# or the string "hg id" to get the version from the hg id output. |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
34 |
# |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
35 |
# If the XBUILD_HG_ID environment variable is set, it is used for the hg id |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
36 |
# instead of forking a hg id process for every component in a full tree build |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
37 |
# |
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
38 |
# If -X is specified, it gives a regular expresion for filenames to skip |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
39 |
# for this module. |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
40 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
41 |
use strict; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
42 |
use warnings; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
43 |
use Getopt::Std; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
44 |
use POSIX qw(strftime); |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
45 |
use File::Find; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
46 |
|
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
47 |
$Getopt::Std::STANDARD_HELP_VERSION = 1; |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
48 |
|
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
49 |
my %opts; |
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
50 |
getopts('B:M:X:', \%opts); |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
51 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
52 |
my $module_version_info = '@(#)'; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
53 |
if (exists($opts{'M'})) { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
54 |
$module_version_info .= $opts{'M'}; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
55 |
} else { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
56 |
die qq(Must specify -M "module version"); |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
57 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
58 |
|
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
59 |
my $exclude_regexp; |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
60 |
if (exists($opts{'X'})) { |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
61 |
$exclude_regexp = $opts{'X'}; |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
62 |
} |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
63 |
|
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
64 |
my $build_info = strftime("%e %b %Y", localtime); |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
65 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
66 |
if (exists($opts{'B'})) { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
67 |
my $build_version_file = $opts{'B'}; |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
68 |
|
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
69 |
if ($build_version_file eq 'hg id') { |
970
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
70 |
my $hg_id = 'revision unavailable'; |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
71 |
if (exists $ENV{'XBUILD_HG_ID'}) { |
970
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
72 |
$hg_id = $ENV{'XBUILD_HG_ID'}; |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
73 |
} else { |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
74 |
open my $VERS, '-|', $build_version_file |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
75 |
or die "Can't run $build_version_file: $!\n"; |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
76 |
|
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
77 |
while ($_ = <$VERS>) { |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
78 |
chomp($_); |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
79 |
if ($_ =~ m/\S+/) { |
970
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
80 |
my ($rev, $tag) = split(' ', $_, 2); |
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
81 |
if ($tag eq 'tip') { |
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
82 |
$hg_id = $rev; |
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
83 |
} else { |
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
84 |
$hg_id = $_; |
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
85 |
} |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
86 |
} |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
87 |
} |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
88 |
close $VERS; |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
89 |
} |
970
272328fe1b4a
6941932 X should be able to build IPS packages natively
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
943
diff
changeset
|
90 |
$build_info = "hg: $hg_id - $build_info"; |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
91 |
} else { |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
92 |
open my $VERS, '<', $build_version_file |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
93 |
or die "Can't open $build_version_file for reading: $!\n"; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
94 |
|
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
95 |
while ($_ = <$VERS>) { |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
96 |
if ($_ =~ m/^BUILD="(.*)"/) { |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
97 |
my $v = $1 / 100.0; |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
98 |
if ($v >= 1.0) { |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
99 |
$build_info = "build $v - " . $build_info; |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
100 |
} |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
101 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
102 |
} |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
103 |
close $VERS; |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
104 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
105 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
106 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
107 |
$module_version_info .= " ($build_info)"; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
108 |
$module_version_info =~ s/\s+$//ms; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
109 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
110 |
sub scan_file { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
111 |
# skip sources & intermediate build files that we don't ship |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
112 |
return if $_ =~ m/\.[acho]$/ims; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
113 |
|
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
114 |
# skip files matching specified regexp |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
115 |
if (defined $exclude_regexp) { |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
116 |
if ($_ =~ m{$exclude_regexp}so) { |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
117 |
print "Excluding $_\n"; |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
118 |
return; |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
119 |
} |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
120 |
} |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
121 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
122 |
# If the file is not a symlink, is a regular file, and is at least 256 bytes |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
123 |
if ((! -l $_) && (-f _) && (-s _ > 256)) { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
124 |
open my $IN, '<', $_ |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
125 |
or die "Can't open $_ for reading: $!\n"; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
126 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
127 |
my $magic_number; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
128 |
sysread($IN, $magic_number, 4) |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
129 |
or die "Can't read from $_: $!\n"; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
130 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
131 |
close $IN; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
132 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
133 |
if ($magic_number eq "\177ELF") { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
134 |
my @cmd = ('/usr/bin/mcs', '-a', $module_version_info, '-c', $_); |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
135 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
136 |
print join(' ', @cmd), "\n"; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
137 |
system(@cmd) == 0 |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
138 |
or die "*** mcs $File::Find::name failed: $?\n"; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
139 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
140 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
141 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
142 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
143 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
144 |
find(\&scan_file, @ARGV); |