@@ -1397,42 +1397,81 @@ sub replace_config_sub_guess {
1397
1397
# Make sure we got a submodule-full clone. If not, abort and let a
1398
1398
# human figure it out.
1399
1399
if (-f " .gitmodules" ) {
1400
- open (IN, " git submodule status|" )
1401
- || die " Can't run \" git submodule status\" " ;
1400
+ # Do a quick sanity check to ensure that non-3rd-party
1401
+ # submodules are at least present (e.g., they won't be present
1402
+ # if you downloaded a GitHub.com-created tarball).
1403
+ open (IN, " .gitmodules" ) ||
1404
+ die " Can't open .gitmodules" ;
1402
1405
while (<IN>) {
1403
- $_ =~ m / ^(.)[0-9a-f] {40}\s +(\S +)/ ;
1404
- my $status = $1 ;
1405
- my $path = $2 ;
1406
-
1407
- print (" === Submodule: $path \n " );
1408
- if (index ($path , " pmix" ) != -1 and list_contains(" pmix" , @disabled_3rdparty_packages )) {
1409
- print (" Disabled - skipping openpmix" );
1410
- next ;
1406
+ # Find "path = " lines
1407
+ if (!($_ =~ m / ^\s +path = (.+)$ / )) {
1408
+ next ;
1409
+ }
1410
+ my $path = $1 ;
1411
+
1412
+ # Only care about paths that do not include "3rd-party"
1413
+ if (index ($path , " 3rd-party" ) != -1) {
1414
+ next ;
1415
+ }
1416
+
1417
+ # Check that the path exists and is non-empty.
1418
+ my $happy = 1;
1419
+ if (! -d $path ) {
1420
+ $happy = 0;
1421
+ } else {
1422
+ opendir (DIR, $path ) ||
1423
+ my_die " Can't open $path directory" ;
1424
+ my @files = readdir (DIR);
1425
+ closedir (DIR);
1426
+
1427
+ $happy = 0
1428
+ if ($#files < 2);
1411
1429
}
1412
- if (index ($path , " prrte" ) != -1 and list_contains(" prrte" , @disabled_3rdparty_packages )) {
1413
- print (" Disabled - skipping prrte" );
1414
- next ;
1430
+
1431
+ if (!$happy ) {
1432
+ print (" ==> ERROR: Missing submodule\n\n The submodule \" $path \" is missing.\n\n " );
1433
+ exit (1);
1415
1434
}
1435
+ }
1416
1436
1417
- # Make sure the submodule is there
1418
- if ($status eq " -" ) {
1419
- print (" ==> ERROR: Missing
1437
+ if (-d " .git" ) {
1438
+ open (IN, " git submodule status|" )
1439
+ || die " Can't run \" git submodule status\" " ;
1440
+ while (<IN>) {
1441
+ $_ =~ m / ^(.)[0-9a-f] {40}\s +(\S +)/ ;
1442
+ my $status = $1 ;
1443
+ my $path = $2 ;
1444
+
1445
+ print (" === Submodule: $path \n " );
1446
+ if (index ($path , " pmix" ) != -1 and list_contains(" pmix" , @disabled_3rdparty_packages )) {
1447
+ print (" Disabled - skipping openpmix" );
1448
+ next ;
1449
+ }
1450
+ if (index ($path , " prrte" ) != -1 and list_contains(" prrte" , @disabled_3rdparty_packages )) {
1451
+ print (" Disabled - skipping prrte" );
1452
+ next ;
1453
+ }
1454
+
1455
+ # Make sure the submodule is there
1456
+ if ($status eq " -" ) {
1457
+ print (" ==> ERROR: Missing
1420
1458
1421
1459
The submodule \" $path \" is missing.
1422
1460
1423
1461
Perhaps you forgot to \" git clone --recursive ...\" , or you need to
1424
1462
\" git submodule update --init --recursive\" ...?\n\n " );
1425
- exit (1);
1426
- }
1463
+ exit (1);
1464
+ }
1427
1465
1428
- # See if the commit in the submodule is not the same as the
1429
- # commit that the git submodule thinks it should be.
1430
- elsif ($status eq " +" ) {
1466
+ # See if the commit in the submodule is not the same as the
1467
+ # commit that the git submodule thinks it should be.
1468
+ elsif ($status eq " +" ) {
1431
1469
print (" ==> WARNING: Submodule hash is different than upstream.
1432
1470
If this is not intentional, you may want to run:
1433
1471
\" git submodule update --init --recursive\"\n " );
1434
- } else {
1435
- print (" Local hash is what is expected by the submodule (good!)\n " );
1472
+ } else {
1473
+ print (" Local hash is what is expected by the submodule (good!)\n " );
1474
+ }
1436
1475
}
1437
1476
}
1438
1477
}
0 commit comments