mirror of
https://github.com/GayPizzaSpecifications/darwin-apk.git
synced 2025-08-04 05:51:31 +00:00
try implementing a command that can search the index for packages
This commit is contained in:
@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import CryptoKit
|
||||
|
||||
public struct ApkIndexUpdater {
|
||||
var repositories: [String]
|
||||
@ -22,7 +21,7 @@ public struct ApkIndexUpdater {
|
||||
public func update() {
|
||||
let repositories = self.repositories.flatMap { repo in
|
||||
self.architectures.map { arch in
|
||||
Repository(name: repo, arch: arch)
|
||||
ApkIndexRepository(name: repo, arch: arch)
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,24 +106,3 @@ public struct ApkIndexUpdater {
|
||||
try ApkRawIndex(lines: MemoryInputStream(buffer: apkIndexFile).lines))
|
||||
}
|
||||
}
|
||||
|
||||
extension ApkIndexUpdater {
|
||||
struct Repository {
|
||||
let name: String
|
||||
let arch: String
|
||||
let discriminator: String
|
||||
|
||||
private static func resolveApkIndex(_ repo: String, _ arch: String)
|
||||
-> String { "\(repo)/\(arch)/APKINDEX.tar.gz" }
|
||||
var url: URL { URL(string: Self.resolveApkIndex(self.name, self.arch))! }
|
||||
var localName: String { "APKINDEX.\(discriminator).tar.gz" }
|
||||
|
||||
init(name repo: String, arch: String) {
|
||||
self.name = repo
|
||||
self.arch = arch
|
||||
|
||||
let urlSHA1Digest = Data(Insecure.SHA1.hash(data: Data(Self.resolveApkIndex(repo, arch).utf8)))
|
||||
self.discriminator = urlSHA1Digest.subdata(in: 0..<3).map { String(format: "%02x", $0) }.joined()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user