| |
@@ -102,6 +102,9 @@
|
| |
self.resultsdir = os.path.join(self.tag_dir, "results")
|
| |
if not os.path.exists(self.resultsdir):
|
| |
os.makedirs(self.resultsdir)
|
| |
+ # generate repodata even it's an empty repo, otherwise it can
|
| |
+ # cause yum error for our first build due to missing repodata
|
| |
+ execute_cmd(["/usr/bin/createrepo_c", self.resultsdir])
|
| |
|
| |
# Create "config" sub-directory.
|
| |
self.configdir = os.path.join(self.tag_dir, "config")
|
| |
@@ -115,13 +118,18 @@
|
| |
# before the first build is done, otherwise we would remove files
|
| |
# which we already build in this module build.
|
| |
if MockModuleBuilder._build_id == 1:
|
| |
+ removed_rpms = 0
|
| |
# Remove all RPMs from the results directory, but keep old logs.
|
| |
for name in os.listdir(self.resultsdir):
|
| |
if name.endswith(".rpm"):
|
| |
os.remove(os.path.join(self.resultsdir, name))
|
| |
+ removed_rpms = removed_rpms + 1
|
| |
|
| |
- # Remove the old RPM repository from the results directory.
|
| |
- if os.path.exists(os.path.join(self.resultsdir, "repodata/repomd.xml")):
|
| |
+ # Remove the old RPM repository from the results directory. However
|
| |
+ # if there was no rpms removed, assume we're preparing for the first
|
| |
+ # build and the resultsdir is empty at this moment.
|
| |
+ repomd_path = os.path.join(self.resultsdir, "repodata/repomd.xml")
|
| |
+ if os.path.exists(repomd_path) and removed_rpms > 0:
|
| |
os.remove(os.path.join(self.resultsdir, "repodata/repomd.xml"))
|
| |
|
| |
# Remove old config files from config directory.
|
| |
When preparing for the first build, the resultsdir is empty, mock
command will fail due to missing repodata in 'localrepo'.
Some koji tags don't have any package or build at all, this can
result in an empty local repo created from the tags, and it can cause
mock failure.
So we create repodata for the empty repo just after it is created.