commit:     3a20e05d5c1e83c0fcf000918ced99717f5368c9
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 04:22:23 2026 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 04:22:23 2026 +0000
URL:        https://gitweb.gentoo.org/proj/install-xattr.git/commit/?id=3a20e05d

Look at __PORTAGE_HELPER_CWD instead of OLDCWD

Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 install-xattr.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/install-xattr.c b/install-xattr.c
index cbc4277..d785815 100644
--- a/install-xattr.c
+++ b/install-xattr.c
@@ -295,18 +295,11 @@ main(int argc, char* argv[])
        first = optind;
        last = argc - 1;
 
-       /* Do we need to chdir to OLDPWD?  This is required when we are called 
my a
-        * wrapper like ${__PORTAGE_HELPER_PATH} which then passes its 
directory as
-        * $PWD and the source directory from which it was called as $OLDPWD.  
But
-        * we want the system install to run in the source directory, ie 
$OLDPWD,
-        * so we chdir to it.  Currently we assume that if __PORTAGE_HELPER_PATH
-        * is set, then we chdir to oldpwd.
-        */
-       char *oldpwd = getenv("OLDPWD");
-       char *portage_helper_path = getenv("__PORTAGE_HELPER_PATH");
-       if (portage_helper_path)
-               if (!oldpwd || chdir(oldpwd) != 0)
-                       err(1, "failed to chdir %s", oldpwd);
+       /* If this is set it means Portage has switched the working directory
+        * and expects us to switch back. */
+       char *portage_helper_cwd = getenv("__PORTAGE_HELPER_CWD");
+       if (portage_helper_cwd && chdir(portage_helper_cwd))
+               err(1, "failed to chdir %s", portage_helper_cwd);
 
        argv[0] = getenv("REAL_INSTALL") ?: REAL_INSTALL;
 

Reply via email to