commit:     dd377fc68bfb78c283d35b2173b47ce4837b0d35
Author:     André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Jun 25 16:06:00 2014 +0000
Commit:     André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Jun 25 16:06:00 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=dd377fc6

distroot, handle_file_collision(): restore src_uri_dest

... if the file collision cannot be resolved

Also adds some safety checks (distfile name must not be empty and should not
be rename_prefix).

---
 roverlay/overlay/pkgdir/distroot/distroot.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/roverlay/overlay/pkgdir/distroot/distroot.py 
b/roverlay/overlay/pkgdir/distroot/distroot.py
index 654c1f6..9872aad 100644
--- a/roverlay/overlay/pkgdir/distroot/distroot.py
+++ b/roverlay/overlay/pkgdir/distroot/distroot.py
@@ -657,22 +657,33 @@ class PersistentDistroot ( DistrootBase ):
       if self.distmap.get_distfile_slot ( package_dir, package_info ):
          return True
       else:
-         distfile      = package_info.get_src_uri_dest().rpartition ( os.sep )
-         rename_prefix = package_info ['repo_name'].lower() + '_'
-
-         if distfile[2][:len(rename_prefix)] == rename_prefix:
+         orig_src_uri_dest = package_info.get_src_uri_dest()
+         # distfile_dirname, distfile_os_sep, distfile_basename
+         distfile          = orig_src_uri_dest.rpartition ( os.sep )
+         rename_prefix     = package_info ['repo_name'].lower() + '_'
+         rename_prefix_len = len ( rename_prefix )
+
+         assert distfile[2]
+
+         if (
+            len(distfile[2]) > rename_prefix_len
+            and distfile[2][:rename_prefix_len] == rename_prefix
+         ):
             # already prefixed with the repo name
             return False
+
          else:
             package_info.update (
                src_uri_dest=(
                   distfile[0] + distfile[1] + rename_prefix + distfile[2]
                )
             )
-            #return self.distmap.get_distfile_slot(...)
+
             if self.distmap.get_distfile_slot ( package_dir, package_info ):
                return True
             else:
+               # restore src_uri_dest
+               package_info.update ( src_uri_dest=orig_src_uri_dest )
                return False
    # --- end of handle_file_collision (...) ---
 

Reply via email to