Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 775191 (forbidden-variable-use) - [Tracker] Packages using forbidden (undefined) variables in various phases (VariableScope)
Summary: [Tracker] Packages using forbidden (undefined) variables in various phases (V...
Status: CONFIRMED
Alias: forbidden-variable-use
Product: Quality Assurance
Classification: Unclassified
Component: Trackers (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Quality Assurance Team
URL:
Whiteboard:
Keywords: Tracker
Depends on: filesdir-bad-scope 778806 778812 836031 836032 836034 836038 836040 836041 836042 836045 836047 836048 836049 836051 836052 836054 836055 836056 836057 836058 836059 836060 836062 836064 836065 836066 836067 836068 836069 836071 836072 836073 836074 836075 836076 836081 836084 836086 836087 836088 836090 836091 836092 836093 836095 836096 836098 836099 836100 836101 836102 836103 836104 836105 836106 836107 836108 836111 836114 836115 836116 836117 836118 836119 836120 836121 836123 205087 681232 775188 778056 778803 778809 778815 836030 836033 836035 836036 836037 836039 836043 836044 836046 836050 836053 836061 836063 836070 836077 836078 836079 836080 836082 836083 836085 836089 836094 836097 836109 836110 836112 836113 836122 836124
Blocks:
  Show dependency tree
 
Reported: 2021-03-10 01:02 UTC by Sam James
Modified: 2022-03-26 21:26 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-03-10 01:02:40 UTC
As per PMS [0], some variables are only defined during certain phases. e.g. EROOT is only defined within pkg_* and should not be used in e.g. src_*.

pkgcheck now implements MisplacedVariable [1] to help detect such cases (experimental).

Please be aware that using undefined variables in this way:
1) violates PMS (and the disadvantages that brings);
2) may result in undefined behaviour, including your ebuild not functioning at some later point in time with e.g. a new version of Portage;
3) may not behave as expected in pathological cases like cross-compilation, Gentoo Prefix, binpkgs, or --root.

Ask for help if you're not sure of the best way to fix an issue in your package.

There are two helpful PMS tables [2] [3] which define which dependency classes are satisfied
in which phase and which elements in our CHOST/CBUILD model. This is useful for figuring out if
you want e.g. BROOT, ESYSROOT, or just EPREFIX.

[0] https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-10900011.1
[1] https://github.com/pkgcore/pkgcheck/commit/552506b076c2cf34fc863df51086f92e7f752393
[2] https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-720008.1
[3] https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-72002r2
Comment 1 David Seifert gentoo-dev 2021-03-26 22:51:12 UTC
*** Bug 608664 has been marked as a duplicate of this bug. ***
Comment 2 Larry the Git Cow gentoo-dev 2021-03-30 18:15:49 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=fd90736ea1141e95c63a9634d424aa843454ca45

commit fd90736ea1141e95c63a9634d424aa843454ca45
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-03-21 02:31:00 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2021-03-30 18:14:52 +0000

    ebuild-writing/common-mistakes: give more information on invalid ${ROOT} usage
    
    Bug: https://bugs.gentoo.org/775191
    Signed-off-by: Sam James <sam@gentoo.org>
    [Add bug number to link text.]
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 ebuild-writing/common-mistakes/text.xml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-03-26 05:41:48 UTC
I've now automatically filed bugs for all packages hitting pkgcheck's VariableScope warning, given we need the tree to be clean before we can change Portage's behaviour.

Reach out to us in e.g. #gentoo-dev-help, #gentoo-qa if you need help adapting your ebuild.