11import ArgumentParser
2+ import AsyncHTTPClient
23import Foundation
34import SwiftlyCore
45import SystemPackage
@@ -142,9 +143,6 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
142143 }
143144
144145 func buildLinuxRelease( ) async throws {
145- // TODO: turn these into checks that the system meets the criteria for being capable of using the toolchain + checking for packages, not tools
146- let curl = try await self . assertTool ( " curl " , message: " Please install curl with `yum install curl` " )
147-
148146 try await self . checkGitRepoStatus ( )
149147
150148 // Start with a fresh SwiftPM package
@@ -162,7 +160,20 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
162160 try ? FileManager . default. createDirectory ( atPath: pkgConfigPath, withIntermediateDirectories: true )
163161
164162 try ? FileManager . default. removeItem ( atPath: libArchivePath)
165- try currentPlatform. runProgram ( curl, " -L " , " -o " , " \( buildCheckoutsDir + " /libarchive- \( libArchiveVersion) .tar.gz " ) " , " --remote-name " , " --location " , " https://github.com/libarchive/libarchive/releases/download/v \( libArchiveVersion) /libarchive- \( libArchiveVersion) .tar.gz " )
163+
164+ // Download libarchive
165+ let libarchiveRequest = HTTPClientRequest ( url: " https://github.com/libarchive/libarchive/releases/download/v \( libArchiveVersion) /libarchive- \( libArchiveVersion) .tar.gz " )
166+ let libarchiveResponse = try await HTTPClient . shared. execute ( libarchiveRequest, timeout: . seconds( 60 ) )
167+ guard libarchiveResponse. status == . ok else {
168+ throw Error ( message: " Download failed with status: \( libarchiveResponse. status) " )
169+ }
170+ let buf = try await libarchiveResponse. body. collect ( upTo: 20 * 1024 * 1024 )
171+ guard let contents = buf. getBytes ( at: 0 , length: buf. readableBytes) else {
172+ throw Error ( message: " Unable to read all of the bytes " )
173+ }
174+ let data = Data ( contents)
175+ try data. write ( to: FilePath ( buildCheckoutsDir + " /libarchive- \( libArchiveVersion) .tar.gz " ) )
176+
166177 let libArchiveTarShaActual = try await sys. sha256sum ( files: FilePath ( " \( buildCheckoutsDir) /libarchive- \( libArchiveVersion) .tar.gz " ) ) . output ( currentPlatform)
167178 guard let libArchiveTarShaActual, libArchiveTarShaActual. starts ( with: libArchiveTarSha) else {
168179 let shaActual = libArchiveTarShaActual ?? " none "
0 commit comments