Gentoo Archives: gentoo-portage-dev

From: Michael Orlitzky <mjo@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH 1/1] Add a test case for PMS-compliant usage of the ROOT variable.
Date: Wed, 11 May 2016 16:08:38
Message-Id: 1462982905-17867-2-git-send-email-mjo@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 0/1] Test PMS-compliant usage of the ROOT variable. by Michael Orlitzky
1 A recent thread on gentoo-dev proposed a change to the devmanual's
2 description of the ROOT variable:
3
4 https://archives.gentoo.org/gentoo-dev/message/8901669dd375ca0fdb610efef0ddfe6f
5
6 The proposed change would bring the devmanual's language in line with
7 the PMS. That discussion reveals that the use of ROOT outside of
8 pkg_* is illegal, yet current versions of repoman/portage allow it.
9 This commit adds a test ebuild that violates the PMS (with respect to
10 ROOT) in several ways.
11 ---
12 ebuild-test/root-var-usage/metadata.xml | 24 ++++++
13 ebuild-test/root-var-usage/root-var-usage-0.ebuild | 90 ++++++++++++++++++++++
14 2 files changed, 114 insertions(+)
15 create mode 100644 ebuild-test/root-var-usage/metadata.xml
16 create mode 100644 ebuild-test/root-var-usage/root-var-usage-0.ebuild
17
18 diff --git a/ebuild-test/root-var-usage/metadata.xml b/ebuild-test/root-var-usage/metadata.xml
19 new file mode 100644
20 index 0000000..f8ba4d0
21 --- /dev/null
22 +++ b/ebuild-test/root-var-usage/metadata.xml
23 @@ -0,0 +1,24 @@
24 +<?xml version="1.0" encoding="UTF-8"?>
25 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
26 +<pkgmetadata>
27 + <longdescription>
28 + Test that the $ROOT variable is used according to the Package
29 + Manager Specification (PMS).
30 +
31 + All currently-approved versions of the PMS state that the $ROOT
32 + variable is legal only in the pkg_* phases. One common misuse is
33 + to use $ROOT instead of $EPREFIX as "something more general than a
34 + front-slash" in the src_* functions. We want to detect these
35 + mistakes, and eventually eliminate all uses of $ROOT outside of
36 + the PMS-defined pkg_* phases.
37 + </longdescription>
38 +
39 +<maintainer type="person">
40 + <email>exampledev@g.o</email>
41 + <description>Primary maintainer</description>
42 +</maintainer>
43 +<maintainer type="project">
44 + <email>exampleproject@g.o</email>
45 + <name>Gentoo Example Project</name>
46 +</maintainer>
47 +</pkgmetadata>
48 diff --git a/ebuild-test/root-var-usage/root-var-usage-0.ebuild b/ebuild-test/root-var-usage/root-var-usage-0.ebuild
49 new file mode 100644
50 index 0000000..a46339e
51 --- /dev/null
52 +++ b/ebuild-test/root-var-usage/root-var-usage-0.ebuild
53 @@ -0,0 +1,90 @@
54 +# Copyright 1999-2016 Gentoo Foundation
55 +# Distributed under the terms of the GNU General Public License v2
56 +# $Id$
57 +
58 +EAPI=6
59 +
60 +DESCRIPTION="Ensure ROOT variable usage complies with the PMS"
61 +HOMEPAGE="https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-11800011"
62 +LICENSE="BSD"
63 +SLOT="0"
64 +KEYWORDS="~amd64"
65 +IUSE=""
66 +
67 +# All uses of $ROOT within the pkg_* "Ebuild-defined functions" should
68 +# be allowed. The list comes from the so-named chapter of the PMS.
69 +
70 +pkg_pretend() {
71 + local foo=$ROOT
72 +}
73 +
74 +pkg_setup() {
75 + local foo="${ROOT}/foo"
76 +}
77 +
78 +pkg_preinst() {
79 + local foo="$ROOT"
80 +}
81 +
82 +pkg_postinst() {
83 + local foo="bar/${ROOT}"
84 +}
85 +
86 +pkg_prerm() {
87 + local foo="bar/${ROOT}/baz"
88 +}
89 +
90 +pkg_postrm() {
91 + local foo=bar/$ROOT
92 +}
93 +
94 +pkg_config() {
95 + local foo="$ROOT"
96 +}
97 +
98 +pkg_info() {
99 +local foo=$ROOT
100 +}
101 +
102 +pkg_nofetch() {
103 + local foo=`echo $ROOT`
104 +}
105 +
106 +# All uses below here are errors. The following src_* functions are
107 +# defined in the PMS.
108 +src_unpack() {
109 + local foo=$ROOT
110 +}
111 +
112 +src_prepare() {
113 + local foo="${ROOT}/foo"
114 +}
115 +
116 +src_configure() {
117 + local foo=`echo $ROOT`
118 +}
119 +
120 +src_compile() {
121 +local foo=$ROOT
122 +}
123 +
124 +src_test() {
125 + local foo=$(echo $ROOT)
126 +}
127 +
128 +src_install() {
129 + local foo="bar/${ROOT}/baz"
130 +}
131 +
132 +pkg_apocrypha(){
133 + # This function begins with "pkg_", but isn't defined in the PMS.
134 + local foo=bar/$ROOT
135 +}
136 +
137 +washington_irving(){
138 + # This function is arbitrarily-named and not defined in the PMS.
139 + local foo="${ROOT}/foo"
140 +}
141 +
142 +# And I suppose we should check that it's not used in global scope, too.
143 +DEPEND="sys-libs${ROOT}glibc"
144 --
145 2.7.3

Replies