[unpackfs] Enable to use "/" as a source

If we don't have/need an image for the rootfs, we might want to
configure the `/` directory as a source for unpackfs. Unfortunately,
this raises an error:
  - unpackfs first creates a temporary directory
  - it then creates a subdirectory for each source, using the source
path's basename
  - when the source is `/`, the basename is an empty string, therefore
the module tries to create an already existing directory

In order to prevent this error, we use the `os.makedirs` function with
parameter `exist_ok=True` instead of `os.mkdir`.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
This commit is contained in:
Arnaud Ferraris 2019-08-23 17:26:45 +02:00
parent d422c782ba
commit 0f6b2dbe2d

View File

@ -208,7 +208,7 @@ class UnpackOperation:
imgbasename = os.path.splitext(
os.path.basename(entry.source))[0]
imgmountdir = os.path.join(source_mount_path, imgbasename)
os.mkdir(imgmountdir)
os.makedirs(imgmountdir, exist_ok=True)
self.mount_image(entry, imgmountdir)