added current gentooimgr

This commit is contained in:
embed@git.macaw.me
2023-12-21 18:53:25 +00:00
parent 349f2b9dea
commit f7303dce15
25 changed files with 6993 additions and 0 deletions

15
gentooimgr/shrink.py Normal file
View File

@@ -0,0 +1,15 @@
import os
import datetime
from subprocess import PIPE, Popen
def shrink(args, config, stamp=None):
if stamp is None:
dt = datetime.datetime.utcnow()
# 0 padded month and day timestamp
stamp = f"{dt.year}-{dt.month:02d}-{dt.day:02d}"
name, ext = os.path.splitext(config.get("imagename") or args.img)
# ext includes the .
filename = f"{name}-{stamp}{ext}"
proc = Popen(["virt-sparsify", "--compress", args.img, filename])
proc.communicate()
return filename