Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 168442 - app-portage/portage-utils-0.1.24 does not properly parse the profile location
Summary: app-portage/portage-utils-0.1.24 does not properly parse the profile location
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage Utils Team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2007-02-26 10:26 UTC by Georgi Georgiev
Modified: 2007-06-21 14:02 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
portae-utils-chdir.patch (putils-chdir.patch,1.14 KB, patch)
2007-02-27 00:08 UTC, Georgi Georgiev
Details | Diff
portage-utils-chdir.patch (putils-chdir.patch,468 bytes, patch)
2007-02-27 00:12 UTC, Georgi Georgiev
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Georgi Georgiev 2007-02-26 10:26:18 UTC
While looking at bug #168334 I found this one. Not exactly a showstopper nor have I discovered any unexpected behavior but anyway

portage-utils tries to follow the location pointed to by /etc/make.profile but when this is a relative location (as set by eselect for example) it doesn't always work out. For example running the debugging version of "q" from /root (or /usr or /etc) gives me:

profile ../usr/portage/profiles/default-linux/amd64/2006.1/make.defaults
profile ../usr/portage/profiles/default-linux/amd64/2006.1/../make.defaults
profile ../usr/portage/profiles/default-linux/amd64/2006.1/../../make.defaults
profile ../usr/portage/profiles/default-linux/amd64/2006.1/../../../base/make.defaults
profile /etc/make.globals
profile /etc/make.conf

which is right, but when running from two levels or more deep (like $HOME for a non-root user for example) I get:
profile ../usr/portage/profiles/default-linux/amd64/2006.1/make.defaults
profile /etc/make.globals
profile /etc/make.conf

It's trivial to fix with a chdir("/etc") in main.c.
Comment 1 solar (RETIRED) gentoo-dev 2007-02-26 18:22:24 UTC
Please attach a patch.
Comment 2 Georgi Georgiev 2007-02-27 00:08:54 UTC
Created attachment 111367 [details, diff]
portae-utils-chdir.patch

Fair enough, here is the patch. I don't know if changing the directory is the proper way to do it, but the current working directory doesn't seem to affect anything else so why not.
Comment 3 Georgi Georgiev 2007-02-27 00:12:34 UTC
Created attachment 111369 [details, diff]
portage-utils-chdir.patch

Oh, what the hell, the chdir should have been outside the loop (not that it makes any differnece).
Comment 4 solar (RETIRED) gentoo-dev 2007-02-27 00:30:12 UTC
Thanks. This should be in the 0.1.25
Comment 5 solar (RETIRED) gentoo-dev 2007-04-05 18:42:17 UTC
This is released in 0.1.25

Bug #168334 ; q -r dies with a segfault after emerge --sync
Bug #168442 ; does not  properly parse the profile location
Bug #170795 ; add a -E/--eclass option to qgrep
Bug #170797 ; add a -s/--skip-comments option to qgrep
Bug #171024 ; opening '/usr/portage/.metadata.x' failed
Bug #171374 ; Misc enhancements for qgrep
Bug #172240 ; -A/-B options for qgrep (context lines) 
Bug #172338 ; qgrepping through installed ebuilds (in the VDB) 
Bug #173005 ; Colorized output for qgrep.
Comment 6 solar (RETIRED) gentoo-dev 2007-04-05 18:43:01 UTC
Closing
Comment 7 solar (RETIRED) gentoo-dev 2007-04-09 22:58:57 UTC
This change breaks things. We will have to revert it and or come up with a new patch. 
Comment 8 solar (RETIRED) gentoo-dev 2007-04-09 23:08:50 UTC
This patch comes from vapier to address the breakage caused by your patch.

--- main.c      8 Apr 2007 19:45:41 -0000       1.136
+++ main.c      9 Apr 2007 23:01:13 -0000
@@ -508,7 +508,10 @@ void initialize_portage_env(void)
        f = 0;
        if (readlink("/etc/make.profile", profile, sizeof(profile)) == -1)
                strcpy(profile, "/etc/make.profile");
-       chdir("/etc");
+       if (profile[0] != '/') {
+               memmove(profile+5, profile, strlen(profile));
+               memcpy(profile, "/etc/", 5);
+       }
        do {
                if (f == 0)
                        snprintf(portage_file, sizeof(portage_file), "%s/make.defaults", profile);
Comment 9 solar (RETIRED) gentoo-dev 2007-06-21 14:02:04 UTC
Closing bug