mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 19:57:37 +08:00
Fix #467 - Inject modules.yaml to mock repository
This commit is contained in:
@@ -47,6 +47,7 @@ import xmlrpclib
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
|
import yaml
|
||||||
|
|
||||||
import munch
|
import munch
|
||||||
from OpenSSL.SSL import SysCallError
|
from OpenSSL.SSL import SysCallError
|
||||||
@@ -1288,14 +1289,24 @@ mdpolicy=group:primary
|
|||||||
"""
|
"""
|
||||||
log.debug("Creating repository in %s" % self.resultsdir)
|
log.debug("Creating repository in %s" % self.resultsdir)
|
||||||
path = self.resultsdir
|
path = self.resultsdir
|
||||||
if os.path.exists(path + '/repodata/repomd.xml'):
|
repodata_path = os.path.join(path, "repodata")
|
||||||
comm = ['/usr/bin/createrepo_c', '--update', path]
|
|
||||||
else:
|
# Remove old repodata files
|
||||||
comm = ['/usr/bin/createrepo_c', path]
|
if os.path.exists(repodata_path):
|
||||||
cmd = subprocess.Popen(
|
for name in os.listdir(repodata_path):
|
||||||
comm, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
os.remove(os.path.join(repodata_path, name))
|
||||||
out, err = cmd.communicate()
|
|
||||||
return out, err
|
# Generate the mmd the same way as pungi does.
|
||||||
|
m1 = ModuleBuild.query.filter(ModuleBuild.name == self.module_str).one()
|
||||||
|
modules = {"modules": []}
|
||||||
|
modules["modules"].append(yaml.safe_load(m1.mmd().dumps()))
|
||||||
|
mmd_path = os.path.join(path, "modules.yaml")
|
||||||
|
with open(mmd_path, "w") as outfile:
|
||||||
|
outfile.write(yaml.safe_dump(modules))
|
||||||
|
|
||||||
|
# Generate repo and inject modules.yaml there.
|
||||||
|
_execute_cmd(['/usr/bin/createrepo_c', path])
|
||||||
|
_execute_cmd(['/usr/bin/modifyrepo_c', '--mdtype=modules', mmd_path, repodata_path])
|
||||||
|
|
||||||
def _add_repo(self, name, baseurl, extra = ""):
|
def _add_repo(self, name, baseurl, extra = ""):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user