also looking at this
feat: own runtime firmware candidates
#49
24 files
+1245
-92
| @@ -20,6 +20,9 @@ export async function epochRepository(directory: string, duplicateSnapshotKey = | ||
| 20 | 20 | async function publish(epoch: 1 | 2, version: number, releaseSequence: number) { |
| 21 | 21 | if (epoch === 2) await writeFile(join(directory, 'metadata/2.root.json'), root(2)) |
| 22 | 22 | const image = Buffer.from('synthetic epoch image, never execute or flash\n') |
| 23 | const imageHash = digest(image), imagePath = join(directory, 'targets/runtime', `${imageHash}.pico2-bench.bin`) | |
| 24 | await mkdir(join(directory, 'targets/runtime'), { recursive: true }) | |
| 25 | await writeFile(imagePath, image) | |
| 23 | 26 | const custom = { schema: 'drone-runtime-image-v1', platform, protocolVersion: 1, releaseSequence, sourceRevision: 'a'.repeat(40), profile: 'neutral-bench' } |
| 24 | 27 | const targets = new Metadata(new Targets({ ...fields, version, targets: { [target]: new TargetFile({ path: target, length: image.length, hashes: { sha256: digest(image) }, unrecognizedFields: { custom: { drone: custom } } }) } })) |
| 25 | 28 | targets.sign(keys.targets.sign) |
| @@ -32,6 +35,7 @@ export async function epochRepository(directory: string, duplicateSnapshotKey = | ||
| 32 | 35 | await writeFile(join(directory, 'metadata/timestamp.json'), JSON.stringify(timestamp.toJSON())) |
| 33 | 36 | await writeFile(join(directory, `metadata/${version}.snapshot.json`), snapshotBytes) |
| 34 | 37 | await writeFile(join(directory, `metadata/${version}.targets.json`), targetBytes) |
| 38 | return { image, imageHash, imagePath } | |
| 35 | 39 | } |
| 36 | 40 | return { rootPath, rootSha256: digest(anchor), publish } |
| 37 | 41 | } |