Skip to content

Commit 34a14df

Browse files
Merge pull request FEX-Emu#27 from asahi-alarm/output_flags
Add `-no-repack-[tar|erofs|squashfs]` flags
2 parents aead21e + ca625ee commit 34a14df

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

build_image.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -475,23 +475,29 @@ def Stage2(CacheDir, RootFSDir, config_json):
475475
print ("Exec: '{}'".format(command))
476476
os.system(command)
477477

478-
print("Repackaging image")
479-
if os.system("tar {} -cf ../Stage2_{} *".format(PIGZPrompt, config_json["Guest_Image"])) != 0:
480-
raise Exception("tar failure")
478+
if not args.no_repack_tar:
479+
print("Repackaging image")
480+
if os.system("tar {} -cf ../Stage2_{} *".format(PIGZPrompt, config_json["Guest_Image"])) != 0:
481+
raise Exception("tar failure")
481482

482483
os.chdir(OldDir)
483484

484-
print("Repackaging image to SquashsFS")
485-
if os.system("mksquashfs " + Stage1_RootFS + " " + SquashFSTarget + " -comp zstd -no-xattrs") != 0:
486-
raise Exception("mksquashfs failure")
485+
if not args.no_repack_squashfs:
486+
print("Repackaging image to SquashsFS")
487+
if os.system("mksquashfs " + Stage1_RootFS + " " + SquashFSTarget + " -comp zstd -no-xattrs") != 0:
488+
raise Exception("mksquashfs failure")
487489

488-
print("Repackaging image to EroFS. Using LZ4HC compression level 12. Might take a while!")
489-
if os.system("mkfs.erofs -x-1 -zlz4hc,12 " + EroFSTarget + " " + Stage1_RootFS) != 0:
490-
raise Exception("mkfs.erofs failure")
490+
if not args.no_repack_erofs:
491+
print("Repackaging image to EroFS. Using LZ4HC compression level 12. Might take a while!")
492+
if os.system("mkfs.erofs -x-1 -zlz4hc,12 " + EroFSTarget + " " + Stage1_RootFS) != 0:
493+
raise Exception("mkfs.erofs failure")
491494

492-
print("Completed image now at %s" % ("Stage2_" + config_json["Guest_Image"]))
493-
print("Completed squashfs image now at %s" % (config_json["ImageName"] + ".sqsh"))
494-
print("Completed EroFS image now at %s" % (config_json["ImageName"] + ".ero"))
495+
if not args.no_repack_tar:
496+
print("Completed image now at %s" % ("Stage2_" + config_json["Guest_Image"]))
497+
if not args.no_repack_squashfs:
498+
print("Completed squashfs image now at %s" % (config_json["ImageName"] + ".sqsh"))
499+
if not args.no_repack_erofs:
500+
print("Completed EroFS image now at %s" % (config_json["ImageName"] + ".ero"))
495501

496502
def CheckPrograms():
497503
Missing = False
@@ -504,13 +510,16 @@ def CheckPrograms():
504510
# Argument parser setup
505511
parser = argparse.ArgumentParser(
506512
description="Script to configure and build a RootFS using QEMU with specified settings.",
507-
usage="%(prog)s [-m <memory>] [-disable-kvm] <Config.json> <Cache directory> <RootFS Dir>"
513+
usage="%(prog)s [-m <memory>] [-disable-kvm] [-no-repack-tar] [-no-repack-squashfs] [-no-repack-erofs] <Config.json> <Cache directory> <RootFS Dir>"
508514
)
509515
parser.add_argument("config", type=str, help="Path to a RootFS config .json file")
510516
parser.add_argument("cache_dir", type=str, help="Cache directory")
511517
parser.add_argument("rootfs_dir", type=str, help="RootFS directory")
512518
parser.add_argument("-m", type=str, help="Memory size for QEMU (e.g., 2G, 512M, etc.)", default="32G")
513519
parser.add_argument("-disable-kvm", action="store_true", help="Disable KVM in QEMU")
520+
parser.add_argument("-no-repack-tar", action="store_true", help="Do not repackage into a tar archive")
521+
parser.add_argument("-no-repack-squashfs", action="store_true", help="Do not repackage into a SquashFS image")
522+
parser.add_argument("-no-repack-erofs", action="store_true", help="Do not repackage into a EroFS image")
514523

515524
args = parser.parse_args()
516525

0 commit comments

Comments
 (0)