Merged from trunk -r15154:15166
authorFabian Groffen <grobian@gentoo.org>
Tue, 5 Jan 2010 19:23:45 +0000 (19:23 -0000)
committerFabian Groffen <grobian@gentoo.org>
Tue, 5 Jan 2010 19:23:45 +0000 (19:23 -0000)
   | 15155   | Add some tests related to bug #287848.                       |
   | zmedico |                                                              |

   | 15156   | Use get_term_size() to adjust to current terminal width.     |
   | zmedico | Thanks to Dror Levin <spatz@g.0> for the initial patch.      |

   | 15157   | Document doins -r option.                                    |
   | zmedico |                                                              |

   | 15158   | Bug #299248 - Fix doins return code handling to make sure it |
   | zmedico | always fails when appropriate. Thanks to Jonathan Callen     |
   |         | <abcd@g.o> for the initial patch.                            |

   | 15159   | Bug #298310 - Make sure the _selinux attribute is correctly  |
   | zmedico | reinitialized after reload(portage) is called.               |

   | 15160   | Add test cases for implicit .0 at end of version.            |
   | zmedico |                                                              |

   | 15161   | Revert vercmp() behavior so 12.2b > 12.2.5 which was         |
   | zmedico | accidentally changed in r2309 (between portage-2.0.x and     |
   |         | portage-2.1). Thanks to Brian Harring for reporting in bug   |
   |         | #287848, comment #3.                                         |

   | 15162   | Fix vercmp so 1b > 1 and add corresponding tests.            |
   | zmedico |                                                              |

   | 15163   | Add test cases for cvs versions.                             |
   | zmedico |                                                              |

   | 15164   | Add some more cases for versions with letter suffixes.       |
   | zmedico |                                                              |

   | 15165   | More cases.                                                  |
   | zmedico |                                                              |

   | 15166   | Revert r15161 so 12.2.5 is greater than 12.2b once again.    |
   | zmedico | Depending on how you look at, it may seem counter-intuitive. |
   |         | However, if you really think about it, it seems like it's    |
   |         | probably safe to assume that 12.2.5 > 12.2b is the behavior  |
   |         | that is intended by anyone who would use versions such as    |
   |         | these.                                                       |

svn path=/main/branches/prefix/; revision=15170

bin/ebuild-helpers/doins
man/ebuild.5
pym/_emerge/JobStatusDisplay.py
pym/portage/__init__.py
pym/portage/tests/versions/test_vercmp.py
pym/portage/versions.py

index d4a277aa63e900dd2b5f19ad4125e138f30c3560..3eb598a745c1db2f0208718dd5b264b675af659f 100755 (executable)
@@ -71,12 +71,20 @@ _doins() {
 }
 
 _xdoins() {
+       local -i success=0 failed=0
        while read -d $'\0' x ; do
                _doins "$x" "${x%/*}"
+               if [[ $? -eq 0 ]] ; then
+                       ((success|=1))
+               else
+                       ((failed|=1))
+               fi
        done
+       [[ $failed -ne 0 || $success -eq 0 ]] && return 1 || return 0
 }
 
 success=0
+failed=0
 
 for x in "$@" ; do
        if [[ $PRESERVE_SYMLINKS = n && -d $x ]] || \
@@ -108,15 +116,24 @@ for x in "$@" ; do
                fi
                find "$x_orig" -type d -exec dodir "${INSDESTTREE}/{}" \;
                find "$x_orig" \( -type f -or -type l \) -print0 | _xdoins
+               if [[ ${PIPESTATUS[1]} -eq 0 ]] ; then
+                       ((success|=1))
+               else
+                       ((failed|=1))
+               fi
                if [[ $x != $x_orig ]] ; then
                        popd >/dev/null
                        mv "$TMP/1/$x_orig" "$x"
                fi
                while popd >/dev/null 2>&1 ; do true ; done
-               ((success|=1))
        else
-               _doins "${x}" && ((success|=1))
+               _doins "${x}"
+               if [[ $? -eq 0 ]] ; then
+                       ((success|=1))
+               else
+                       ((failed|=1))
+               fi
        fi
 done
 rm -rf "$TMP"
-[ $success -gt 0 ] && exit 0 || exit 1
+[[ $failed -ne 0 || $success -eq 0 ]] && exit 1 || exit 0
index b3521e2224a5ed8836a85cd7b8faae53fff5ceb0..fcf8e3e4a427638472b09c0e18f514b09c29852d 100644 (file)
@@ -1017,9 +1017,10 @@ The default path is /.
 Can be used to define options for the install function used in
 \fBdoins\fR.  The default is \fI\-m0644\fR.
 .TP
-\fBdoins\fR \fI<file> [list of more files]\fR
+\fBdoins\fR \fI[-r] <file> [list of more files]\fR
 Installs files into the path controlled by \fBinsinto\fR.  This function
 uses \fBinstall\fR(1).  Creates all necessary dirs.
+Setting -r sets recursive.
 .TP
 \fBexeinto\fR \fI[path]\fR
 Sets the destination path for the \fBdoexe\fR function.
index cfc0bfa91ce6419f067741ce15ff5fc002616403..dfc766d26df32420edcc5d34da5aa5b1a3139ed7 100644 (file)
@@ -22,7 +22,6 @@ if sys.hexversion >= 0x3000000:
 class JobStatusDisplay(object):
 
        _bound_properties = ("curval", "failed", "running")
-       _jobs_column_width = 48
 
        # Don't update the display unless at least this much
        # time has passed, in units of seconds.
