FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 09-06-2012, 07:44 AM
"Gregory M. Turner"
 
Default relative ROOT: correct behavior when ROOT=

Hello, in my overlay I need to fix a bunch of issues that crop up when
implementing EPREFIX construction in scripts due to Cygwin's
idiosyncratic, but POSIX-compliant, handling of paths beginning with
"//" (Cygwin does some arguably pathological stuff when such paths are
used).


Almost all of these stem from the careless tacking of "ROOT" onto
"EPREFIX" in bash-scripts, i.e., as in this (made-up) bash-script snippet:


${ROOT:=/}
EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
EROOT="${ROOT}${EPREFIX}"

When ROOT is undefined or empty, this script will assign "//foo" to
EROOT and bad things will happen in Cygwin.


Several correct-ish solutions exist, i.e., in the above we could change
the concatenation statement to read:


EROOT="${ROOT}${EPREFIX#/}"

Thats a matter for another thread, however.

As I've been reading code like the above, I've stumbled across some bugs
and inconsistencies pertaining to relative-ROOT and I've been trying to
file bugs to get these fixed.


One such issue pertains to the case where the ROOT environment variable
is defined, but empty. Portage and most python code seem to treat this
as equivalent to ROOT="${PWD}", which is to say, that relative-root
functionality is triggered by this circumstance.


However, several app-admin and sys-devel scripts "disagree" and treat
this as equivalent to ROOT="/" (as does my example above).


So... which behavior is correct? Since I'm aware of the issue, I'd
might as well file bugs against the incorrect ones and get everything
consistent.


-gmt
 
Old 09-06-2012, 07:55 AM
Ulrich Mueller
 
Default relative ROOT: correct behavior when ROOT=

>>>>> On Thu, 06 Sep 2012, Gregory M Turner wrote:

> Hello, in my overlay I need to fix a bunch of issues that crop up when
> implementing EPREFIX construction in scripts due to Cygwin's
> idiosyncratic, but POSIX-compliant, handling of paths beginning with
> "//" (Cygwin does some arguably pathological stuff when such paths are
> used).

> Almost all of these stem from the careless tacking of "ROOT" onto
> "EPREFIX" in bash-scripts, i.e., as in this (made-up) bash-script snippet:

> ${ROOT:=/}
> EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
> EROOT="${ROOT}${EPREFIX}"

> When ROOT is undefined or empty, this script will assign "//foo" to
> EROOT and bad things will happen in Cygwin.

> Several correct-ish solutions exist, i.e., in the above we could change
> the concatenation statement to read:

> EROOT="${ROOT}${EPREFIX#/}"

I'd rather do it the other way around:
EROOT=${ROOT%/}${EPREFIX}

Reason: EPREFIX is guaranteed to start with a slash, whereas for ROOT
I wouldn't be so sure that it always ends with one.

Ulrich
 
Old 09-06-2012, 09:34 AM
"Gregory M. Turner"
 
Default relative ROOT: correct behavior when ROOT=

On 9/6/2012 12:55 AM, Ulrich Mueller wrote:

On Thu, 06 Sep 2012, Gregory M Turner wrote:

Several correct-ish solutions exist, i.e., in the above we could change
the concatenation statement to read:



EROOT="${ROOT}${EPREFIX#/}"


I'd rather do it the other way around:
EROOT=${ROOT%/}${EPREFIX}

Reason: EPREFIX is guaranteed to start with a slash, whereas for ROOT
I wouldn't be so sure that it always ends with one.


Good point, but EPREFIX is empty for non-prefix gentoo. So, I guess:

EROOT="${ROOT%/}/${EPREFIX#/}"

It's a contrived example anyhow, so it's mostly academic.

My main concern is the correct behavior when ROOT is defined, but empty
-- I mostly included this explanation to preempt anyone inclined to ask
"what are you trying to achieve?" :P


-gmt
 
Old 09-06-2012, 12:56 PM
Ian Stakenvicius
 
Default relative ROOT: correct behavior when ROOT=

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 06/09/12 03:55 AM, Ulrich Mueller wrote:
>>>>>> On Thu, 06 Sep 2012, Gregory M Turner wrote:
>
>> Hello, in my overlay I need to fix a bunch of issues that crop up
>> when implementing EPREFIX construction in scripts due to Cygwin's
>> idiosyncratic, but POSIX-compliant, handling of paths beginning
>> with "//" (Cygwin does some arguably pathological stuff when such
>> paths are used).
>
>> Almost all of these stem from the careless tacking of "ROOT" onto
>> "EPREFIX" in bash-scripts, i.e., as in this (made-up)
>> bash-script snippet:
>
>> ${ROOT:=/} EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
>> EROOT="${ROOT}${EPREFIX}"
>
>> When ROOT is undefined or empty, this script will assign "//foo"
>> to EROOT and bad things will happen in Cygwin.
>
>> Several correct-ish solutions exist, i.e., in the above we could
>> change the concatenation statement to read:
>
>> EROOT="${ROOT}${EPREFIX#/}"
>
> I'd rather do it the other way around: EROOT=${ROOT%/}${EPREFIX}
>
> Reason: EPREFIX is guaranteed to start with a slash, whereas for
> ROOT I wouldn't be so sure that it always ends with one.
>
> Ulrich
>

Not to mention that `man 5 ebuild` specifically defines EROOT to be
"${ROOT%/}${EPREFIX}/" already , so all that's needed is the removal
of the final '/' if I'm reading this correctly..





-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iF4EAREIAAYFAlBInW8ACgkQ2ugaI38ACPA0UQD/YePPvXa5wNhdvpk656RtwNwa
+yUJKdh/cdu2d8lKCcQA/2/SI4ApNEY/uAf0VxEyRKE6jxdm9/KM6a9gWfSJ0ttn
=gJ7i
-----END PGP SIGNATURE-----
 

Thread Tools




All times are GMT. The time now is 12:17 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org