Skip to content

Commit

Permalink
autogen.pl: sanity check for git submodules
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
  • Loading branch information
jsquyres committed Dec 24, 2019
1 parent b814ff7 commit c82c39d
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions autogen.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,54 @@ sub in_tarball {

#---------------------------------------------------------------------------

++$step;
verbose "\n$step. Checking for git submodules\n\n";

# Make sure we got a submodule-full clone. If not, abort and let a
# human figure it out.
if (-f ".gitmodules") {
open(IN, "git submodule status|")
|| die "Can't run \"git submodule status\"";
while (<IN>) {
chomp;
$_ =~ m/^(.)(.{40}) ([^ ]+) *\(*([^\(\)]*)\)*$/;
my $status = $1;
my $local_hash = $2;
my $path = $3;
my $extra = $4;

print("=== Submodule: $path\n");

# Make sure the submodule is there
if ($status eq "-") {
print(" ==> ERROR: Missing
The submodule \"$path\" is missing.
Perhaps you forgot to \"git clone --recursive ...\", or you need to
\"git submodule update --init --recursive\"...?\n\n");
exit(1);
}

# See if the submodule is at the expected git hash
# (it may be ok if it's not -- just warn the user)
$extra =~ m/-g(.+)/;
my $remote_hash = $1;
if ($remote_hash) {
my $abbrev_local_hash = substr($local_hash, 0, length($remote_hash));
if ($remote_hash ne $abbrev_local_hash) {
print(" ==> WARNING: Submodule hash is different than upstream.
If this is not intentional, you may want to run:
\"git submodule update --init --recursive\"\n");
} else {
print(" Local hash == remote hash (good!)\n");
}
}
}
}

#---------------------------------------------------------------------------

# Save the platform file in the m4
$m4 .= "dnl Platform file\n";

Expand Down

0 comments on commit c82c39d

Please sign in to comment.