From 0f6b2dbe2dd8766c3fb581fe0027467dc98255d8 Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Fri, 23 Aug 2019 17:26:45 +0200 Subject: [PATCH] [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 --- src/modules/unpackfs/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index e956dc070..90c258cd7 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -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)