client/tools/rhncfg/config_client/rhncfgcli_diff.py | 18 +++++++++++-------
client/tools/rhncfg/config_client/rhncfgcli_list.py | 2 +-
client/tools/rhncfg/config_common/file_utils.py | 7 ++++---
3 files changed, 16 insertions(+), 11 deletions(-)
New commits:
commit 145edafbeb6da83bbfbc612da1c6a406712af34a
Author: Partha Aji <paji(a)redhat.com>
Date: Thu Jul 29 19:07:55 2010 -0400
Made the diff in operation rhncfg client work with symlinks
diff --git a/client/tools/rhncfg/config_client/rhncfgcli_diff.py b/client/tools/rhncfg/config_client/rhncfgcli_diff.py
index 4d1d29d..10c928a 100644
--- a/client/tools/rhncfg/config_client/rhncfgcli_diff.py
+++ b/client/tools/rhncfg/config_client/rhncfgcli_diff.py
@@ -15,7 +15,7 @@
import sys
import os
-
+import os.path
from config_common import utils
from config_common.rhn_log import log_debug
@@ -24,9 +24,8 @@ import handler_base
class Handler(handler_base.HandlerBase):
_usage_options = handler_base.HandlerBase._usage_options + " [ files ... ]"
def _process_file(self, *args):
- src, dst = args[:2]
- type = args[3]
-
+ src, dst= args [:2]
+ type = args[3]
# label for diff output. this lets 'patch -R' properly apply
# a patch to update to known version and have proper lsdiff
# output. also gets rid of /tmp/@blah in diff output.
@@ -35,11 +34,16 @@ class Handler(handler_base.HandlerBase):
if type == 'directory':
#dst is a directory, so just tell the user we're skipping the entry
print "Entry \'%s\' is a directory, skipping" % dst
- return
elif type == 'symlink':
#dst is a symlink, so just tell the user we're skipping the entry
- print "Entry \'%s\' is a symbolic link, skipping" % dst
- return
+ srclink = os.path.abspath(os.readlink(src))
+ destlink = os.path.abspath(os.readlink(dst))
+ if srclink == destlink:
+ print "No change between the symbolic links '%s' " % dst
+ else:
+ print "Symbolic link targets are different."
+ print "Channel: '%s' -> '%s' System: '%s' -> '%s' " % (dst,srclink, dst, destlink)
+
else:
# if file isn't present, compare to /dev/null so we see the
# whole thing in the diff
diff --git a/client/tools/rhncfg/config_client/rhncfgcli_list.py b/client/tools/rhncfg/config_client/rhncfgcli_list.py
index ae597b2..a79501f 100644
--- a/client/tools/rhncfg/config_client/rhncfgcli_list.py
+++ b/client/tools/rhncfg/config_client/rhncfgcli_list.py
@@ -32,7 +32,7 @@ class Handler(handler_base.HandlerBase):
maxlen = max(map(lambda s: len(s[0]), files))
maxlen = max(maxlen, len(label)) + 2
- print "DoF %*s %s" % (maxlen, label, "File")
+ print "DoFoS %*s %s" % (maxlen, label, "File")
for file in files:
# checking to see if the filetype is in the 'file' entry,
# and if it is and that type is '1', it is a file
diff --git a/client/tools/rhncfg/config_common/file_utils.py b/client/tools/rhncfg/config_common/file_utils.py
index 971224e..6325c39 100644
--- a/client/tools/rhncfg/config_common/file_utils.py
+++ b/client/tools/rhncfg/config_common/file_utils.py
@@ -14,6 +14,7 @@
#
import os
+import os.path
import time
import tempfile
import base64
@@ -103,12 +104,12 @@ class FileProcessor:
if file_struct['filetype'] == 'symlink':
try:
- curlink = os.readlink(path)
- newlink = os.readlink(temp_file)
+ curlink = os.path.abspath(os.readlink(path))
+ newlink = os.path.abspath(os.readlink(temp_file))
if curlink == newlink:
result = ''
else:
- result = "Link targets differ: actual: [%s], expected: [%s]\n" % (curlink, newlink)
+ result = "Link targets differ for [%s]: actual: [%s], expected: [%s]\n" % (path, curlink, newlink)
except OSError, e:
if e.errno == 22:
result = "Deployed symlink is no longer a symlink!"