@@ -48,7 +47,12 @@ class JobStatusDisplay(object):
                object.__setattr__(self, "_changed", False)
                object.__setattr__(self, "_displayed", False)
                object.__setattr__(self, "_last_display_time", 0)
-               object.__setattr__(self, "width", 80)
+
+               width = portage.output.get_term_size()[1]
+               if width <= 0 or width > 80:
+                       width = 80
+               object.__setattr__(self, "width", width)
+               object.__setattr__(self, "_jobs_column_width", width - 32)
                self.reset()
 
                isatty = hasattr(self.out, "isatty") and self.out.isatty()
index b4a9c31ffaaf7eb792a8a88359191a5c4ee06324..aa499cba33c77b21efab8a03a778e104099aae16 100644 (file)
@@ -294,6 +294,9 @@ selinux = None
 _selinux_merge = None
 try:
        import portage._selinux
+       # Make sure the _selinux attribute is correctly reinitialized after
+       # reload(portage) is called. See bug #298310.
+       _selinux = sys.modules['portage._selinux']
        selinux = _unicode_module_wrapper(_selinux,
                encoding=_encodings['fs'])
        _selinux_merge = _unicode_module_wrapper(_selinux,
index 2d57236e10e9ca49ec2c629a903d5ef13e064881..eb2ba3eb0ab409cd8183c586151f74d339a130bd 100644 (file)
@@ -15,7 +15,15 @@ class VerCmpTestCase(TestCase):
                tests = [ ( "6.0", "5.0"), ("5.0","5"),
                        ("1.0-r1", "1.0-r0"),
                        ("1.0-r1", "1.0"),
-                       ("999999999999999999999999999999", "999999999999999999999999999998"),]
+                       ("cvs.9999", "9999"),
+                       ("999999999999999999999999999999", "999999999999999999999999999998"),
+                       ("1.0.0", "1.0"),
+                       ("1.0.0", "1.0b"),
+                       ("1b", "1"),
+                       ("1b_p1", "1_p1"),
+                       ("1.1b", "1.1"),
+                       ("12.2.5", "12.2b"),
+               ]
                for test in tests:
                        self.failIf( vercmp( test[0], test[1] ) <= 0, msg="%s < %s? Wrong!" % (test[0],test[1]) )
 
@@ -27,10 +35,18 @@ class VerCmpTestCase(TestCase):
                        ("1.0_alpha2", "1.0_p2"),("1.0_alpha1", "1.0_beta1"),("1.0_beta3","1.0_rc3"),
                        ("1.001000000000000000001", "1.001000000000000000002"),
                        ("1.00100000000", "1.0010000000000000001"),
+                       ("9999", "cvs.9999"),
                        ("999999999999999999999999999998", "999999999999999999999999999999"),
                        ("1.01", "1.1"),
                        ("1.0-r0", "1.0-r1"),
-                       ("1.0", "1.0-r1")]
+                       ("1.0", "1.0-r1"),
+                       ("1.0", "1.0.0"),
+                       ("1.0b", "1.0.0"),
+                       ("1_p1", "1b_p1"),
+                       ("1", "1b"),
+                       ("1.1", "1.1b"),
+                       ("12.2b", "12.2.5"),
+               ]
                for test in tests:
                        self.failIf( vercmp( test[0], test[1]) >= 0, msg="%s > %s? Wrong!" % (test[0],test[1]))
        
@@ -50,9 +66,16 @@ class VerCmpTestCase(TestCase):
                
                tests = [ ("1","2"),("1.0_alpha","1.0_pre"),("1.0_beta","1.0_alpha"),
                        ("0", "0.0"),
+                       ("cvs.9999", "9999"),
                        ("1.0-r0", "1.0-r1"),
                        ("1.0-r1", "1.0-r0"),
                        ("1.0", "1.0-r1"),
-                       ("1.0-r1", "1.0")]
+                       ("1.0-r1", "1.0"),
+                       ("1.0", "1.0.0"),
+                       ("1_p1", "1b_p1"),
+                       ("1b", "1"),
+                       ("1.1b", "1.1"),
+                       ("12.2b", "12.2"),
+               ]
                for test in tests:
                        self.failIf( vercmp( test[0], test[1]) == 0, msg="%s == %s? Wrong!" % (test[0],test[1]))
index a01c2ee2d9a318239a9517ca5e7c7ed95d866f6b..95f6fe899685f922d21c282992a873bc32a7d2b8 100644 (file)
@@ -101,9 +101,10 @@ def vercmp(ver1, ver2, silent=1):
        list2 = [int(match2.group(2))]
 
        # this part would greatly benefit from a fixed-length version pattern
-       if len(match1.group(3)) or len(match2.group(3)):
+       if match1.group(3) or match2.group(3):
                vlist1 = match1.group(3)[1:].split(".")
                vlist2 = match2.group(3)[1:].split(".")
+
                for i in range(0, max(len(vlist1), len(vlist2))):
                        # Implcit .0 is given a value of -1, so that 1.0.0 > 1.0, since it
                        # would be ambiguous if two versions that aren't literally equal
@@ -133,6 +134,11 @@ def vercmp(ver1, ver2, silent=1):
                                list2.append(int(vlist2[i].ljust(max_len, "0")))
 
        # and now the final letter
+       # NOTE: Behavior changed in r2309 (between portage-2.0.x and portage-2.1).
+       # The new behavior is 12.2.5 > 12.2b which, depending on how you look at,
+       # may seem counter-intuitive. However, if you really think about it, it
+       # seems like it's probably safe to assume that this is the behavior that
+       # is intended by anyone who would use versions such as these.
        if len(match1.group(5)):
                list1.append(ord(match1.group(5)))
        if len(match2.group(5)):