Allow swap creation to fail
This commit is contained in:
parent
1a39cffd68
commit
bbe928f340
@ -318,10 +318,19 @@ def main():
|
|||||||
|
|
||||||
print("> Adding files")
|
print("> Adding files")
|
||||||
print("Creating swap ...")
|
print("Creating swap ...")
|
||||||
call(["dd","if=/dev/zero","of=" +ipth("swap"),"bs=1M","count=512","status=progress"])
|
hasSwap = False
|
||||||
call(["chmod","600",ipth("swap")])
|
try:
|
||||||
call(["mkswap",ipth("swap")])
|
call(["dd","if=/dev/zero","of=" +ipth("swap"),"bs=1M","count=512","status=progress"])
|
||||||
call(["swapon",ipth("swap")])
|
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 ...")
|
print("Unpacking OS ...")
|
||||||
call(["unsquashfs","-f","-d",ipth(),"/lib/live/mount/medium/live/filesystem.squashfs"])
|
call(["unsquashfs","-f","-d",ipth(),"/lib/live/mount/medium/live/filesystem.squashfs"])
|
||||||
@ -347,7 +356,7 @@ def main():
|
|||||||
print("Writing fstab ...")
|
print("Writing fstab ...")
|
||||||
fh = open(ipth("etc/fstab"),"w")
|
fh = open(ipth("etc/fstab"),"w")
|
||||||
fh.write('UUID=' +installPartitionUUID+ ' / ' +getPartitionType(installPartition)+ ' defaults 0 1\n')
|
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()
|
fh.close()
|
||||||
|
|
||||||
print("Copying keyboard settings ...")
|
print("Copying keyboard settings ...")
|
||||||
@ -399,7 +408,7 @@ def main():
|
|||||||
chroot(ipth(),["update-grub"])
|
chroot(ipth(),["update-grub"])
|
||||||
|
|
||||||
print("> Unmounting ...")
|
print("> Unmounting ...")
|
||||||
call(["swapoff",ipth("swap")])
|
if hasSwap: call(["swapoff",ipth("swap")])
|
||||||
call(["umount",ipth()])
|
call(["umount",ipth()])
|
||||||
os.rmdir(ipth())
|
os.rmdir(ipth())
|
||||||
if encrypt: call(["cryptsetup","luksClose","system"])
|
if encrypt: call(["cryptsetup","luksClose","system"])
|
||||||
|
Loading…
Reference in New Issue
Block a user