Add: --force option to delete existing package
This commit is contained in:
parent
6a6d439aa2
commit
56bd015690
5 changed files with 69 additions and 10 deletions
|
|
@ -27,12 +27,13 @@ class Package:
|
|||
def generate_manifest(self):
|
||||
install_root = self.tmp_dir / "tmp"
|
||||
for path in install_root.rglob("*"):
|
||||
rel_path = Path("/") / path.relative_to(install_root)
|
||||
stat = path.lstat()
|
||||
user = pwd.getpwuid(stat.st_uid).pw_name
|
||||
group = grp.getgrgid(stat.st_gid).gr_name
|
||||
|
||||
if path.is_file():
|
||||
rel_path = Path("/") / path.relative_to(install_root)
|
||||
stat = path.stat()
|
||||
md5 = hashlib.md5(path.read_bytes()).hexdigest()
|
||||
user = pwd.getpwuid(stat.st_uid).pw_name
|
||||
group = grp.getgrgid(stat.st_gid).gr_name
|
||||
self.manifest.append(
|
||||
{
|
||||
"path": str(rel_path),
|
||||
|
|
@ -40,6 +41,18 @@ class Package:
|
|||
"mode": oct(stat.st_mode & 0o777),
|
||||
"user": user,
|
||||
"group": group,
|
||||
"type": "file",
|
||||
}
|
||||
)
|
||||
elif path.is_dir():
|
||||
self.manifest.append(
|
||||
{
|
||||
"path": str(rel_path),
|
||||
"md5": "-", # pas de hash pour les dossiers
|
||||
"mode": oct(stat.st_mode & 0o777),
|
||||
"user": user,
|
||||
"group": group,
|
||||
"type": "dir",
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -48,7 +61,7 @@ class Package:
|
|||
with open(manifest_path, "w") as f:
|
||||
for entry in self.manifest:
|
||||
f.write(
|
||||
f"{entry['path']} {entry['md5']} {entry['mode']} {entry['user']} {entry['group']}\n"
|
||||
f"{entry['type']} {entry['path']} {entry['md5']} {entry['mode']} {entry['user']} {entry['group']}\n"
|
||||
)
|
||||
|
||||
def copy_pakva(self, pakva_path):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue