Skip to content

Commit 4dee09e

Browse files
committed
os: Allow specify rauc bundle version
1 parent 28eaf78 commit 4dee09e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

os/rauc/rauc.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ export async function setup_system_conf() {
122122
await writeRaucSystemConf(conf)
123123
}
124124

125-
export async function createBundle(device, bootname) {
125+
export async function createBundle(device, bootname, version) {
126126
const date = new Date().toISOString()
127127
const build = date
128-
const version = date.split("T")[0]
128+
version ??= date.split("T")[0]
129129

130130
const partitions = await getBlockDevices(device)
131131

@@ -161,7 +161,7 @@ export async function createBundle(device, bootname) {
161161
// mount it as loop device "mount -o loop rootfs.img /mnt"
162162
// then rsync files into it
163163
await $`dd if=${part_root.path} of=${join(bundle_dir, manifest.image.ROOT.filename)} bs=64M`
164-
const bundle_path = join(tmpdir, `PlanktoScope-update-${version}.raucb`)
164+
const bundle_path = join(tmpdir, `PlanktoScopeOS-${version}.raucb`)
165165
await $`rauc --cert /etc/rauc/cert.pem --key planktoscope-rauc-key.pem bundle ${bundle_dir} ${bundle_path}`
166166
await rm(bundle_dir, {
167167
recursive: true,
@@ -182,17 +182,17 @@ if (import.meta.main) {
182182
}
183183
await setup_system_conf()
184184
} else if (command === "create-bundle") {
185-
const [device_path, bootname] = args
185+
const [device_path, bootname, version] = args
186186
if (!device_path || !bootname) {
187-
throw new Error("create-bundle /dev/device A|B")
187+
throw new Error("create-bundle /dev/device A|B [version]")
188188
}
189189
const booted_slot = await getBootedSlot()
190190
if (device_path === device && bootname === booted_slot) {
191191
throw new Error(
192192
`Cannot create a bundle for booted ${device} ${bootname} slot.`,
193193
)
194194
}
195-
const bundle_path = await createBundle(device_path, bootname)
195+
const bundle_path = await createBundle(device_path, bootname, version)
196196
console.log(bundle_path)
197197
} else {
198198
throw new Error(`Unknwon command "${command}".`)

0 commit comments

Comments
 (0)