Make die() to show a message indicating the repository that an ebuild came
authorZac Medico <zmedico@gentoo.org>
Mon, 12 Jan 2009 08:20:30 +0000 (08:20 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 12 Jan 2009 08:20:30 +0000 (08:20 -0000)
from, and do it during any phase for both ebuilds and binary packages. Now
PORTAGE_REPO_NAME is initialized inside config.setcpv() for both ebuilds
and binary packages, so it's always available inside ebuild.sh. (trunk r12402)

svn path=/main/branches/2.1.6/; revision=12462

bin/isolated-functions.sh
pym/_emerge/__init__.py
pym/portage/__init__.py

index 9ed933c02ec7a3ae1b53eebf926d613ecea92d9f..e418bdde61dad50b10261b7b9b6bbaecbba0f5ce 100755 (executable)
@@ -123,7 +123,19 @@ die() {
                local overlay=${EBUILD%/*}
                overlay=${overlay%/*}
                overlay=${overlay%/*}
-               eerror "This ebuild is from an overlay: '${overlay}/'"
+               if [[ -n $PORTAGE_REPO_NAME ]] ; then
+                       eerror "This ebuild is from an overlay named" \
+                               "'$PORTAGE_REPO_NAME': '${overlay}/'"
+               else
+                       eerror "This ebuild is from an overlay: '${overlay}/'"
+               fi
+       elif [[ -n $PORTAGE_REPO_NAME && -f "$PORTDIR"/profiles/repo_name ]] ; then
+               local portdir_repo_name=$(<"$PORTDIR"/profiles/repo_name)
+               if [[ -n $portdir_repo_name && \
+                       $portdir_repo_name != $PORTAGE_REPO_NAME ]] ; then
+                       eerror "This ebuild is from a repository" \
+                               "named '$PORTAGE_REPO_NAME'"
+               fi
        fi
        eerror
 
index 373979b2302bbfad22ee4d4dcbdcb1eee4e58bf2..dbdd64600801d7e499083ee5bfa0fd3345c9268c 100644 (file)
@@ -2502,9 +2502,8 @@ class EbuildBuild(CompositeTask):
                tree = "porttree"
                self._tree = tree
                portdb = root_config.trees[tree].dbapi
-               settings["EMERGE_FROM"] = pkg.type_name
-               settings.backup_changes("EMERGE_FROM")
-               settings.reset()
+               settings.setcpv(pkg)
+               settings.configdict["pkg"]["EMERGE_FROM"] = pkg.type_name
                ebuild_path = portdb.findname(self.pkg.cpv)
                self._ebuild_path = ebuild_path
 
@@ -3187,6 +3186,7 @@ class Binpkg(CompositeTask):
                debug = settings.get("PORTAGE_DEBUG") == "1"
                portage.doebuild_environment(self._ebuild_path, "setup",
                        settings["ROOT"], settings, debug, 1, self._bintree.dbapi)
+               settings.configdict["pkg"]["EMERGE_FROM"] = pkg.type_name
 
                # The prefetcher has already completed or it
                # could be running now. If it's running now,
index db6ce822f72452e5ee01d42154d82e22fa5f5a6c..e3bc6105fef706245e58eeba2dbb0136bc1001ca 100644 (file)
@@ -917,7 +917,7 @@ class config(object):
        _env_blacklist = [
                "A", "AA", "CATEGORY", "EBUILD_PHASE", "EMERGE_FROM",
                "PF", "PKGUSE", "PORTAGE_CONFIGROOT", "PORTAGE_IUSE",
-               "PORTAGE_USE", "ROOT"
+               "PORTAGE_REPO_NAME", "PORTAGE_USE", "ROOT"
        ]
 
        _environ_whitelist = []
@@ -1911,8 +1911,12 @@ class config(object):
                        else:
                                aux_keys = [k for k in auxdbkeys \
                                        if not k.startswith("UNUSED_")]
+                               aux_keys.append("repository")
                                for k, v in izip(aux_keys, mydb.aux_get(self.mycpv, aux_keys)):
                                        pkg_configdict[k] = v
+                       repository = pkg_configdict.pop("repository", None)
+                       if repository is not None:
+                               pkg_configdict["PORTAGE_REPO_NAME"] = repository
                        for k in pkg_configdict:
                                if k != "USE":
                                        env_configdict.pop(k, None)
@@ -4751,17 +4755,6 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
 
        mysettings["ROOT"]     = myroot
        mysettings["STARTDIR"] = getcwd()
-
-       mysettings["PORTAGE_REPO_NAME"] = ""
-       # bindbapi has no getRepositories() method
-       if mydbapi and hasattr(mydbapi, "getRepositories"):
-               # do we have a origin repository name for the current package
-               repopath = os.sep.join(pkg_dir.split(os.path.sep)[:-2])
-               for reponame in mydbapi.getRepositories():
-                       if mydbapi.getRepositoryPath(reponame) == repopath:
-                               mysettings["PORTAGE_REPO_NAME"] = reponame
-                               break
-
        mysettings["EBUILD"]   = ebuild_path
        mysettings["O"]        = pkg_dir
        mysettings.configdict["pkg"]["CATEGORY"] = cat