mirror of
https://gitlab.com/kupfer/kupferbootstrap.git
synced 2025-02-23 05:35:44 -05:00
distro/package: add acquire() parameters to Distro interface: dest_dir: Optional[str], filename: Optional[str]
This commit is contained in:
parent
ba5aa209dd
commit
d527769473
1 changed files with 9 additions and 5 deletions
|
@ -3,8 +3,8 @@ import os
|
|||
|
||||
from typing import Optional, Union
|
||||
|
||||
from exec.file import get_temp_dir, makedir
|
||||
from utils import download_file
|
||||
from exec.file import copy_file, get_temp_dir, makedir
|
||||
from utils import download_file, sha256sum
|
||||
|
||||
|
||||
class PackageInfo:
|
||||
|
@ -61,16 +61,20 @@ class BinaryPackage(PackageInfo):
|
|||
p._desc = desc
|
||||
return p
|
||||
|
||||
def acquire(self) -> str:
|
||||
def acquire(self, dest_dir: Optional[str] = None, filename: Optional[str] = None) -> str:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class LocalPackage(BinaryPackage):
|
||||
|
||||
def acquire(self) -> str:
|
||||
def acquire(self, dest_dir: Optional[str] = None, filename: Optional[str] = None) -> str:
|
||||
assert self.resolved_url and self.filename and self.filename in self.resolved_url
|
||||
path = f'{self.resolved_url.split("file://")[1]}'
|
||||
assert os.path.exists(path) or print(path)
|
||||
if dest_dir:
|
||||
target = os.path.join(dest_dir, filename or self.filename)
|
||||
if os.path.getsize(path) != os.path.getsize(target) or sha256sum(path) != sha256sum(target):
|
||||
copy_file(path, target, follow_symlinks=True)
|
||||
return target
|
||||
return path
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue