From bbe928f34093582d3ee2fee2eca8efe8eb968bf0 Mon Sep 17 00:00:00 2001 From: Fierelier Date: Sat, 22 Apr 2023 17:15:32 +0200 Subject: [PATCH] Allow swap creation to fail --- .../data/opt/wdvn/installer/main | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mods/live-installer/data/opt/wdvn/installer/main b/mods/live-installer/data/opt/wdvn/installer/main index 7db321e..f0b0256 100755 --- a/mods/live-installer/data/opt/wdvn/installer/main +++ b/mods/live-installer/data/opt/wdvn/installer/main @@ -318,10 +318,19 @@ def main(): print("> Adding files") print("Creating swap ...") - call(["dd","if=/dev/zero","of=" +ipth("swap"),"bs=1M","count=512","status=progress"]) - call(["chmod","600",ipth("swap")]) - call(["mkswap",ipth("swap")]) - call(["swapon",ipth("swap")]) + hasSwap = False + try: + call(["dd","if=/dev/zero","of=" +ipth("swap"),"bs=1M","count=512","status=progress"]) + call(["chmod","600",ipth("swap")]) + call(["mkswap",ipth("swap")]) + call(["swapon",ipth("swap")]) + except Exception as e: + print(e) + print("Creating swap failed, skipping.") + try: + os.remove(ipth("swap")) + except Exception: + pass print("Unpacking OS ...") call(["unsquashfs","-f","-d",ipth(),"/lib/live/mount/medium/live/filesystem.squashfs"]) @@ -347,7 +356,7 @@ def main(): print("Writing fstab ...") fh = open(ipth("etc/fstab"),"w") fh.write('UUID=' +installPartitionUUID+ ' / ' +getPartitionType(installPartition)+ ' defaults 0 1\n') - fh.write('/swap none swap sw 0 0\n') + if hasSwap: fh.write('/swap none swap sw 0 0\n') fh.close() print("Copying keyboard settings ...") @@ -399,7 +408,7 @@ def main(): chroot(ipth(),["update-grub"]) print("> Unmounting ...") - call(["swapoff",ipth("swap")]) + if hasSwap: call(["swapoff",ipth("swap")]) call(["umount",ipth()]) os.rmdir(ipth()) if encrypt: call(["cryptsetup","luksClose","system"])