Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 613110 - [Tracker] ${S} used outside src_*
Summary: [Tracker] ${S} used outside src_*
Status: CONFIRMED
Alias: None
Product: Quality Assurance
Classification: Unclassified
Component: Trackers (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Quality Assurance Team
URL:
Whiteboard:
Keywords:
Depends on: 613108 613114 613116 613120 613122
Blocks:
  Show dependency tree
 
Reported: 2017-03-18 14:38 UTC by Michał Górny
Modified: 2022-04-14 10:47 UTC (History)
0 users

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 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2017-03-18 14:38:06 UTC
So, PMS states that ${S} is defined only inside src_* phases.

However, there's around ~250 packages that access the variable in global scope. Most notably:

- packages defining S=${S}/...;

- lots of font packages which use FONT_S=${S};

- many CMake packages that do CMAKE_USE_DIR=${S}/...;

- lots of java packages that do JAVA_*=${S}/...;

- lots of kernel-module packages that do MODULE_NAMES="(...:${S})" [yes, this design is horrible];

- various other minor uses -- EGIT_CHECKOUT_DIR, ECONF_SOURCE, PERL_S, PHP_EXT_S, AT_M4DIR...

Some of them may be false positives because if the ebuild defines S= explicitly, it can obviously use the just-defined value.

Plus, there are some cases of S being used in pkg_setup() (MODULE_NAMES again), or even accessed in pkg_preinst().

Considering the scale of the problem, I would go for defining S in global scope (with similar rules as for FILESDIR), and just fighting looped assigments (S=${S}...) and actual accesses outside src_*.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-04-14 06:24:26 UTC
(In reply to Michał Górny from comment #0)
> [...]
> Considering the scale of the problem, I would go for defining S in global
> scope (with similar rules as for FILESDIR), and just fighting looped
> assigments (S=${S}...) and actual accesses outside src_*.

From 65d38361a953c0b6da4cc192d8727b0d6f1c64cc Mon Sep 17 00:00:00 2001
From: Ulrich Müller <ulm@gentoo.org>
Date: Sat, 18 Mar 2017 15:18:25 +0100
Subject: WORKDIR and S have the same scope as FILESDIR and DISTDIR.

Both WORKDIR and S are defined in global scope, but ebuilds must not
access the actual directories. So the FILESDIR footnote applies to
them, too. Rearrange the table accordingly.

Also small change of wording ("in which" -> "where") to prevent an
awkward page break.
---
 ebuild-env-vars.tex | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-04-14 06:59:23 UTC
So, remaining cases:

$ grep -rsin '^S="${S}'
net-wireless/hostapd/hostapd-2.10.ebuild:13:S="${S}/${PN}"
net-wireless/hostapd/hostapd-9999.ebuild:13:S="${S}/${PN}"
net-wireless/hostapd/hostapd-2.9-r6.ebuild:13:S="${S}/${PN}"
dev-util/buildbot-worker/buildbot-worker-9999.ebuild:14:S="${S}/worker"
dev-util/buildbot/buildbot-9999.ebuild:15:S="${S}/master"
games-emulation/libretro-snes9x/libretro-snes9x-0.0.2_pre20200107.ebuild:11:S="${S}/libretro"
games-emulation/libretro-snes9x/libretro-snes9x-9999.ebuild:8:S="${S}/libretro"
dev-db/mariadb-connector-odbc/mariadb-connector-odbc-3.1.12.ebuild:19:S="${S}-src"
dev-db/mariadb-connector-odbc/mariadb-connector-odbc-3.1.14.ebuild:19:S="${S}-src"
dev-db/mariadb-connector-odbc/mariadb-connector-odbc-3.1.13.ebuild:19:S="${S}-src"
kde-plasma/xembed-sni-proxy/xembed-sni-proxy-5.24.4.ebuild:34:S="${S}/${PN}"
kde-plasma/xembed-sni-proxy/xembed-sni-proxy-5.23.5.ebuild:34:S="${S}/${PN}"
kde-plasma/libkworkspace/libkworkspace-5.24.4.ebuild:38:S="${S}/${PN}"
kde-plasma/libkworkspace/libkworkspace-5.23.5.ebuild:38:S="${S}/${PN}"
sys-boot/dvhtool/dvhtool-1.0.1-r2.ebuild:20:S="${S}.orig"
Comment 3 Ulrich Müller gentoo-dev 2022-04-14 07:42:48 UTC
(In reply to Sam James from comment #1)
> From 65d38361a953c0b6da4cc192d8727b0d6f1c64cc Mon Sep 17 00:00:00 2001
> From: Ulrich Müller <ulm@gentoo.org>
> Date: Sat, 18 Mar 2017 15:18:25 +0100
> Subject: WORKDIR and S have the same scope as FILESDIR and DISTDIR.
> 
> Both WORKDIR and S are defined in global scope, but ebuilds must not
> access the actual directories. So the FILESDIR footnote applies to
> them, too. Rearrange the table accordingly.

Link to commit: https://gitweb.gentoo.org/proj/pms.git/commit/?id=65d38361a953c0b6da4cc192d8727b0d6f1c64cc
Comment 4 Ulrich Müller gentoo-dev 2022-04-14 07:47:40 UTC
(In reply to Ulrich Müller from comment #3)
> https://gitweb.gentoo.org/proj/pms.git/commit/
> ?id=65d38361a953c0b6da4cc192d8727b0d6f1c64cc

... but it has been reverted later:

https://gitweb.gentoo.org/proj/pms.git/commit/?id=7a04d1e8577ec052e8309b1daf1d96ddeea40fa7
commit 7a04d1e8577ec052e8309b1daf1d96ddeea40fa7
Author: Ulrich Müller <ulm@gentoo.org>
Date:   Tue Apr 11 18:55:00 2017 +0200

    Revert "WORKDIR and S have the same scope as FILESDIR and DISTDIR."
    
    This reverts commit 65d38361a953c0b6da4cc192d8727b0d6f1c64cc.
Comment 5 Ulrich Müller gentoo-dev 2022-04-14 10:47:42 UTC
So, what we have (and what was approved by the Council) is this:

WORKDIR: Legal in src_* and in global scope (but ebuilds must not access the directory in global scope)

S: Legal in src_* only


(In reply to Sam James from comment #2)
> So, remaining cases:

Looks like we could trivially replace ${S} by ${WORKDIR}/${P} for these cases.