Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit dde1fa167e4a6504b7255d68279827b36f97a190
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Oct 23 23:13:19 2014 +0200
[backend] createrepo should create dest_dir for createrepo_c
---------------------------------------------------------------
backend/backend/createrepo.py | 7 +++++--
backend/tests/test_createrepo.py | 16 ++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/backend/backend/createrepo.py b/backend/backend/createrepo.py
index 31532c4..fc6f5c7 100644
--- a/backend/backend/createrepo.py
+++ b/backend/backend/createrepo.py
@@ -18,8 +18,8 @@ def createrepo_unsafe(path, lock=None, dest_dir=None, base_url=None):
:param string path: target location to create repo
:param lock: [optional]
- :param str dest_dir: [optional] target location for repomd, in most cases
- you should also provide base_url
+ :param str dest_dir: [optional] relative to path location for repomd, in most cases
+ you should also provide base_url.
:param str base_url: optional parameter for createrepo_c, "--baseurl"
:return tuple: (return_code, stdout, stderr)
@@ -34,6 +34,9 @@ def createrepo_unsafe(path, lock=None, dest_dir=None, base_url=None):
if dest_dir:
comm.extend(['--outputdir', dest_dir])
+ dest_dir_path = os.path.join(path, dest_dir)
+ if not os.path.exists(dest_dir_path):
+ os.makedirs(dest_dir_path)
if base_url:
comm.extend(['--baseurl', base_url])
diff --git a/backend/tests/test_createrepo.py b/backend/tests/test_createrepo.py
index d9e8d8f..ea6b2b4 100644
--- a/backend/tests/test_createrepo.py
+++ b/backend/tests/test_createrepo.py
@@ -158,3 +158,19 @@ class TestCreaterepoUnsafe(object):
createrepo_unsafe(path, lock=None, base_url="../",
dest_dir="devel")
assert mc_popen.call_args == mock.call(expected, stderr=-1, stdout=-1)
+
+ def test_createrepo_devel_creates_folder(self, mc_popen):
+
+ mc_popen.return_value.communicate.return_value = ("", "")
+ path_epel_5 = os.path.join(self.tmp_dir_name, "epel-5")
+ expected_epel_5 = ['/usr/bin/createrepo_c', '--database',
'--ignore-lock',
+ '-s', 'sha', '--checksum',
'md5',
+ '--outputdir', 'devel', '--baseurl',
'../', path_epel_5]
+ path_fedora = os.path.join(self.tmp_dir_name, "fedora-21")
+ expected_fedora = ['/usr/bin/createrepo_c', '--database',
'--ignore-lock',
+ '--outputdir', 'devel', '--baseurl',
'../', path_fedora]
+ for path, expected in [(path_epel_5, expected_epel_5), (path_fedora,
expected_fedora)]:
+ os.makedirs(path)
+
+ createrepo_unsafe(path, lock=None, base_url="../",
dest_dir="devel")
+ assert os.path.exists(os.path.join(path, "devel"))