Skip to content

Commit 66e5001

Browse files
committed
asahi_firmware.update: Add updater module & setup.py
Signed-off-by: Hector Martin <[email protected]>
1 parent 1dd9e65 commit 66e5001

3 files changed

Lines changed: 55 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ package
44
installer.tar.gz
55
latest
66
*.ipsw
7+
*.egg-info
8+
build
9+
dist

asahi_firmware/update.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-License-Identifier: MIT
2+
import pathlib, tempfile, subprocess
3+
4+
from .core import FWPackage
5+
from .wifi import WiFiFWCollection
6+
from .bluetooth import BluetoothFWCollection
7+
8+
def update_firmware(source, dest, manifest):
9+
raw_fw = source.joinpath("all_firmware.tar.gz")
10+
if not raw_fw.exists():
11+
print(f"Could not find {raw_fw}")
12+
13+
pkg = FWPackage(dest)
14+
15+
with tempfile.TemporaryDirectory() as tmpdir:
16+
tmpdir = pathlib.Path(tmpdir)
17+
subprocess.run(["tar", "xf", str(raw_fw.resolve())], cwd=tmpdir, check=True)
18+
col = WiFiFWCollection(str(tmpdir.joinpath("firmware", "wifi")))
19+
pkg.add_files(sorted(col.files()))
20+
col = BluetoothFWCollection(str(tmpdir.joinpath("firmware", "bluetooth")))
21+
pkg.add_files(sorted(col.files()))
22+
23+
pkg.close()
24+
25+
pkg.save_manifest(manifest)
26+
27+
if __name__ == "__main__":
28+
import argparse
29+
30+
parser = argparse.ArgumentParser(description='Update vendor firmware tarball')
31+
parser.add_argument('source', metavar='DIR', type=pathlib.Path,
32+
help='path containing raw firmware')
33+
parser.add_argument('dest', metavar='FILE', type=pathlib.Path,
34+
help='output vendor firmware tarball')
35+
parser.add_argument('manifest', metavar='FILE', type=pathlib.Path,
36+
help='output vendor firmware manifest')
37+
38+
args = parser.parse_args()
39+
40+
update_firmware(args.source, args.dest, args.manifest)

setup.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python
2+
3+
from distutils.core import setup
4+
5+
setup(name='asahi_firmware',
6+
version='0.1',
7+
description='Asahi Linux firmware tools',
8+
author='Hector Martin',
9+
author_email='[email protected]',
10+
url='https://github.com/AsahiLinux/asahi-installer/',
11+
packages=['asahi_firmware'],
12+
)

0 commit comments

Comments
 (0)