flash.py: use exec.file.get_temp_dir()
This commit is contained in:
parent
0924ea298a
commit
6cfd8ae1c2
1 changed files with 2 additions and 8 deletions
10
flash.py
10
flash.py
|
@ -1,11 +1,10 @@
|
||||||
import atexit
|
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
import click
|
import click
|
||||||
import tempfile
|
|
||||||
|
|
||||||
from constants import FLASH_PARTS, LOCATIONS
|
from constants import FLASH_PARTS, LOCATIONS
|
||||||
from exec.cmd import run_root_cmd
|
from exec.cmd import run_root_cmd
|
||||||
|
from exec.file import get_temp_dir
|
||||||
from fastboot import fastboot_flash
|
from fastboot import fastboot_flash
|
||||||
from image import dd_image, partprobe, shrink_fs, losetup_rootfs_image, dump_aboot, dump_lk2nd, dump_qhypstub, get_device_and_flavour, get_image_name, get_image_path
|
from image import dd_image, partprobe, shrink_fs, losetup_rootfs_image, dump_aboot, dump_lk2nd, dump_qhypstub, get_device_and_flavour, get_image_name, get_image_path
|
||||||
from wrapper import enforce_wrap
|
from wrapper import enforce_wrap
|
||||||
|
@ -58,14 +57,9 @@ def cmd_flash(what: str, location: str):
|
||||||
if path == '':
|
if path == '':
|
||||||
raise Exception('Unable to discover Jumpdrive')
|
raise Exception('Unable to discover Jumpdrive')
|
||||||
|
|
||||||
minimal_image_dir = tempfile.gettempdir()
|
minimal_image_dir = get_temp_dir(register_cleanup=True)
|
||||||
minimal_image_path = os.path.join(minimal_image_dir, f'minimal-{device_image_name}')
|
minimal_image_path = os.path.join(minimal_image_dir, f'minimal-{device_image_name}')
|
||||||
|
|
||||||
def clean_dir():
|
|
||||||
shutil.rmtree(minimal_image_dir)
|
|
||||||
|
|
||||||
atexit.register(clean_dir)
|
|
||||||
|
|
||||||
shutil.copyfile(device_image_path, minimal_image_path)
|
shutil.copyfile(device_image_path, minimal_image_path)
|
||||||
|
|
||||||
loop_device = losetup_rootfs_image(minimal_image_path, sector_size)
|
loop_device = losetup_rootfs_image(minimal_image_path, sector_size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue