author | Alan Coopersmith <Alan.Coopersmith@Oracle.COM> |
Thu, 06 Dec 2012 08:08:39 -0800 | |
changeset 1338 | 60f8357a54f4 |
parent 1147 | 54bcc6a673bf |
child 1614 | 546eae8fed25 |
permissions | -rwxr-xr-x |
1147
54bcc6a673bf
7054723 X consolidation should move to perl 5.12
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1078
diff
changeset
|
1 |
#! /usr/perl5/5.12/bin/perl |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
2 |
# |
1071
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
3 |
# Copyright (c) 2008, 2011, 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 |
# |
1071
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
29 |
# Usage: set-elf-comments.pl [-b] [-B <pkgversion>] -M "module version" \ |
994
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 |
|
1078
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
41 |
require 5.10.0; # needed for Time::Hires::stat |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
42 |
|
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
43 |
use strict; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
44 |
use warnings; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
45 |
use Getopt::Std; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
46 |
use POSIX qw(strftime); |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
47 |
use File::Find; |
1078
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
48 |
use Time::HiRes qw(); |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
49 |
|
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
50 |
$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
|
51 |
|
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
52 |
my %opts; |
1071
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
53 |
getopts('B:M:X:b', \%opts); |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
54 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
55 |
my $module_version_info = '@(#)'; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
56 |
if (exists($opts{'M'})) { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
57 |
$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
|
58 |
} else { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
59 |
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
|
60 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
61 |
|
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
62 |
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
|
63 |
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
|
64 |
$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
|
65 |
} |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
66 |
|
1071
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
67 |
if (exists($opts{'b'})) { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
68 |
# Add build info, including date & anything specified by -B |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
69 |
my $build_info = strftime("%e %b %Y", localtime); |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
70 |
|
1071
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
71 |
if (exists($opts{'B'})) { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
72 |
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
|
73 |
|
1071
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
74 |
if ($build_version_file eq 'hg id') { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
75 |
my $hg_id = 'revision unavailable'; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
76 |
if (exists $ENV{'XBUILD_HG_ID'}) { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
77 |
$hg_id = $ENV{'XBUILD_HG_ID'}; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
78 |
} else { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
79 |
open my $VERS, '-|', $build_version_file |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
80 |
or die "Can't run $build_version_file: $!\n"; |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
81 |
|
1071
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
82 |
while ($_ = <$VERS>) { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
83 |
chomp($_); |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
84 |
if ($_ =~ m/\S+/) { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
85 |
my ($rev, $tag) = split(' ', $_, 2); |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
86 |
if ($tag eq 'tip') { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
87 |
$hg_id = $rev; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
88 |
} else { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
89 |
$hg_id = $_; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
90 |
} |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
91 |
} |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
92 |
} |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
93 |
close $VERS; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
94 |
} |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
95 |
$build_info = "hg: $hg_id - $build_info"; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
96 |
} else { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
97 |
open my $VERS, '<', $build_version_file |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
98 |
or die "Can't open $build_version_file for reading: $!\n"; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
99 |
|
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
100 |
while ($_ = <$VERS>) { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
101 |
if ($_ =~ m/^BUILD="(.*)"/) { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
102 |
my $v = $1 / 100.0; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
103 |
if ($v >= 1.0) { |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
104 |
$build_info = "build $v - " . $build_info; |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
105 |
} |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
106 |
} |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
107 |
} |
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
108 |
close $VERS; |
906
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
109 |
} |
4c633d8c519b
6927451 X gate build scripts & Makefiles need adjustments for hg master gate
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
591
diff
changeset
|
110 |
} |
1071
79918bb93075
7019195 stop embedding hg id/tag & build date in mcs information in X
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
994
diff
changeset
|
111 |
$module_version_info .= " ($build_info)"; |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
112 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
113 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
114 |
$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
|
115 |
|
1078
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
116 |
my %elf_files; |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
117 |
|
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
118 |
sub scan_file { |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
119 |
# 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
|
120 |
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
|
121 |
|
994
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
122 |
# 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
|
123 |
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
|
124 |
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
|
125 |
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
|
126 |
return; |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
127 |
} |
ebd9341332ef
6975153 libfreetype.so.6 does not contain correct mcs version info
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
970
diff
changeset
|
128 |
} |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
129 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
130 |
# 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
|
131 |
if ((! -l $_) && (-f _) && (-s _ > 256)) { |
1078
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
132 |
open my $IN, '<', $_ |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
133 |
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
|
134 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
135 |
my $magic_number; |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
136 |
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
|
137 |
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
|
138 |
|
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
139 |
close $IN; |
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 |
if ($magic_number eq "\177ELF") { |
1078
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
142 |
my @sb = Time::HiRes::stat($_); |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
143 |
$elf_files{$File::Find::name} = $sb[9]; # mtime |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
144 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
145 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
146 |
} |
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
147 |
|
1078
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
148 |
find(\&scan_file, @ARGV); |
591
a2c6b61a92aa
6777135 X builds should record version info in ELF comments
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
149 |
|
1078
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
150 |
if (scalar(keys %elf_files) > 0) { |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
151 |
my @filelist = sort { $elf_files{$a} <=> $elf_files{$b} } keys %elf_files; |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
152 |
|
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
153 |
my @cmd = ('/usr/bin/mcs', '-a', $module_version_info, '-c', @filelist); |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
154 |
|
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
155 |
print join(' ', map { if ($_ =~ /\s+/) { qq("$_") } else { $_ } } @cmd), |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
156 |
"\n"; |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
157 |
system(@cmd) == 0 |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
158 |
or die "*** mcs failed: $?\n"; |
7f847d8722f1
7022271 set-elf-comments.pl can induce race conditions in X gate builds
Alan Coopersmith <Alan.Coopersmith@Oracle.COM>
parents:
1071
diff
changeset
|
159 |
} |