Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Scipio dependencies #1

Merged
merged 11 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ on:
- '*'
jobs:
Tests:
runs-on: macos-12
runs-on: macos-14
steps:
- uses: actions/checkout@v2
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_14.0.app/Contents/Developer'
run: sudo xcode-select -s '/Applications/Xcode_15.3.app/Contents/Developer'
- name: Install SwiftLint
run: brew install swiftlint
- name: SwiftLint
run: swiftlint --strict
- name: Run Tests
Expand Down
133 changes: 35 additions & 98 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "864c8d9e0ead5de7ba70b61c8982f89126710863",
"version" : "1.15.0"
"revision" : "a22083713ee90808d527d0baa290c2fb13ca3096",
"version" : "1.21.1"
}
},
{
Expand All @@ -28,111 +28,83 @@
}
},
{
"identity" : "rainbow",
"identity" : "scipio-cache-storage",
"kind" : "remoteSourceControl",
"location" : "https://github.com/onevcat/Rainbow",
"location" : "https://github.com/giginet/scipio-cache-storage.git",
"state" : {
"revision" : "e0dada9cd44e3fa7ec3b867e49a8ddbf543e3df3",
"version" : "4.0.1"
}
},
{
"identity" : "scipio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/giginet/Scipio.git",
"state" : {
"branch" : "0.11.0",
"revision" : "10b52087b98f7114cc140d03ef286dc4efbce72e"
"revision" : "ec3467983ae14356ffcba0ecf4e5c76c3dd80532"
}
},
{
"identity" : "soto-codegenerator",
"kind" : "remoteSourceControl",
"location" : "https://github.com/soto-project/soto-codegenerator",
"state" : {
"revision" : "8fad5a4e1b131d00ac1d900910bd0d7b34d8e995",
"version" : "0.7.0"
"revision" : "b7c7091434baa7ccb48a767efaf1377a10662efd",
"version" : "6.0.0"
}
},
{
"identity" : "soto-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/soto-project/soto-core.git",
"state" : {
"revision" : "787be995b0cff07bd28e9aea4c8a6424ead36e71",
"version" : "6.4.2"
"revision" : "3ed66ec536bc372360d7e3ec39a5e8b1870747ea",
"version" : "6.5.2"
}
},
{
"identity" : "soto-smithy",
"kind" : "remoteSourceControl",
"location" : "https://github.com/soto-project/soto-smithy.git",
"state" : {
"revision" : "37c1f08b6a4979873d86cc392015e1244fce7a74",
"version" : "0.3.6"
"revision" : "9d90291376232d1fd520736b5e852c4505f60ea6",
"version" : "0.4.0"
}
},
{
"identity" : "swift-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-algorithms.git",
"state" : {
"revision" : "b14b7f4c528c942f121c8b860b9410b2bf57825e",
"version" : "1.0.0"
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
"version" : "1.2.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a",
"version" : "1.2.2"
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "ff3d2212b6b093db7f177d0855adbc4ef9c5f036",
"version" : "1.0.3"
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
"version" : "1.0.4"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "75ec60b8b4cc0f085c3ac414f3dca5625fa3588e",
"version" : "2.2.4"
"revision" : "d029d9d39c87bed85b1c50adee7c41795261a192",
"version" : "1.0.6"
}
},
{
"identity" : "swift-driver",
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-driver.git",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"branch" : "main",
"revision" : "738a6a31c4e10cbc9f07e576bb6561fdcfcb4714"
}
},
{
"identity" : "swift-llbuild",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-llbuild.git",
"state" : {
"branch" : "main",
"revision" : "674f81a2fc0308c1f4482ca761c012af2dde7c14"
"revision" : "9bee2fdb79cc740081abd8ebd80738063d632286",
"version" : "1.1.0"
}
},
{
Expand All @@ -149,53 +121,53 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "e8bced74bc6d747745935e469f45d03f048d6cbd",
"version" : "2.3.4"
"revision" : "ce594e71e92a1610015017f83f402894df540e51",
"version" : "2.4.4"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "45167b8006448c79dda4b7bd604e07a034c15c49",
"version" : "2.48.0"
"revision" : "702cd7c56d5d44eeba73fdf83918339b26dc855c",
"version" : "2.62.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "d75ed708d00353acf173ca23018b6bd46f949464",
"version" : "1.17.0"
"revision" : "a3b640d7dc567225db7c94386a6e71aded1bfa63",
"version" : "1.22.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "38feec96bcd929028939107684073554bf01abeb",
"version" : "1.25.2"
"revision" : "c6afe04165c865faaa687b42c32ed76dfcc91076",
"version" : "1.31.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "4fb7ead803e38949eb1d6fabb849206a72c580f3",
"version" : "2.23.0"
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version" : "2.26.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "c0d9a144cfaec8d3d596aadde3039286a266c15c",
"version" : "1.15.0"
"revision" : "38ac8221dd20674682148d6451367f89c2652980",
"version" : "1.21.0"
}
},
{
Expand All @@ -206,41 +178,6 @@
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
}
},
{
"identity" : "swift-package-manager",
"kind" : "remoteSourceControl",
"location" : "https://github.com/giginet/swift-package-manager.git",
"state" : {
"revision" : "11c88e87e6874a570711d18462ca0ea43ff7ff5e"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "836bc4557b74fe6d2660218d56e3ce96aff76574",
"version" : "1.1.1"
}
},
{
"identity" : "swift-tools-support-core",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-tools-support-core.git",
"state" : {
"branch" : "main",
"revision" : "93784c59434dbca8e8a9e4b700d0d6d94551da6a"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "f47ba4838c30dbd59998a4e4c87ab620ff959e8a",
"version" : "5.0.5"
}
}
],
"version" : 2
Expand Down
17 changes: 10 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
// swift-tools-version: 5.7
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "scipio-s3-storage",
platforms: [
.macOS(.v12),
.macOS(.v13),
],
products: [
.library(
name: "ScipioS3Storage",
targets: ["ScipioS3Storage"]),
],
dependencies: [
.package(url: "https://github.com/giginet/Scipio.git",
revision: "0.12.0"),
.package(url: "https://github.com/soto-project/soto-codegenerator",
from: "0.6.0"),
.package(url: "https://github.com/soto-project/soto-core.git",
from: "6.0.0"),
.package(url: "https://github.com/soto-project/soto-core.git",
from: "6.4.0"),
.package(url: "https://github.com/giginet/scipio-cache-storage.git",
from: "1.0.0"),
],
targets: [
.target(
name: "ScipioS3Storage",
dependencies: [
.product(name: "ScipioKit", package: "Scipio"),
.product(name: "ScipioStorage", package: "scipio-cache-storage"),
.product(name: "SotoCore", package: "soto-core"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
],
plugins: [
.plugin(name: "SotoCodeGeneratorPlugin", package: "soto-codegenerator"),
]
Expand Down
82 changes: 82 additions & 0 deletions Sources/ScipioS3Storage/AARArchiver.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import Foundation
import System
import Compression
import AppleArchive

/// Compress binaries into Apple Archive(AAR)
struct AARArchiver {
private let fileManager: FileManager = .default

init() throws {
try fileManager.createDirectory(at: temporaryDirectory, withIntermediateDirectories: true)
}

func compress(_ directoryPath: URL) throws -> Data {
guard let keySet else { throw Error.initializationError }

let source = FilePath(directoryPath.path)

let archivePath = temporaryDirectory.appendingPathComponent("\(UUID().uuidString).aar")
defer { try? fileManager.removeItem(at: archivePath) }

try ArchiveByteStream.withFileStream(
path: FilePath(archivePath.path),
mode: .writeOnly,
options: [.create, .truncate],
permissions: [.ownerReadWrite, .groupRead, .otherRead]
) { file in
try ArchiveByteStream.withCompressionStream(using: .lzfse, writingTo: file) { compressor in
try ArchiveStream.withEncodeStream(writingTo: compressor) { encoder in
try encoder.writeDirectoryContents(archiveFrom: source, keySet: keySet)
}
}
}

guard let data = fileManager.contents(atPath: archivePath.path) else {
throw Error.compressionError
}

return data
}

func extract(_ archiveData: Data, to destinationPath: URL) throws {
let destination = FilePath(destinationPath.path)

let temporaryPath = temporaryDirectory.appendingPathComponent("\(UUID().uuidString).aar")
fileManager.createFile(atPath: temporaryPath.path, contents: archiveData)
defer { try? fileManager.removeItem(at: temporaryPath) }

try fileManager.createDirectory(at: destinationPath, withIntermediateDirectories: true)

_ = try ArchiveByteStream.withFileStream(
path: FilePath(temporaryPath.path),
mode: .readOnly,
options: [],
permissions: [.ownerRead, .groupRead, .otherRead]
) { file in
try ArchiveByteStream.withDecompressionStream(readingFrom: file) { decompress in
try ArchiveStream.withDecodeStream(readingFrom: decompress) { decode in
try ArchiveStream.withExtractStream(
extractingTo: destination,
flags: [.ignoreOperationNotPermitted]
) { extract in
try ArchiveStream.process(readingFrom: decode, writingTo: extract)
}
}
}
}
}

enum Error: LocalizedError {
case initializationError
case compressionError
}

private var temporaryDirectory: URL {
fileManager.temporaryDirectory.appendingPathComponent("org.giginet.ScipioS3Storage")
}

private var keySet: ArchiveHeader.FieldKeySet? {
ArchiveHeader.FieldKeySet("TYP,PAT,LNK,DEV,DAT,UID,GID,MOD,FLG,MTM,BTM,CTM")
}
}
Loading
Loading