Merged from trunk 5861:5880
authorFabian Groffen <grobian@gentoo.org>
Sat, 3 Feb 2007 21:52:00 +0000 (21:52 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sat, 3 Feb 2007 21:52:00 +0000 (21:52 -0000)
fix doc typo; more test fiddling (WarnerBro)

A somewhat more intelligent layout, move tests into portaage namespace
so we can import them easier, seems to be a more common layout from what
I've seen.  Also rewrite the test runner to work with new layout
(WarnerBro)

apparently I'm retarded and missed some of the tests.. (WarnerBro)

Rename dir.bz2 since that's the most likely case now.

add warning about storing data in PORTDIR (WarnerBro)

For bug #153109, replace our old chflags module with the one provided by
the py-freebsd package.  Thanks to Diego Petten?\195?\178
<flameeyes@gentoo.org> for the initial patch.

remove redundant directory now (WarnerBro)

grrr I thought I removed this (WarnerBro)

For bug #165065, use the proper RESTRICT setting when fetching files in
digestgen().

Make the tests pass.

For bug #165034, make sure that symlinks are excluded from chmod calls.

Use ! -type l to exclude symlinks better.  Thanks to marienz.

Fix a typo from the previos commit.

In order to correctly handl the case of target caches that don't have
complete eclass entries, validate the set of interited eclasses to make
sure it is correct (since timestamp validation is not applicable).

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

29 files changed:
bin/ebuild.sh
bin/emerge
man/make.conf.5
pym/portage/__init__.py
pym/portage/cache/util.py
pym/portage/dep.py
pym/portage/tests/__init__.py [moved from tests/__init__.py with 75% similarity]
pym/portage/tests/dep/__init__.py [moved from tests/portage/dep/__init__.py with 100% similarity]
pym/portage/tests/dep/test_dep_getcpv.py [moved from tests/portage/dep/test_dep_getcpv.py with 100% similarity]
pym/portage/tests/dep/test_dep_getslot.py [moved from tests/portage/dep/test_dep_getslot.py with 100% similarity]
pym/portage/tests/dep/test_dep_getusedeps.py [moved from tests/portage/dep/test_dep_getusedeps.py with 74% similarity]
pym/portage/tests/dep/test_get_operator.py [moved from tests/portage/dep/test_get_operator.py with 100% similarity]
pym/portage/tests/dep/test_isjustname.py [moved from tests/portage/dep/test_isjustname.py with 100% similarity]
pym/portage/tests/dep/test_isvalidatom.py [moved from tests/portage/dep/test_isvalidatom.py with 96% similarity]
pym/portage/tests/dep/test_match_from_list.py [moved from tests/portage/dep/test_match_from_list.py with 100% similarity]
pym/portage/tests/news/__init__.py [moved from tests/portage/news/__init__.py with 100% similarity]
pym/portage/tests/news/test_NewsItem.py [moved from tests/portage/news/test_NewsItem.py with 100% similarity]
pym/portage/tests/runTests [moved from tests/runTests with 69% similarity]
pym/portage/tests/util/__init__.py [moved from tests/portage/util/__init__.py with 100% similarity]
pym/portage/tests/util/test_grabdict.py [moved from tests/portage/util/test_grabdict.py with 100% similarity]
pym/portage/tests/util/test_normalizedPath.py [moved from tests/portage/util/test_normalizedPath.py with 100% similarity]
pym/portage/tests/util/test_stackDictList.py [moved from tests/portage/util/test_stackDictList.py with 100% similarity]
pym/portage/tests/util/test_stackDicts.py [moved from tests/portage/util/test_stackDicts.py with 100% similarity]
pym/portage/tests/util/test_stackLists.py [moved from tests/portage/util/test_stackLists.py with 100% similarity]
pym/portage/tests/util/test_uniqueArray.py [moved from tests/portage/util/test_uniqueArray.py with 100% similarity]
pym/portage/tests/util/test_varExpand.py [moved from tests/portage/util/test_varExpand.py with 100% similarity]
pym/portage/tests/versions/__init__.py [moved from tests/portage/versions/__init__.py with 100% similarity]
pym/portage/tests/versions/test_vercmp.py [moved from tests/portage/versions/test_vercmp.py with 100% similarity]
tests/portage/__init__.py [deleted file]

index 8fcf28db299db6d45f7fe15bc6a616ca045261ec..8138f99e84a0a4d28198c96f6847c7bfb4d53f52 100755 (executable)
@@ -608,7 +608,7 @@ unpack() {
        done
        # Do not chmod '.' since it's probably ${WORKDIR} and PORTAGE_WORKDIR_MODE
        # should be preserved.
-       find . -mindepth 1 -print0 | ${XARGS} -0 chmod -f a+rX,u+w,g-w,o-w
+       find . -mindepth 1 ! -type l -print0 | ${XARGS} -0 chmod -f a+rX,u+w,g-w,o-w
 }
 
 strip_duplicate_slashes() {
index 7194ea3d08e5adfe9230ec7bafe0e5cb0ead19d6..0b7ef032887966c6dcd324ade0e135f769617274 100755 (executable)
@@ -3471,7 +3471,7 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval):
                        for inforoot in regen_infodirs:
                                if inforoot=='':
                                        continue
-                               for filename in ("dir", "dir.gz"):
+                               for filename in ("dir", "dir.gz", "dir.bz2"):
                                        file_path = os.path.join(inforoot, filename)
                                        try:
                                                os.rename(file_path, file_path + ".old")
index 85912d9bdfb550eec35cc559cd890418bcc2ef25..8e89cca7504d38086babec0902b6b727ae310e0b 100644 (file)
@@ -381,6 +381,15 @@ Defaults to /var/tmp.
 Defines the location of your Portage tree.
 .br
 Defaults to /usr/portage. 
+.br
+\fB***Warning***\fR
+.br
+Storing data such as distfiles and binary packages in PORTDIR can
+be potentially dangerous. The default emerge configuration defaults to this 
+behavior (which will work fine), however if you deviate from the default
+configuration by changing PKGDIR or DISTDIR, emerge \-\-sync may inadvertedly
+delete all your distfiles/binary packages. Please make sure to set
+\fBPORTAGE_EXTRA_RSYNC_OPTS\fR properly to insure the safety of files in PORTDIR.
 .TP
 \fBPORTDIR_OVERLAY\fR = \fI"[path] [different\-path] [etc...]"\fR
 Defines the directories in which user made ebuilds may be stored and not 
index d4f7740ac1d14f641d9a279a9a16817a68f378ae..a91fccff0029d7280f0f6968f6d9e2eede7f1db3 100644 (file)
@@ -42,12 +42,12 @@ except ImportError, e:
        sys.stderr.write("    "+str(e)+"\n\n");
        raise
 
-try:
-       # XXX: This should get renamed to bsd_chflags, I think.
-       import chflags
-       bsd_chflags = chflags
-except ImportError:
-       bsd_chflags = None
+bsd_chflags = None
+if os.uname()[0] in ["FreeBSD"]:
+       try:
+               import freebsd as bsd_chflags
+       except ImportError:
+               pass
 
 try:
        from portage.cache.cache_errors import CacheError
@@ -2736,19 +2736,29 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
                        if missing_files:
                                mytree = os.path.realpath(os.path.dirname(
                                        os.path.dirname(mysettings["O"])))
-                               myuris = []
+                               fetch_settings = config(clone=mysettings)
+                               debug = mysettings.get("PORTAGE_DEBUG") == "1"
                                for myfile in missing_files:
+                                       success = False
                                        for cpv in distfiles_map[myfile]:
+                                               myebuild = os.path.join(mysettings["O"],
+                                                       catsplit(cpv)[1] + ".ebuild")
+                                               # for RESTRICT=fetch, mirror, etc...
+                                               doebuild_environment(myebuild, "fetch",
+                                                       mysettings["ROOT"], fetch_settings,
+                                                       debug, 1, myportdb)
                                                alluris, aalist = myportdb.getfetchlist(
                                                        cpv, mytree=mytree, all=True,
-                                                       mysettings=mysettings)
-                                               for uri in alluris:
-                                                       if os.path.basename(uri) == myfile:
-                                                               myuris.append(uri)
-                               if not fetch(myuris, mysettings):
-                                       writemsg(("!!! File %s doesn't exist, can't update " + \
-                                               "Manifest\n") % myfile, noiselevel=-1)
-                                       return 0
+                                                       mysettings=fetch_settings)
+                                               myuris = [uri for uri in alluris \
+                                                       if os.path.basename(uri) == myfile]
+                                               if fetch(myuris, fetch_settings):
+                                                       success = True
+                                                       break
+                                       if not success:
+                                               writemsg(("!!! File %s doesn't exist, can't update " + \
+                                                       "Manifest\n") % myfile, noiselevel=-1)
+                                               return 0
                writemsg_stdout(">>> Creating Manifest for %s\n" % mysettings["O"])
                try:
                        mf.create(requiredDistfiles=myarchives,
@@ -3777,24 +3787,12 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
                destexists=0
 
        if bsd_chflags:
-               # Check that we can actually unset schg etc flags...
-               # Clear the flags on source and destination; we'll reinstate them after merging
                if destexists and dstat.st_flags != 0:
-                       if bsd_chflags.lchflags(dest, 0) < 0:
-                               writemsg("!!! Couldn't clear flags on file being merged: \n ",
-                                       noiselevel=-1)
-               # We might have an immutable flag on the parent dir; save and clear.
-               pflags=bsd_chflags.lgetflags(os.path.dirname(dest))
+                       bsd_chflags.lchflags(dest, 0)
+               pflags = os.stat(os.path.dirname(dest)).st_flags
                if pflags != 0:
                        bsd_chflags.lchflags(os.path.dirname(dest), 0)
 
-               if (destexists and bsd_chflags.lhasproblems(dest) > 0) or \
-                       bsd_chflags.lhasproblems(os.path.dirname(dest)) > 0:
-                       # This is bad: we can't merge the file with these flags set.
-                       writemsg("!!! Can't merge file "+dest+" because of flags set\n",
-                               noiselevel=-1)
-                       return None
-
        if destexists:
                if stat.S_ISLNK(dstat[stat.ST_MODE]):
                        try:
@@ -3897,10 +3895,8 @@ def movefile(src,dest,newmtime=None,sstat=None,mysettings=None):
 
        if bsd_chflags:
                # Restore the flags we saved before moving
-               if pflags and bsd_chflags.lchflags(os.path.dirname(dest), pflags) < 0:
-                       writemsg("!!! Couldn't restore flags (%s) on '%s'\n" % \
-                               (str(pflags), os.path.dirname(dest)), noiselevel=-1)
-                       return None
+               if pflags:
+                       bsd_chflags.lchflags(os.path.dirname(dest), pflags)
 
        return newmtime
 
@@ -7625,10 +7621,9 @@ class dblink:
 
                                        if bsd_chflags:
                                                # Save then clear flags on dest.
-                                               dflags=bsd_chflags.lgetflags(mydest)
-                                               if dflags != 0 and bsd_chflags.lchflags(mydest, 0) < 0:
-                                                       writemsg("!!! Couldn't clear flags on '"+mydest+"'.\n",
-                                                               noiselevel=-1)
+                                               dflags = os.lstat(mydest).st_flags
+                                               if dflags != 0:
+                                                       bsd_chflags.lchflags(mydest, 0)
 
                                        if not os.access(mydest, os.W_OK):
                                                pkgstuff = pkgsplit(self.pkg)
index 0fc56b5eeaf0e6819ce959c183b205b503a98903..c31dc9163a965acae58834b91a8bb42ae801335b 100644 (file)
@@ -39,7 +39,9 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
                trg = None
                try:
                        trg = trg_cache[x]
-                       if long(trg["_mtime_"]) == long(entry["_mtime_"]) and portage.eclass_cache.is_eclass_data_valid(trg["_eclasses_"]):
+                       if long(trg["_mtime_"]) == long(entry["_mtime_"]) and \
+                               eclass_cache.is_eclass_data_valid(trg["_eclasses_"]) and \
+                               set(trg["_eclasses_"]) == set(entry["_eclasses_"]):
                                write_it = False
                except (cache_errors.CacheError, KeyError):
                        pass
index e59715f1c6678c86deb212fe3e9de327a2ed4dbb..bf8c0ae05d3588c27a3d119a5b6fd21e5b12e435 100644 (file)
@@ -18,7 +18,7 @@
 # "a? ( b? ( z ) ) -- Valid
 #
 
-import re,  sys, types
+import re, sys, types
 import portage.exception
 from portage.exception import InvalidData, InvalidAtom
 from portage.versions import catpkgsplit, catsplit, pkgcmp, pkgsplit, ververify
@@ -341,7 +341,7 @@ def dep_getusedeps( depend ):
        Pull a listing of USE Dependencies out of a dep atom.
        
        Example usage:
-               >>> dep_getusedeps('app-misc/test:3[foo][-bar]
+               >>> dep_getusedeps('app-misc/test:3[foo][-bar]')
                ['foo','-bar']
        
        @param depend: The depstring to process
similarity index 75%
rename from tests/__init__.py
rename to pym/portage/tests/__init__.py
index f9bca5ee6e36cfeaf02c208310eff3091cca34ef..3a881348a8bf99b54c412c8551fb1d9f60c8ef16 100644 (file)
@@ -7,7 +7,7 @@ import os, unittest
 
 def main():
        
-       testDirs = ["portage", "portage/util","portage/versions", "portage/dep"]
+       testDirs = ["util","versions", "dep"]
 
        suite = unittest.TestSuite()
 
@@ -36,7 +36,8 @@ def getTests( path, base_path ):
        files = os.listdir( path )
        files = [ f[:-3] for f in files if f.startswith("test_") and f.endswith(".py") ]
        parent_path = path[len(base_path)+1:]
-       parent_module = ".".join(("tests", parent_path))
+       parent_module = ".".join(("portage","tests", parent_path))
+       parent_module = parent_module.replace('/','.')
        result = []
        for mymodule in files:
                try:
@@ -47,3 +48,8 @@ def getTests( path, base_path ):
                except ImportError:
                        raise
        return result
+
+test_cpvs = ['sys-apps/portage','virtual/portage']
+test_versions = ['1.0', '1.0-r1','2.3_p4','1.0_alpha57']
+test_slots = [ None, '1','gentoo-sources-2.6.17','spankywashere']
+test_usedeps = ['foo','-bar', ['foo','bar'],['foo','-bar'] ]
similarity index 74%
rename from tests/portage/dep/test_dep_getusedeps.py
rename to pym/portage/tests/dep/test_dep_getusedeps.py
index c16632c94aff77e27babba0d7d40b204c262c98f..d191d43ccc5d27ab16f03b12f160d051e5cee152 100644 (file)
@@ -6,20 +6,20 @@
 from unittest import TestCase
 from portage.dep import dep_getusedeps
 
+import sys
+from portage.tests import test_cpvs, test_slots, test_versions, test_usedeps
+
 class DepGetUseDeps(TestCase):
        """ A simple testcase for dep_getusedeps
        """
 
        def testDepGetUseDeps(self):
 
-               useflags = [ '', 'foo', '-bar', ['baz','bar'], ['baz','-bar'] ]
-               cpvs = [ "sys-apps/portage" ]
-               slots = [ None, "0","1","linux-sources-2.5.7","randomstring" ]
-               versions = [ None, "2.1.1", "2.1.1-r2"]
-               for mycpv in cpvs:
-                       for version in versions:
-                               for slot in slots:
-                                       for use in useflags:
+
+               for mycpv in test_cpvs:
+                       for version in test_versions:
+                               for slot in test_slots:
+                                       for use in test_usedeps:
                                                cpv = mycpv[:]
                                                if version:
                                                        cpv += version
similarity index 96%
rename from tests/portage/dep/test_isvalidatom.py
rename to pym/portage/tests/dep/test_isvalidatom.py
index 88250e96cda601e41ab08f5e54736b90cb8d32f0..2ba91b7cc7dbb88ee763a9b2b0da9e77b2d7bdc4 100644 (file)
@@ -20,7 +20,7 @@ class IsValidAtom(TestCase):
                          ( ">sys-apps/portage-2.1", True ),
                          ( "<sys-apps/portage-2.1", True ),
                          ( "~sys-apps/portage-2.1", True ),
-                         ( "sys-apps/portage-2.1:foo", True ),
+                         ( "sys-apps/portage-2.1:foo", False ),
                          ( "sys-apps/portage-2.1:", False ),
                          ( ">~cate-gory/foo-1.0", False ),
                          ( ">~category/foo-1.0", False ),
similarity index 69%
rename from tests/runTests
rename to pym/portage/tests/runTests
index c44d3678845319bbc29d850720520fe526f7bc71..6781796f8d7f8c8a0bcbfb26dfccee47020f3eb1 100755 (executable)
@@ -10,12 +10,10 @@ import os.path as osp
 
 # Insert our parent dir so we can do shiny import "tests"
 # This line courtesy of Marienz and Pkgcore ;)
-sys.path.insert(0, osp.dirname(osp.dirname(osp.abspath(__file__))))
+sys.path.insert(0, osp.dirname(osp.dirname(osp.dirname(osp.abspath(__file__)))))
 
-# Grab SVN portage files instead of normal ones.
-sys.path.insert(0, os.path.join(sys.path[0], "pym"))
+import portage.tests as tests
 
-import tests
 if __name__ == "__main__":
        result = tests.main()
        if result.failures:
diff --git a/tests/portage/__init__.py b/tests/portage/__init__.py
deleted file mode 100644 (file)
index 920c2f7..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# tests/portage/__init__.py -- Portage Unit Test functionality
-# Copyright 2006 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Id$