|
1 | 1 | #!/usr/bin/env perl
|
2 | 2 | #
|
3 |
| -# Copyright (c) 2009-2019 Cisco Systems, Inc. All rights reserved |
| 3 | +# Copyright (c) 2009-2021 Cisco Systems, Inc. All rights reserved |
4 | 4 | # Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
5 | 5 | # Copyright (c) 2013 Mellanox Technologies, Inc.
|
6 | 6 | # All rights reserved.
|
@@ -1149,6 +1149,102 @@ sub in_tarball {
|
1149 | 1149 | return $tarball;
|
1150 | 1150 | }
|
1151 | 1151 |
|
| 1152 | +############################################################################## |
| 1153 | + |
| 1154 | +sub replace_config_sub_guess { |
| 1155 | + # This could be simpler if we could use some Perl modules for this |
| 1156 | + # functionality (e.g., DateTime). But I don't want to introduce |
| 1157 | + # any CPAN dependencies here, so just do sometime simple, even if |
| 1158 | + # it's a bit laborious. Use a few private helper functions for |
| 1159 | + # this kind of functionality. |
| 1160 | + |
| 1161 | + sub _get_timestamp { |
| 1162 | + my $filename = shift; |
| 1163 | + |
| 1164 | + my $ret; |
| 1165 | + if (-x $filename) { |
| 1166 | + my $out = `$filename --version`; |
| 1167 | + $out =~ m/GNU config\.[a-z]+ \((.+)\)/; |
| 1168 | + $ret = $1; |
| 1169 | + } |
| 1170 | + |
| 1171 | + return $ret; |
| 1172 | + } |
| 1173 | + |
| 1174 | + sub _split_timestamp { |
| 1175 | + my $ts = shift; |
| 1176 | + |
| 1177 | + $ts =~ m/(\d+)-(\d+)-(\d+)/; |
| 1178 | + return $1, $2, $3; |
| 1179 | + } |
| 1180 | + |
| 1181 | + # Returns true if timestamp $a > timestamp $b. |
| 1182 | + sub _timestamp_gt { |
| 1183 | + my ($a, $b) = @_; |
| 1184 | + |
| 1185 | + my ($year_a, $month_a, $day_a) = _split_timestamp($a); |
| 1186 | + my ($year_b, $month_b, $day_b) = _split_timestamp($b); |
| 1187 | + |
| 1188 | + # Don't try to be clever -- just do a simple set of explicit |
| 1189 | + # comparisons. |
| 1190 | + if ($year_a > $year_b) { |
| 1191 | + return 1; |
| 1192 | + } elsif ($year_a < $year_b) { |
| 1193 | + return 0; |
| 1194 | + } else { |
| 1195 | + if ($month_a > $month_b) { |
| 1196 | + return 1; |
| 1197 | + } elsif ($month_a < $month_b) { |
| 1198 | + return 0; |
| 1199 | + } else { |
| 1200 | + if ($day_a > $day_b) { |
| 1201 | + return 1; |
| 1202 | + } else { |
| 1203 | + return 0; |
| 1204 | + } |
| 1205 | + } |
| 1206 | + } |
| 1207 | + } |
| 1208 | + |
| 1209 | + my ($topdir) = @_; |
| 1210 | + |
| 1211 | + # Find the stashed known-good files, and get their version |
| 1212 | + # timestamps. |
| 1213 | + my $cached_dir = "$topdir/config/from-savannah"; |
| 1214 | + my @files = qw/config.guess config.sub/; |
| 1215 | + my %known_good_timestamps; |
| 1216 | + foreach my $file (@files) { |
| 1217 | + my $filename = "$cached_dir/upstream-$file"; |
| 1218 | + my_die("Cannot find $filename") |
| 1219 | + if (! -f $filename); |
| 1220 | + |
| 1221 | + my $ts = _get_timestamp($filename); |
| 1222 | + $known_good_timestamps{$file} = $ts; |
| 1223 | + } |
| 1224 | + |
| 1225 | + # Find all config.guess/config.sub files in the tree. If their |
| 1226 | + # versions are older than the stashed known-good files, update |
| 1227 | + # them from the stash. |
| 1228 | + my @files; |
| 1229 | + File::Find::find(sub { |
| 1230 | + push(@files, $File::Find::name) |
| 1231 | + if ($_ eq "config.guess" || |
| 1232 | + $_ eq "config.sub") }, $topdir); |
| 1233 | + |
| 1234 | + foreach my $file (@files) { |
| 1235 | + # Skip anything in the 3rd-party tree |
| 1236 | + next |
| 1237 | + if ($file =~ /\/3rd-party\//); |
| 1238 | + |
| 1239 | + my $base = basename($file); |
| 1240 | + my $ts = _get_timestamp($file); |
| 1241 | + if (_timestamp_gt($known_good_timestamps{$base}, $ts)) { |
| 1242 | + print("=== Replacing $file with newer version\n"); |
| 1243 | + safe_system("cp -f $cached_dir/upstream-$base $file"); |
| 1244 | + } |
| 1245 | + } |
| 1246 | +} |
| 1247 | + |
1152 | 1248 | ##############################################################################
|
1153 | 1249 | ##############################################################################
|
1154 | 1250 | ## main - do the real work...
|
@@ -1590,6 +1686,11 @@ sub in_tarball {
|
1590 | 1686 |
|
1591 | 1687 | patch_autotools_output(".");
|
1592 | 1688 |
|
| 1689 | +# Per https://github.com/open-mpi/ompi/issues/8410, replace config.sub |
| 1690 | +# and config.guess with known-good versions if the Autoconf-installed |
| 1691 | +# versions are older. |
| 1692 | +replace_config_sub_guess("."); |
| 1693 | + |
1593 | 1694 | #---------------------------------------------------------------------------
|
1594 | 1695 |
|
1595 | 1696 | verbose "
|
|
0 commit comments