livemedia-creator: Copy fsimage if hardlink fails

If the user supplies a fsimage to use for the iso it may not be on the
same filesystem as the working directory. Try to hardlink first, but if
that fails copy the image.
This commit is contained in:
Brian C. Lane 2014-04-25 09:11:54 -07:00
parent 08d8f3b2fc
commit b3e80b7564
1 changed files with 5 additions and 2 deletions

View File

@ -701,8 +701,11 @@ def make_squashfs(disk_img, work_dir, compression="xz"):
liveos_dir = joinpaths(work_dir, "runtime/LiveOS")
os.makedirs(liveos_dir)
os.makedirs(os.path.dirname(joinpaths(work_dir, RUNTIME)))
execWithRedirect("/bin/ln", [disk_img,
joinpaths(liveos_dir, "rootfs.img")])
rc = execWithRedirect("/bin/ln", [disk_img, joinpaths(liveos_dir, "rootfs.img")])
if rc != 0:
shutil.copy2(disk_img, joinpaths(liveos_dir, "rootfs.img"))
mksquashfs(joinpaths(work_dir, "runtime"),
joinpaths(work_dir, RUNTIME), compression)
remove(joinpaths(work_dir, "runtime"))