Skip to content

Commit d6a5ac4

Browse files
committed
autogen: use newer config.sub|guess if available
Per #8410, have autogen.pl check each config.sub and config.guess that it finds with a known-good version of that file if the known-good version has a timestamp version that is newer than what Autoconf installed. We also skip updating anything in the 3rd-party tree; we don't really want to mess with those packages. Signed-off-by: Jeff Squyres <[email protected]> (cherry picked from commit 4a002ce)
1 parent e51abf5 commit d6a5ac4

File tree

2 files changed

+106
-3
lines changed

2 files changed

+106
-3
lines changed

autogen.pl

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env perl
22
#
3-
# Copyright (c) 2009-2020 Cisco Systems, Inc. All rights reserved
3+
# Copyright (c) 2009-2021 Cisco Systems, Inc. All rights reserved
44
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
55
# Copyright (c) 2013 Mellanox Technologies, Inc.
66
# All rights reserved.
@@ -1137,6 +1137,102 @@ sub in_tarball {
11371137
return $tarball;
11381138
}
11391139

1140+
##############################################################################
1141+
1142+
sub replace_config_sub_guess {
1143+
# This could be simpler if we could use some Perl modules for this
1144+
# functionality (e.g., DateTime). But I don't want to introduce
1145+
# any CPAN dependencies here, so just do sometime simple, even if
1146+
# it's a bit laborious. Use a few private helper functions for
1147+
# this kind of functionality.
1148+
1149+
sub _get_timestamp {
1150+
my $filename = shift;
1151+
1152+
my $ret;
1153+
if (-x $filename) {
1154+
my $out = `$filename --version`;
1155+
$out =~ m/GNU config\.[a-z]+ \((.+)\)/;
1156+
$ret = $1;
1157+
}
1158+
1159+
return $ret;
1160+
}
1161+
1162+
sub _split_timestamp {
1163+
my $ts = shift;
1164+
1165+
$ts =~ m/(\d+)-(\d+)-(\d+)/;
1166+
return $1, $2, $3;
1167+
}
1168+
1169+
# Returns true if timestamp $a > timestamp $b.
1170+
sub _timestamp_gt {
1171+
my ($a, $b) = @_;
1172+
1173+
my ($year_a, $month_a, $day_a) = _split_timestamp($a);
1174+
my ($year_b, $month_b, $day_b) = _split_timestamp($b);
1175+
1176+
# Don't try to be clever -- just do a simple set of explicit
1177+
# comparisons.
1178+
if ($year_a > $year_b) {
1179+
return 1;
1180+
} elsif ($year_a < $year_b) {
1181+
return 0;
1182+
} else {
1183+
if ($month_a > $month_b) {
1184+
return 1;
1185+
} elsif ($month_a < $month_b) {
1186+
return 0;
1187+
} else {
1188+
if ($day_a > $day_b) {
1189+
return 1;
1190+
} else {
1191+
return 0;
1192+
}
1193+
}
1194+
}
1195+
}
1196+
1197+
my ($topdir) = @_;
1198+
1199+
# Find the stashed known-good files, and get their version
1200+
# timestamps.
1201+
my $cached_dir = "$topdir/config/from-savannah";
1202+
my @files = qw/config.guess config.sub/;
1203+
my %known_good_timestamps;
1204+
foreach my $file (@files) {
1205+
my $filename = "$cached_dir/upstream-$file";
1206+
my_die("Cannot find $filename")
1207+
if (! -f $filename);
1208+
1209+
my $ts = _get_timestamp($filename);
1210+
$known_good_timestamps{$file} = $ts;
1211+
}
1212+
1213+
# Find all config.guess/config.sub files in the tree. If their
1214+
# versions are older than the stashed known-good files, update
1215+
# them from the stash.
1216+
my @files;
1217+
File::Find::find(sub {
1218+
push(@files, $File::Find::name)
1219+
if ($_ eq "config.guess" ||
1220+
$_ eq "config.sub") }, $topdir);
1221+
1222+
foreach my $file (@files) {
1223+
# Skip anything in the 3rd-party tree
1224+
next
1225+
if ($file =~ /\/3rd-party\//);
1226+
1227+
my $base = basename($file);
1228+
my $ts = _get_timestamp($file);
1229+
if (_timestamp_gt($known_good_timestamps{$base}, $ts)) {
1230+
print("=== Replacing $file with newer version\n");
1231+
safe_system("cp -f $cached_dir/upstream-$base $file");
1232+
}
1233+
}
1234+
}
1235+
11401236
##############################################################################
11411237
##############################################################################
11421238
## main - do the real work...
@@ -1458,6 +1554,11 @@ sub in_tarball {
14581554

14591555
patch_autotools_output(".");
14601556

1557+
# Per https://github.com/open-mpi/ompi/issues/8410, replace config.sub
1558+
# and config.guess with known-good versions if the Autoconf-installed
1559+
# versions are older.
1560+
replace_config_sub_guess(".");
1561+
14611562
#---------------------------------------------------------------------------
14621563

14631564
verbose "

config/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# University of Stuttgart. All rights reserved.
1010
# Copyright (c) 2004-2005 The Regents of the University of California.
1111
# All rights reserved.
12-
# Copyright (c) 2006-2018 Cisco Systems, Inc. All rights reserved.
12+
# Copyright (c) 2006-2021 Cisco Systems, Inc. All rights reserved.
1313
# Copyright (c) 2010 Oracle and/or its affiliates. All rights
1414
# reserved.
1515
# Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
@@ -30,7 +30,9 @@ EXTRA_DIST = \
3030
opal_mca_priority_sort.pl \
3131
find_common_syms \
3232
getdate.sh \
33-
make_manpage.pl
33+
make_manpage.pl \
34+
from-savannah/upstream-config.guess \
35+
from-savannah/upstream-config.sub
3436

3537
maintainer-clean-local:
3638
rm -f opal_get_version.sh

0 commit comments

Comments
 (0)