@@ -2227,26 +2227,7 @@ export async function downloadPackage(
2227
2227
// Validate package completeness and trigger source build if incomplete
2228
2228
const isValidPackage = await validatePackageInstallation ( packageDir , domain )
2229
2229
if ( ! isValidPackage ) {
2230
- const missingComponents = getMissingComponents ( packageDir , domain )
2231
- logUniqueMessage ( `⚠️ Package ${ domain } appears incomplete (missing ${ missingComponents } ), attempting source build...` )
2232
-
2233
- // Try source build for known problematic packages
2234
- const sourceBuilt = await attemptSourceBuild ( domain , installPath , version )
2235
- if ( sourceBuilt ) {
2236
- logUniqueMessage ( `✅ Successfully built ${ domain } from source` )
2237
- // Remove incomplete installation and use source-built version
2238
- await fs . promises . rm ( packageDir , { recursive : true , force : true } )
2239
- // Source build creates its own package directory, so update our reference
2240
- const newPackageDir = path . join ( installPath , domain , `v${ version } ` )
2241
- // Update packageDir for subsequent operations
2242
- if ( fs . existsSync ( newPackageDir ) ) {
2243
- // The validation and shim creation will work on the new directory
2244
- }
2245
- }
2246
- else {
2247
- logUniqueMessage ( `⚠️ ${ domain } may be incomplete, but no source build available` )
2248
- // Keep the incomplete package - it might still have useful binaries
2249
- }
2230
+ logUniqueMessage ( `⚠️ Package ${ domain } appears incomplete, source build not available...` )
2250
2231
}
2251
2232
2252
2233
// Find binaries and create shims
@@ -3180,7 +3161,7 @@ export async function install(packages: PackageSpec | PackageSpec[], basePath?:
3180
3161
// Handle OS-specific packages (e.g., darwin@package -> package)
3181
3162
const osMatch = pkg . match ( / ^ ( d a r w i n | l i n u x | w i n d o w s | f r e e b s d | o p e n b s d | n e t b s d ) @ ( [ ^ : ] + ) ( : .* ) ? $ / )
3182
3163
if ( osMatch ) {
3183
- const [ , osPrefix , basePkg , versionConstraint ] = osMatch
3164
+ const [ , _osPrefix , basePkg , versionConstraint ] = osMatch
3184
3165
// Fix malformed version constraints: ": ^1" -> "@^1"
3185
3166
let fallbackPkg = basePkg
3186
3167
if ( versionConstraint ) {
@@ -3263,7 +3244,7 @@ export async function install(packages: PackageSpec | PackageSpec[], basePath?:
3263
3244
// Handle OS-specific packages (e.g., darwin@package -> package)
3264
3245
const osMatch = result . package . match ( / ^ ( d a r w i n | l i n u x | w i n d o w s | f r e e b s d | o p e n b s d | n e t b s d ) @ ( [ ^ : ] + ) ( : .* ) ? $ / )
3265
3246
if ( osMatch ) {
3266
- const [ , osPrefix , basePkg , versionConstraint ] = osMatch
3247
+ const [ , _osPrefix , basePkg , versionConstraint ] = osMatch
3267
3248
const fallbackPkg = versionConstraint ? `${ basePkg } ${ versionConstraint } ` : basePkg
3268
3249
// For OS-specific packages, don't show warning yet - let fallback try first
3269
3250
if ( config . verbose ) {
@@ -3906,9 +3887,6 @@ exec "${finalBinaryPath}" "$@"
3906
3887
}
3907
3888
}
3908
3889
3909
-
3910
-
3911
-
3912
3890
/**
3913
3891
* Test if a PHP binary actually works (can run --version without dyld errors)
3914
3892
*/
@@ -3935,63 +3913,6 @@ export async function testPhpBinary(phpPath: string): Promise<boolean> {
3935
3913
}
3936
3914
}
3937
3915
3938
- /**
3939
- * Determine what components are missing from a package installation
3940
- */
3941
- function getMissingComponents ( packageDir : string , domain : string ) : string {
3942
- const binDir = path . join ( packageDir , 'bin' )
3943
- const sbinDir = path . join ( packageDir , 'sbin' )
3944
- const libDir = path . join ( packageDir , 'lib' )
3945
- const shareDir = path . join ( packageDir , 'share' )
3946
- const etcDir = path . join ( packageDir , 'etc' )
3947
-
3948
- const hasBin = fs . existsSync ( binDir )
3949
- const hasSbin = fs . existsSync ( sbinDir )
3950
- const hasLib = fs . existsSync ( libDir )
3951
- const hasShare = fs . existsSync ( shareDir )
3952
- const hasEtc = fs . existsSync ( etcDir )
3953
-
3954
- // Special cases for different package types
3955
- if ( domain === 'curl.se/ca-certs' ) {
3956
- if ( ! hasShare && ! hasEtc ) {
3957
- return 'certificate files'
3958
- }
3959
- }
3960
-
3961
- if ( domain . includes ( 'x.org/util-macros' ) ) {
3962
- const aclocalDir = path . join ( packageDir , 'share' , 'aclocal' )
3963
- const pkgconfigDir = path . join ( packageDir , 'share' , 'pkgconfig' )
3964
- if ( ! fs . existsSync ( aclocalDir ) && ! fs . existsSync ( pkgconfigDir ) && ! hasShare && ! hasBin ) {
3965
- return 'build macros (aclocal or pkgconfig files)'
3966
- }
3967
- }
3968
-
3969
- if ( domain . includes ( 'x.org/protocol' ) ) {
3970
- const includeDir = path . join ( packageDir , 'include' )
3971
- const pkgconfigDir = path . join ( packageDir , 'share' , 'pkgconfig' )
3972
- if ( ! fs . existsSync ( includeDir ) && ! fs . existsSync ( pkgconfigDir ) && ! hasShare && ! hasBin ) {
3973
- return 'protocol headers (include or pkgconfig files)'
3974
- }
3975
- }
3976
-
3977
- // Library packages that need lib directories
3978
- const libraryPackages = [ 'gnu.org/gmp' , 'openssl.org' , 'zlib.net' , 'libpng.org' , 'libsodium.org' ]
3979
- if ( libraryPackages . some ( pkg => domain . includes ( pkg ) ) ) {
3980
- if ( ! hasLib && ! hasBin ) {
3981
- return 'lib directory or working binaries'
3982
- }
3983
- }
3984
-
3985
- // Default: expect bin or sbin
3986
- if ( ! hasBin && ! hasSbin ) {
3987
- return 'executable binaries'
3988
- }
3989
-
3990
- return 'required components'
3991
- }
3992
-
3993
-
3994
-
3995
3916
/**
3996
3917
* Validate if a package installation is complete
3997
3918
* A package is considered incomplete if it's a library package but only has bin/ and no lib/
@@ -4154,40 +4075,6 @@ async function validatePackageInstallation(packageDir: string, domain: string):
4154
4075
}
4155
4076
}
4156
4077
4157
- /**
4158
- * Attempt to build a package from source if we have a source build function for it
4159
- */
4160
- async function attemptSourceBuild ( domain : string , installPath : string , version : string ) : Promise < boolean > {
4161
- try {
4162
- switch ( domain ) {
4163
- // case 'libpng.org': // DISABLED - let ts-pkgx handle libpng like all other deps
4164
- // await buildLibpngFromSource(installPath, version)
4165
- // return true
4166
- // case 'gnu.org/gmp': // DISABLED - let ts-pkgx handle GMP like all other deps
4167
- // await buildGmpFromSource(installPath, version)
4168
- // return true
4169
- // case 'zlib.net': // DISABLED - let ts-pkgx handle zlib like all other deps
4170
- // await buildZlibFromSource(installPath, version)
4171
- // return true
4172
- // case 'sqlite.org': // DISABLED - let ts-pkgx handle sqlite like all other deps
4173
- // await buildSqliteFromSource(installPath, version)
4174
- // return true
4175
- // case 'openssl.org': // DISABLED - let ts-pkgx handle openssl like all other deps
4176
- // await buildOpenSSLFromSource(installPath, version)
4177
- // return true
4178
- default :
4179
- // No source build available for this package - let ts-pkgx handle all deps
4180
- return false
4181
- }
4182
- }
4183
- catch ( error ) {
4184
- if ( config . verbose ) {
4185
- console . warn ( `Source build failed for ${ domain } :` , error )
4186
- }
4187
- return false
4188
- }
4189
- }
4190
-
4191
4078
/**
4192
4079
* Build SQLite from source
4193
4080
*/
@@ -4261,77 +4148,6 @@ export async function buildSqliteFromSource(installPath: string, requestedVersio
4261
4148
}
4262
4149
}
4263
4150
4264
- /**
4265
- * Build OpenSSL from source
4266
- */
4267
- export async function buildOpenSSLFromSource ( installPath : string , requestedVersion ?: string ) : Promise < string [ ] > {
4268
- const version = requestedVersion || '3.5.0'
4269
- const domain = 'openssl.org'
4270
-
4271
- logUniqueMessage ( `🔄 Building OpenSSL ${ version } from source...` )
4272
-
4273
- // Create a source build directory
4274
- const sourceDir = path . join ( installPath , '.tmp' , `openssl-source-${ version } ` )
4275
- await fs . promises . rm ( sourceDir , { recursive : true , force : true } )
4276
- await fs . promises . mkdir ( sourceDir , { recursive : true } )
4277
-
4278
- try {
4279
- // Download OpenSSL source
4280
- logUniqueMessage ( `📦 Downloading OpenSSL ${ version } source...` )
4281
- const sourceUrl = `https://github.com/openssl/openssl/archive/refs/tags/openssl-${ version } .tar.gz`
4282
- const response = await fetch ( sourceUrl )
4283
-
4284
- if ( ! response . ok ) {
4285
- throw new Error ( `Failed to download OpenSSL source: ${ response . status } ` )
4286
- }
4287
-
4288
- const tarPath = path . join ( sourceDir , 'openssl.tar.gz' )
4289
- await fs . promises . writeFile ( tarPath , Buffer . from ( await response . arrayBuffer ( ) ) )
4290
-
4291
- // Extract source
4292
- logUniqueMessage ( `📂 Extracting OpenSSL ${ version } source...` )
4293
- execSync ( `cd "${ sourceDir } " && tar -xzf openssl.tar.gz` , { stdio : 'inherit' } )
4294
-
4295
- // Find the extracted directory
4296
- const extractedDir = path . join ( sourceDir , `openssl-openssl-${ version } ` )
4297
-
4298
- // Configure
4299
- logUniqueMessage ( `⚙️ Configuring OpenSSL ${ version } build...` )
4300
- const packageDir = path . join ( installPath , domain , `v${ version } ` )
4301
- await fs . promises . mkdir ( packageDir , { recursive : true } )
4302
-
4303
- execSync ( `cd "${ extractedDir } " && ./Configure --prefix="${ packageDir } " shared` , {
4304
- stdio : 'inherit' ,
4305
- } )
4306
-
4307
- // Build
4308
- logUniqueMessage ( `🔨 Compiling OpenSSL ${ version } ...` )
4309
- execSync ( `cd "${ extractedDir } " && make` , {
4310
- stdio : 'inherit' ,
4311
- } )
4312
-
4313
- // Install
4314
- logUniqueMessage ( `📦 Installing OpenSSL ${ version } ...` )
4315
- execSync ( `cd "${ extractedDir } " && make install` , {
4316
- stdio : 'inherit' ,
4317
- } )
4318
-
4319
- // Cleanup
4320
- await fs . promises . rm ( sourceDir , { recursive : true , force : true } )
4321
-
4322
- return [ `${ packageDir } /bin/openssl` ]
4323
- }
4324
- catch ( error ) {
4325
- // Cleanup on error
4326
- await fs . promises . rm ( sourceDir , { recursive : true , force : true } )
4327
-
4328
- const errorMessage = `OpenSSL ${ version } source build failed: ${
4329
- error instanceof Error ? error . message : String ( error )
4330
- } `
4331
- throw new Error ( errorMessage )
4332
- }
4333
- }
4334
-
4335
4151
/**
4336
4152
* Install only the dependencies of packages, not the packages themselves
4337
4153
* Useful for setting up build environments without installing the main package
0 commit comments