Skip to content

Commit 26ae9ab

Browse files
Add autoboot toggle script to git
1 parent 2d2ae89 commit 26ae9ab

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

scripts/update_autoboot.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
"""Patch autoboot.txt boot_partition values after a successful OTA commit."""
3+
4+
import sys
5+
import re
6+
7+
path, new_default, new_tryboot = sys.argv[1], sys.argv[2], sys.argv[3]
8+
content = open(path).read()
9+
10+
content = re.sub(
11+
r'(\[all\].*?boot_partition=)\d+',
12+
lambda m: m.group(1) + new_default,
13+
content, flags=re.DOTALL
14+
)
15+
content = re.sub(
16+
r'(\[tryboot\].*?boot_partition=)\d+',
17+
lambda m: m.group(1) + new_tryboot,
18+
content, flags=re.DOTALL
19+
)
20+
21+
open(path, 'w').write(content)

0 commit comments

Comments
 (0)