Gentoo Archives: gentoo-dev

From: "Gregory M. Turner" <gmt@×××××.us>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] relative ROOT: correct behavior when ROOT=
Date: Thu, 06 Sep 2012 07:45:57
Message-Id: 5048547B.3040601@malth.us
1 Hello, in my overlay I need to fix a bunch of issues that crop up when
2 implementing EPREFIX construction in scripts due to Cygwin's
3 idiosyncratic, but POSIX-compliant, handling of paths beginning with
4 "//" (Cygwin does some arguably pathological stuff when such paths are
5 used).
6
7 Almost all of these stem from the careless tacking of "ROOT" onto
8 "EPREFIX" in bash-scripts, i.e., as in this (made-up) bash-script snippet:
9
10 ${ROOT:=/}
11 EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
12 EROOT="${ROOT}${EPREFIX}"
13
14 When ROOT is undefined or empty, this script will assign "//foo" to
15 EROOT and bad things will happen in Cygwin.
16
17 Several correct-ish solutions exist, i.e., in the above we could change
18 the concatenation statement to read:
19
20 EROOT="${ROOT}${EPREFIX#/}"
21
22 Thats a matter for another thread, however.
23
24 As I've been reading code like the above, I've stumbled across some bugs
25 and inconsistencies pertaining to relative-ROOT and I've been trying to
26 file bugs to get these fixed.
27
28 One such issue pertains to the case where the ROOT environment variable
29 is defined, but empty. Portage and most python code seem to treat this
30 as equivalent to ROOT="${PWD}", which is to say, that relative-root
31 functionality is triggered by this circumstance.
32
33 However, several app-admin and sys-devel scripts "disagree" and treat
34 this as equivalent to ROOT="/" (as does my example above).
35
36 So... which behavior is correct? Since I'm aware of the issue, I'd
37 might as well file bugs against the incorrect ones and get everything
38 consistent.
39
40 -gmt

Replies

Subject Author
Re: [gentoo-dev] relative ROOT: correct behavior when ROOT= Ulrich Mueller <ulm@g.o>