-
-
Notifications
You must be signed in to change notification settings - Fork 617
Expand file tree
/
Copy pathrelease-zip
More file actions
executable file
·39 lines (33 loc) · 1.32 KB
/
release-zip
File metadata and controls
executable file
·39 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import os
import zipfile
import common
class Main(common.LkmcCliFunction):
def __init__(self):
super().__init__(
description='''\
https://cirosantilli.com/linux-kernel-module-cheat#release-zip
''',
defaults = {
'show_time': False,
}
)
self.zip_files = []
def timed_main(self):
self.zip_files.append(self.env['qcow2_file'])
self.zip_files.append(self.env['linux_image'])
for root, dirnames, filenames in os.walk(self.env['baremetal_build_dir']):
for filename in sorted(filenames):
path = os.path.join(root, filename)
if os.path.splitext(path)[1] == self.env['baremetal_executable_ext']:
self.zip_files.append(path)
def teardown(self):
os.makedirs(self.env['release_dir'], exist_ok=True)
self.sh.rmrf(self.env['release_zip_file'])
self.log_info('Creating zip: ' + self.env['release_zip_file'])
with zipfile.ZipFile(self.env['release_zip_file'], 'w', zipfile.ZIP_DEFLATED) as zipf:
for zip_file in self.zip_files:
self.log_info('Adding file: ' + zip_file)
zipf.write(zip_file, arcname=os.path.relpath(zip_file, self.env['root_dir']))
if __name__ == '__main__':
Main().cli()