>From the changelog:

  2006-07-20 13:20  pnasrat

    * genpkgmetadata.py: Move to split basedir and directory everywhere
      to preserve command line paths.  Use os.path.walk rather than our
      own implementation Improve error messages

>From the os.path.walk docs:

  Symbolic links to directories are not treated as subdirectories, and that
  walk() therefore will not visit them. To visit linked directories you must
  identify them with os.path.islink(file) and os.path.isdir(file), and
  invoke walk() as necessary.

Urgh. This breaks things for us, since we use symlinks to work around some
AFS, uh, "quirks".

The attached patch fixes this. Also, it fixes bugs in the --skip-symlinks
test and in the isdir test -- os.path.walk doesn't change the working
directory, so the tests against plain file basenames weren't useful.
Actually, worse than that -- if the test happened to match a file in the
directory from which you run createrepo, those files would be skipped --
surprise!

Caveat -- as the os.walk documentation notes, the reason symlinked
directories aren't followed by default is to avoid infinite loops. This
patch adds nothing to avoid that. Probably a hash of visited real
directories should be created and checked against to avoid this. In the
meantime, either use --skip-symlinks or fix the loop.




-- 
Matthew Miller           [EMAIL PROTECTED]          <http://mattdm.org/>
Boston University Linux      ------>              <http://linux.bu.edu/>
--- createrepo/genpkgmetadata.py.20070803       2007-06-07 06:33:34.000000000 
-0400
+++ createrepo/genpkgmetadata.py        2007-08-03 15:36:17.000000000 -0400
@@ -83,11 +83,15 @@
 
         def extension_visitor(filelist, dirname, names):
             for fn in names:
-                if os.path.isdir(fn):
+                if os.path.islink(dirname + '/' + fn):
+                    if self.cmds['skip-symlinks']:
+                        continue
+                    elif os.path.isdir(dirname + '/' + fn):
+                        os.path.walk(dirname + '/' + fn, extension_visitor, 
filelist)
+                        continue
+                elif os.path.isdir(dirname + '/' + fn):
                     continue
-                if self.cmds['skip-symlinks'] and os.path.islink(fn):
-                    continue
-                elif fn[-extlen:].lower() == '%s' % (ext):
+                if fn[-extlen:].lower() == '%s' % (ext):
                     relativepath = dirname.replace(startdir, "", 1)
                     relativepath = relativepath.lstrip("/")
                     filelist.append(os.path.join(relativepath,fn))
@@ -325,9 +329,15 @@
 
         def extension_visitor(arg, dirname, names):
             for fn in names:
-                if os.path.isdir(fn):
+                if os.path.islink(dirname + '/' + fn):
+                    if self.cmds['skip-symlinks']:
+                        continue
+                    elif os.path.isdir(dirname + '/' + fn):
+                        os.path.walk(dirname + '/' + fn, extension_visitor, 
arg)
+                        continue
+                elif os.path.isdir(dirname + '/' + fn):
                     continue
-                elif string.lower(fn[-extlen:]) == '%s' % (ext):
+                if string.lower(fn[-extlen:]) == '%s' % (ext):
                     reldir = os.path.basename(dirname)
                     if reldir == os.path.basename(directory):
                         reldir = ""
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to