forked from ali1234/rpi-ramdisk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
53 lines (40 loc) · 1.32 KB
/
__init__.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os, pathlib
from pydo import *
this_dir = pathlib.Path(__file__).parent
try:
from . import config
except ImportError:
log.error('Error: Project is not configured.')
exit(-1)
try:
jobs = int(os.environ['PYDOJOBS'], 10)
except Exception:
import multiprocessing
jobs = multiprocessing.cpu_count()
log.warning(f'Setting jobs to {jobs}.')
from . import kernel, firmware, raspbian, sysroot, packages
kernel_boot_tarballs = [k.boot for k in kernel.kernels]
boot = this_dir / 'boot'
dnsmasq_conf_in = this_dir / 'dnsmasq.conf.in'
dnsmasq_conf = this_dir / 'dnsmasq.conf'
@command(produces=[dnsmasq_conf], consumes=[dnsmasq_conf_in])
def build_dnsmasq_conf():
subst(dnsmasq_conf_in, dnsmasq_conf, {'@TFTP_ROOT@': str(boot)})
@command(produces=[boot], consumes=[firmware.target, raspbian.initrd, *kernel_boot_tarballs, dnsmasq_conf])
def build():
call([
f'mkdir -p {boot}',
f'rm -rf --one-file-system {boot}/*',
f'cp {raspbian.initrd} {boot}',
f'tar -xf {firmware.target} -C {boot}',
*list(f'tar -xf {kb} -C {boot}' for kb in kernel_boot_tarballs),
#f'cd {boot} && zip -qr {boot} *',
f'touch {boot}',
], shell=True)
@command()
def clean():
sysroot.clean()
firmware.clean()
kernel.clean()
raspbian.clean()
packages.clean()