From 908579420e92e631d56a558734299b72f5688e83 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 11 May 2016 11:35:52 -0400 Subject: Add a test case for PMS-compliant usage of the ROOT variable. A recent thread on gentoo-dev proposed a change to the devmanual's description of the ROOT variable: https://archives.gentoo.org/gentoo-dev/message/8901669dd375ca0fdb610efef0ddfe6f The proposed change would bring the devmanual's language in line with the PMS. That discussion reveals that the use of ROOT outside of pkg_* is illegal, yet current versions of repoman/portage allow it. This commit adds a test ebuild that violates the PMS (with respect to ROOT) in several ways. --- ebuild-test/root-var-usage/metadata.xml | 24 ++++++ ebuild-test/root-var-usage/root-var-usage-0.ebuild | 90 ++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 ebuild-test/root-var-usage/metadata.xml create mode 100644 ebuild-test/root-var-usage/root-var-usage-0.ebuild diff --git a/ebuild-test/root-var-usage/metadata.xml b/ebuild-test/root-var-usage/metadata.xml new file mode 100644 index 0000000..f8ba4d0 --- /dev/null +++ b/ebuild-test/root-var-usage/metadata.xml @@ -0,0 +1,24 @@ + + + + + Test that the $ROOT variable is used according to the Package + Manager Specification (PMS). + + All currently-approved versions of the PMS state that the $ROOT + variable is legal only in the pkg_* phases. One common misuse is + to use $ROOT instead of $EPREFIX as "something more general than a + front-slash" in the src_* functions. We want to detect these + mistakes, and eventually eliminate all uses of $ROOT outside of + the PMS-defined pkg_* phases. + + + + exampledev@gentoo.org + Primary maintainer + + + exampleproject@gentoo.org + Gentoo Example Project + + diff --git a/ebuild-test/root-var-usage/root-var-usage-0.ebuild b/ebuild-test/root-var-usage/root-var-usage-0.ebuild new file mode 100644 index 0000000..a46339e --- /dev/null +++ b/ebuild-test/root-var-usage/root-var-usage-0.ebuild @@ -0,0 +1,90 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=6 + +DESCRIPTION="Ensure ROOT variable usage complies with the PMS" +HOMEPAGE="https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-11800011" +LICENSE="BSD" +SLOT="0" +KEYWORDS="~amd64" +IUSE="" + +# All uses of $ROOT within the pkg_* "Ebuild-defined functions" should +# be allowed. The list comes from the so-named chapter of the PMS. + +pkg_pretend() { + local foo=$ROOT +} + +pkg_setup() { + local foo="${ROOT}/foo" +} + +pkg_preinst() { + local foo="$ROOT" +} + +pkg_postinst() { + local foo="bar/${ROOT}" +} + +pkg_prerm() { + local foo="bar/${ROOT}/baz" +} + +pkg_postrm() { + local foo=bar/$ROOT +} + +pkg_config() { + local foo="$ROOT" +} + +pkg_info() { +local foo=$ROOT +} + +pkg_nofetch() { + local foo=`echo $ROOT` +} + +# All uses below here are errors. The following src_* functions are +# defined in the PMS. +src_unpack() { + local foo=$ROOT +} + +src_prepare() { + local foo="${ROOT}/foo" +} + +src_configure() { + local foo=`echo $ROOT` +} + +src_compile() { +local foo=$ROOT +} + +src_test() { + local foo=$(echo $ROOT) +} + +src_install() { + local foo="bar/${ROOT}/baz" +} + +pkg_apocrypha(){ + # This function begins with "pkg_", but isn't defined in the PMS. + local foo=bar/$ROOT +} + +washington_irving(){ + # This function is arbitrarily-named and not defined in the PMS. + local foo="${ROOT}/foo" +} + +# And I suppose we should check that it's not used in global scope, too. +DEPEND="sys-libs${ROOT}glibc" -- cgit v1.2.3-65-gdbad