summaryrefslogtreecommitdiffstats
path: root/src/virtBootstrap/utils.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-12-07 20:42:28 +0000
committerRadostin Stoyanov <rstoyanov1@gmail.com>2017-12-12 17:38:35 +0000
commit76a945f9f2b88407bac8f7a8cc0d1464db183f21 (patch)
treeda31cd76bb0149365269a65683e8da1db78b1806 /src/virtBootstrap/utils.py
parentb38f588c76ad0541ae10fd2aa71677d5e19813d3 (diff)
downloadvirt-bootstrap.git-76a945f9f2b88407bac8f7a8cc0d1464db183f21.tar.gz
virt-bootstrap.git-76a945f9f2b88407bac8f7a8cc0d1464db183f21.tar.xz
virt-bootstrap.git-76a945f9f2b88407bac8f7a8cc0d1464db183f21.zip
docker-source: Avoid skopeo copy in cache
The `skopeo copy` command has changed it's behaviour to keep only a files for single container image per directory. To get around this and keep cache of downloaded images is used temporary destination directory for 'skopeo copy' and image files are then moved in the cache folder.
Diffstat (limited to 'src/virtBootstrap/utils.py')
-rw-r--r--src/virtBootstrap/utils.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/virtBootstrap/utils.py b/src/virtBootstrap/utils.py
index 20a59d2..ec6a96e 100644
--- a/src/virtBootstrap/utils.py
+++ b/src/virtBootstrap/utils.py
@@ -32,6 +32,7 @@ import subprocess
import sys
import tempfile
import logging
+import shutil
import passlib.hosts
@@ -355,6 +356,19 @@ def get_mime_type(path):
return output.read().decode('utf-8').split()[1]
+def copytree(src, dst, symlinks=False, ignore=None):
+ """
+ Copy an entire directory of files into an existing directory.
+ """
+ for item in os.listdir(src):
+ src_item = os.path.join(src, item)
+ dst_item = os.path.join(dst, item)
+ if os.path.isdir(src_item):
+ shutil.copytree(src_item, dst_item, symlinks, ignore)
+ else:
+ shutil.copy2(src_item, dst_item)
+
+
def get_image_dir(no_cache=False):
"""
Get the directory where image layers are stored.