livemedia-creator: Copy fsimage if hardlink fails (#1144140)

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.

(cherry picked from commit b3e80b7564)

Related: rhbz#1144140
This commit is contained in:
Brian C. Lane 2014-04-25 09:11:54 -07:00
parent 4a05a02fe6
commit 0a9992267c

View File

@ -665,8 +665,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"))