summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-04-13 12:18:33 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-04-13 12:18:33 -0400
commitb4f9f91a9eca52ec73aba8d6dcaa136fc12035e6 (patch)
tree45d52afc7d39c39e660e4ac494c71e0edfb4969f
parentb274d671a4f2cf5ae35724c4fd496c33c05b12c6 (diff)
downloadthird_party-cobbler-b4f9f91a9eca52ec73aba8d6dcaa136fc12035e6.tar.gz
third_party-cobbler-b4f9f91a9eca52ec73aba8d6dcaa136fc12035e6.tar.xz
third_party-cobbler-b4f9f91a9eca52ec73aba8d6dcaa136fc12035e6.zip
More generalized fix to aborted-createrepo ".olddata" problems, which now
applies to "cobbler reposync" as well as "cobbler import".
-rw-r--r--CHANGELOG2
-rw-r--r--cobbler/action_import.py11
-rw-r--r--cobbler/action_reposync.py2
-rw-r--r--cobbler/utils.py17
4 files changed, 22 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 8d8800c..2ab4955 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,8 @@ Cobbler CHANGELOG
- Kickstart tracking now understands Apache logs
- Added support for --rpm-list parameter to "repo add" for download of partial content from repositories
(ex: cobbler and koan from FC6extras, w/o games).
+- More consistant naming on imports, regardless of data source.
+- Teach cobbler to remove .olddata dirs, which can happen if createrepo crashes or is killed mid-process
* Thu Apr 05 2007 - 0.4.6
- Bind cobbler_syslogd to all addresses
diff --git a/cobbler/action_import.py b/cobbler/action_import.py
index bdfc364..83874e3 100644
--- a/cobbler/action_import.py
+++ b/cobbler/action_import.py
@@ -20,8 +20,8 @@ import os.path
import traceback
import sub_process
import glob
-import shutil
import api
+import utils
WGET_CMD = "wget --mirror --no-parent --no-host-directories --directory-prefix %s/%s %s"
RSYNC_CMD = "rsync -a %s %s %s/ks_mirror/%s --exclude-from=/etc/cobbler/rsync.exclude --delete --delete-excluded --progress"
@@ -331,14 +331,7 @@ class Importer:
# don't run creatrepo twice -- this can happen easily for Xen and PXE, when
# they'll share same repo files.
if not self.processed_repos.has_key(comps_path):
- bad = os.path.join(comps_path, "repodata", ".olddata")
- bad2 = os.path.join(comps_path, ".olddata")
- if os.path.exists(bad):
- print "- removing .olddata: %s" % bad
- shutil.rmtree(bad, ignore_errors=False, onerror=None)
- if os.path.exists(bad2):
- print "- removing .olddata: %s" % bad
- shutil.rmtree(bad2, ignore_errors=False, onerror=None)
+ utils.remove_yum_olddata(comps_path)
cmd = "createrepo --basedir / --groupfile %s %s" % (os.path.join(comps_path, "repodata", comps_file), comps_path)
print "- %s" % cmd
sub_process.call(cmd,shell=True)
diff --git a/cobbler/action_reposync.py b/cobbler/action_reposync.py
index 1801071..f0febd8 100644
--- a/cobbler/action_reposync.py
+++ b/cobbler/action_reposync.py
@@ -15,7 +15,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
import os.path
-import shutil
import time
import yaml # Howell-Clark version
import sub_process
@@ -250,6 +249,7 @@ class RepoSync:
target_dir = os.path.dirname(dirname).split("/")[-1]
print "- scanning: %s" % target_dir
if target_dir.lower() in [ "i386", "x86_64", "ia64" ] or (arg is None):
+ utils.remove_yum_olddata(dirname)
try:
cmd = "createrepo %s" % dirname
print cmd
diff --git a/cobbler/utils.py b/cobbler/utils.py
index 8b678a5..40a558f 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -17,6 +17,7 @@ import re
import socket
import glob
import sub_process
+import shutil
_re_kernel = re.compile(r'vmlinuz(.*)')
_re_initrd = re.compile(r'initrd(.*).img')
@@ -137,6 +138,22 @@ def find_kernel(path):
return find_highest_files(path,"vmlinuz",_re_kernel)
return None
+def remove_yum_olddata(path):
+ """
+ Delete .olddata files that might be present from a failed run
+ of createrepo.
+ """
+ trythese = [
+ ".olddata",
+ ".repodata/.olddata",
+ "repodata/.oldata",
+ "repodata/repodata"
+ ]
+ for pathseg in trythese:
+ olddata = os.path.join(path, pathseg)
+ if os.path.exists(olddata):
+ print "- removing: %s" % olddata
+ shutil.rmtree(olddata, ignore_errors=False, onerror=None)
def find_initrd(path):
"""