@@ -1206,6 +1206,14 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
1206
1206
const phpSourceDir = downloadPhpSource ( config )
1207
1207
mkdirSync ( installPrefix , { recursive : true } )
1208
1208
1209
+ // Install required system packages for extensions
1210
+ log ( 'Installing required system packages...' )
1211
+ try {
1212
+ execSync ( 'apt-get update && apt-get install -y libbz2-dev libzip-dev gettext libgettextpo-dev' , { stdio : 'inherit' } )
1213
+ } catch ( e ) {
1214
+ log ( 'Warning: Could not install system packages, continuing with available libraries' )
1215
+ }
1216
+
1209
1217
// Use clean system environment without any Launchpad paths
1210
1218
const buildEnv = {
1211
1219
...process . env ,
@@ -1237,7 +1245,7 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
1237
1245
} )
1238
1246
1239
1247
log ( 'Configuring PHP with system libraries...' )
1240
- const configureArgs = [
1248
+ const baseConfigureArgs = [
1241
1249
`--prefix=${ installPrefix } ` ,
1242
1250
'--enable-bcmath' ,
1243
1251
'--enable-calendar' ,
@@ -1273,18 +1281,70 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
1273
1281
'--with-zlib' ,
1274
1282
'--enable-opcache=shared' ,
1275
1283
'--with-readline' ,
1276
- '--without-zip' ,
1277
- '--without-iconv' ,
1278
1284
'--without-ldap-sasl'
1279
1285
]
1280
1286
1281
- execSync ( `./configure ${ configureArgs . join ( ' ' ) } ` , {
1282
- cwd : phpSourceDir ,
1283
- env : buildEnv ,
1284
- stdio : 'inherit'
1285
- } )
1287
+ // Try to configure with all critical extensions first
1288
+ const fullConfigureArgs = [
1289
+ ...baseConfigureArgs ,
1290
+ '--enable-zip' ,
1291
+ '--with-iconv' ,
1292
+ '--with-bz2' ,
1293
+ '--with-gettext'
1294
+ ]
1286
1295
1287
- log ( 'Building PHP...' )
1296
+ let configureSuccess = false
1297
+ try {
1298
+ log ( 'Attempting full configure with all extensions...' )
1299
+ execSync ( `./configure ${ fullConfigureArgs . join ( ' ' ) } ` , {
1300
+ cwd : phpSourceDir ,
1301
+ env : buildEnv ,
1302
+ stdio : 'inherit'
1303
+ } )
1304
+ configureSuccess = true
1305
+ } catch ( error ) {
1306
+ log ( 'Full configure failed, trying individual extensions...' )
1307
+
1308
+ // Try with individual extensions to see which ones work
1309
+ const workingArgs = [ ...baseConfigureArgs ]
1310
+
1311
+ // Test each extension individually
1312
+ const extensionsToTest = [
1313
+ { flag : '--enable-zip' , name : 'zip' } ,
1314
+ { flag : '--with-iconv' , name : 'iconv' } ,
1315
+ { flag : '--with-bz2' , name : 'bz2' } ,
1316
+ { flag : '--with-gettext' , name : 'gettext' }
1317
+ ]
1318
+
1319
+ for ( const ext of extensionsToTest ) {
1320
+ try {
1321
+ const testArgs = [ ...baseConfigureArgs , ext . flag ]
1322
+ execSync ( `./configure ${ testArgs . join ( ' ' ) } ` , {
1323
+ cwd : phpSourceDir ,
1324
+ env : buildEnv ,
1325
+ stdio : 'pipe'
1326
+ } )
1327
+ workingArgs . push ( ext . flag )
1328
+ log ( `✅ ${ ext . name } extension: Available` )
1329
+ } catch ( e ) {
1330
+ log ( `❌ ${ ext . name } extension: Not available, skipping` )
1331
+ }
1332
+ }
1333
+
1334
+ // Final configure with working extensions
1335
+ execSync ( `./configure ${ workingArgs . join ( ' ' ) } ` , {
1336
+ cwd : phpSourceDir ,
1337
+ env : buildEnv ,
1338
+ stdio : 'inherit'
1339
+ } )
1340
+ configureSuccess = true
1341
+ }
1342
+
1343
+ if ( ! configureSuccess ) {
1344
+ throw new Error ( 'Configure failed even with minimal extensions' )
1345
+ }
1346
+
1347
+ log ( 'Configure completed successfully, building PHP...' )
1288
1348
const jobs = execSync ( 'nproc 2>/dev/null || echo 2' , { encoding : 'utf8' } ) . trim ( )
1289
1349
execSync ( `make -j${ jobs } ` , {
1290
1350
cwd : phpSourceDir ,
0 commit comments