@@ -2331,7 +2331,7 @@ exec ./configure "$@"
2331
2331
2332
2332
if ( ! existsSync ( phpBinaryPath ) ) {
2333
2333
log ( '💥 ❌ CRITICAL: make install failed to create PHP binary' )
2334
- log ( `💥 Expected PHP binary at: ${ phpBinaryPath } ` )
2334
+ log ( `💥 Expected PHP binary at: ${ join ( installPrefix , 'bin' , 'php' ) } ` )
2335
2335
log ( `💥 Build-time binary exists: ${ existsSync ( buildTimePhpBinary ) } ` )
2336
2336
2337
2337
if ( existsSync ( buildTimePhpBinary ) ) {
@@ -2347,113 +2347,14 @@ exec ./configure "$@"
2347
2347
2348
2348
log ( '✅ make install successfully created PHP binary' )
2349
2349
2350
- // Copy the main PHP binary
2351
- copyFileSync ( buildTimePhpBinary , phpBinaryPath )
2352
- chmodSync ( phpBinaryPath , '755' ) // Make executable
2353
- log ( `🔧 ✅ Manually copied PHP binary from ${ buildTimePhpBinary } to ${ phpBinaryPath } ` )
2354
-
2355
- // Helper function to safely copy files (skip sockets, pipes, etc.)
2356
- const safeCopyFile = ( source : string , target : string ) : boolean => {
2357
- try {
2358
- const stats = statSync ( source )
2359
- if ( ! stats . isFile ( ) ) {
2360
- log ( `🔧 ⚠️ Skipping ${ source } - not a regular file (type: ${ stats . isSocket ( ) ? 'socket' : stats . isFIFO ( ) ? 'pipe' : stats . isDirectory ( ) ? 'directory' : 'other' } )` )
2361
- return false
2362
- }
2363
- copyFileSync ( source , target )
2364
- chmodSync ( target , '755' )
2365
- return true
2366
- } catch ( error ) {
2367
- log ( `🔧 ⚠️ Failed to copy ${ source } : ${ error } ` )
2368
- return false
2369
- }
2370
- }
2371
-
2372
- // Also copy other important binaries if they exist and weren't installed
2373
- const otherBinaries = [ 'php-cgi' , 'php-config' , 'phpize' , 'pear' , 'pecl' ]
2374
- for ( const binary of otherBinaries ) {
2375
- const sourceBinary = join ( phpSourceDir , 'sapi' , 'cgi' , binary ) // Try CGI first
2376
- const altSourceBinary = join ( phpSourceDir , 'scripts' , binary ) // Try scripts dir
2377
- const altSource2Binary = join ( phpSourceDir , binary ) // Try root
2378
- const targetBinary = join ( installPrefix , 'bin' , binary )
2379
-
2380
- if ( ! existsSync ( targetBinary ) ) {
2381
- if ( existsSync ( sourceBinary ) && safeCopyFile ( sourceBinary , targetBinary ) ) {
2382
- log ( `🔧 ✅ Manually copied ${ binary } ` )
2383
- } else if ( existsSync ( altSourceBinary ) && safeCopyFile ( altSourceBinary , targetBinary ) ) {
2384
- log ( `🔧 ✅ Manually copied ${ binary } from scripts` )
2385
- } else if ( existsSync ( altSource2Binary ) && safeCopyFile ( altSource2Binary , targetBinary ) ) {
2386
- log ( `🔧 ✅ Manually copied ${ binary } from root` )
2387
- }
2388
- }
2389
- }
2390
-
2391
- // Copy CGI binary specifically
2392
- const cgiBinarySource = join ( phpSourceDir , 'sapi' , 'cgi' , 'php-cgi' )
2393
- const cgiBinaryTarget = join ( installPrefix , 'bin' , 'php-cgi' )
2394
- if ( ! existsSync ( cgiBinaryTarget ) && existsSync ( cgiBinarySource ) && safeCopyFile ( cgiBinarySource , cgiBinaryTarget ) ) {
2395
- log ( `🔧 ✅ Manually copied php-cgi binary` )
2396
- }
2397
-
2398
- // Copy FPM binary specifically
2399
- const fpmBinarySource = join ( phpSourceDir , 'sapi' , 'fpm' , 'php-fpm' )
2400
- const fpmBinaryTarget = join ( installPrefix , 'sbin' , 'php-fpm' )
2401
- if ( ! existsSync ( fpmBinaryTarget ) && existsSync ( fpmBinarySource ) ) {
2402
- mkdirSync ( join ( installPrefix , 'sbin' ) , { recursive : true } )
2403
- if ( safeCopyFile ( fpmBinarySource , fpmBinaryTarget ) ) {
2404
- log ( `🔧 ✅ Manually copied php-fpm binary` )
2405
- }
2406
- }
2407
- }
2408
-
2409
- } catch ( error ) {
2410
- if ( config . platform === 'darwin' ) {
2411
- log ( '🔧 ❌ Installation failed, checking build-time PHP binary again...' )
2412
-
2413
- const buildTimePhpBinary = join ( phpSourceDir , 'sapi' , 'cli' , 'php' )
2414
- if ( existsSync ( buildTimePhpBinary ) ) {
2415
- // Check what's wrong with the binary
2416
- try {
2417
- const otoolOutput = execSync ( `otool -L "${ buildTimePhpBinary } "` , { encoding : 'utf8' } )
2418
- log ( '🔧 Build-time PHP binary dependencies:' )
2419
- log ( otoolOutput )
2420
-
2421
- // Try one more comprehensive fix
2422
- log ( '🔧 Attempting final library path fix...' )
2423
- fixMacOSLibraryPaths ( buildTimePhpBinary , homeDir )
2424
-
2425
- // Test the binary one more time
2426
- execSync ( `"${ buildTimePhpBinary } " --version` , {
2427
- stdio : 'inherit' ,
2428
- env : installEnv
2429
- } )
2430
-
2431
- log ( '🔧 Binary is now working, retrying installation...' )
2432
- execSync ( 'make install' , {
2433
- stdio : 'inherit' ,
2434
- cwd : phpSourceDir ,
2435
- env : installEnv ,
2436
- timeout : 15 * 60 * 1000 ,
2437
- } )
2438
- } catch ( finalError ) {
2439
- log ( `🔧 Final installation attempt failed: ${ finalError } ` )
2440
- throw error
2441
- }
2442
- } else {
2443
- throw error
2444
- }
2445
- } else {
2446
- throw error
2447
- }
2448
- }
2449
2350
2450
2351
// Additional post-build validation
2451
2352
log ( '🔍 Performing post-build validation...' )
2452
2353
2453
2354
// Verify final PHP binary works correctly
2454
2355
try {
2455
2356
const phpBinaryPath = join ( installPrefix , 'bin' , 'php' )
2456
- const versionOutput = execSync ( `"${ phpBinaryPath } " --version` , {
2357
+ const versionOutput = execSync ( `"${ join ( installPrefix , 'bin' , 'php' ) } " --version` , {
2457
2358
encoding : 'utf8' ,
2458
2359
env : {
2459
2360
...process . env ,
@@ -2466,7 +2367,7 @@ exec ./configure "$@"
2466
2367
log ( `📋 PHP Version: ${ versionOutput . split ( '\n' ) [ 0 ] } ` )
2467
2368
2468
2369
// Check for required extensions
2469
- const extensionsOutput = execSync ( `"${ phpBinaryPath } " -m` , {
2370
+ const extensionsOutput = execSync ( `"${ join ( installPrefix , 'bin' , 'php' ) } " -m` , {
2470
2371
encoding : 'utf8' ,
2471
2372
env : {
2472
2373
...process . env ,
@@ -2553,11 +2454,10 @@ exec ./configure "$@"
2553
2454
log ( `✅ PHP ${ config . phpVersion } built successfully at ${ installPrefix } ` )
2554
2455
2555
2456
// Verify that the binary was actually installed
2556
- const phpBinaryPath = join ( installPrefix , 'bin' , 'php' )
2557
- if ( existsSync ( phpBinaryPath ) ) {
2558
- log ( `✅ PHP binary verified at: ${ phpBinaryPath } ` )
2457
+ if ( existsSync ( join ( installPrefix , 'bin' , 'php' ) ) ) {
2458
+ log ( `✅ PHP binary verified at: ${ join ( installPrefix , 'bin' , 'php' ) } ` )
2559
2459
} else {
2560
- log ( `❌ PHP binary not found at expected location: ${ phpBinaryPath } ` )
2460
+ log ( `❌ PHP binary not found at expected location: ${ join ( installPrefix , 'bin' , 'php' ) } ` )
2561
2461
log ( `🔍 Contents of ${ installPrefix } :` )
2562
2462
if ( existsSync ( installPrefix ) ) {
2563
2463
const contents = readdirSync ( installPrefix )
@@ -2647,6 +2547,11 @@ exec ./configure "$@"
2647
2547
}
2648
2548
2649
2549
return installPrefix
2550
+ } catch ( error ) {
2551
+ log ( '💥 ❌ CRITICAL: PHP installation failed' )
2552
+ log ( `💥 Error: ${ error } ` )
2553
+ throw new Error ( `Build failed during installation: ${ error } ` )
2554
+ }
2650
2555
}
2651
2556
2652
2557
// Add a BZip2 specific cache variable for configure
@@ -2909,9 +2814,9 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
2909
2814
// Verify that the binary was actually installed
2910
2815
const phpBinaryPath = join ( installPrefix , 'bin' , 'php' )
2911
2816
if ( existsSync ( phpBinaryPath ) ) {
2912
- log ( `✅ PHP binary verified at: ${ phpBinaryPath } ` )
2817
+ log ( `✅ PHP binary verified at: ${ join ( installPrefix , 'bin' , 'php' ) } ` )
2913
2818
} else {
2914
- log ( `❌ PHP binary not found at expected location: ${ phpBinaryPath } ` )
2819
+ log ( `❌ PHP binary not found at expected location: ${ join ( installPrefix , 'bin' , 'php' ) } ` )
2915
2820
log ( `🔍 Contents of ${ installPrefix } :` )
2916
2821
if ( existsSync ( installPrefix ) ) {
2917
2822
const contents = readdirSync ( installPrefix )
0 commit comments