<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>168442</bug_id>
          
          <creation_ts>2007-02-26 10:26 0000</creation_ts>
          <short_desc>app-portage/portage-utils-0.1.24 does not  properly parse the profile location</short_desc>
          <delta_ts>2007-06-21 14:02:04 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Portage Development</product>
          <component>Tools</component>
          <version>2.1</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <keywords>InCVS</keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>chutz@gg3.net</reporter>
          <assigned_to>portage-utils@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>chutz@gg3.net</who>
            <bug_when>2007-02-26 10:26:18 0000</bug_when>
            <thetext>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&apos;t always work out. For example running the debugging version of &quot;q&quot; 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&apos;s trivial to fix with a chdir(&quot;/etc&quot;) in main.c.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-02-26 18:22:24 0000</bug_when>
            <thetext>Please attach a patch.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>chutz@gg3.net</who>
            <bug_when>2007-02-27 00:08:54 0000</bug_when>
            <thetext>Created an attachment (id=111367)
portae-utils-chdir.patch

Fair enough, here is the patch. I don&apos;t know if changing the directory is the proper way to do it, but the current working directory doesn&apos;t seem to affect anything else so why not.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>chutz@gg3.net</who>
            <bug_when>2007-02-27 00:12:34 0000</bug_when>
            <thetext>Created an attachment (id=111369)
portage-utils-chdir.patch

Oh, what the hell, the chdir should have been outside the loop (not that it makes any differnece).</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-02-27 00:30:12 0000</bug_when>
            <thetext>Thanks. This should be in the 0.1.25</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-04-05 18:42:17 0000</bug_when>
            <thetext>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 &apos;/usr/portage/.metadata.x&apos; 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.
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-04-05 18:43:01 0000</bug_when>
            <thetext>Closing</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-04-09 22:58:57 0000</bug_when>
            <thetext>This change breaks things. We will have to revert it and or come up with a new patch. </thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-04-09 23:08:50 0000</bug_when>
            <thetext>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(&quot;/etc/make.profile&quot;, profile, sizeof(profile)) == -1)
                strcpy(profile, &quot;/etc/make.profile&quot;);
-       chdir(&quot;/etc&quot;);
+       if (profile[0] != &apos;/&apos;) {
+               memmove(profile+5, profile, strlen(profile));
+               memcpy(profile, &quot;/etc/&quot;, 5);
+       }
        do {
                if (f == 0)
                        snprintf(portage_file, sizeof(portage_file), &quot;%s/make.defaults&quot;, profile);</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-06-21 14:02:04 0000</bug_when>
            <thetext>Closing bug</thetext>
          </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>111367</attachid>
            <date>2007-02-27 00:08 0000</date>
            <desc>portae-utils-chdir.patch</desc>
            <filename>putils-chdir.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">ZGlmZiAtcnUgcG9ydGFnZS11dGlscy0wLjEuMjQub3JpZy9tYWluLmMgcG9ydGFnZS11dGlscy0w
LjEuMjQvbWFpbi5jCi0tLSBwb3J0YWdlLXV0aWxzLTAuMS4yNC5vcmlnL21haW4uYwkyMDA3LTAy
LTEyIDA3OjMzOjQ2LjAwMDAwMDAwMCArMDkwMAorKysgcG9ydGFnZS11dGlscy0wLjEuMjQvbWFp
bi5jCTIwMDctMDItMjcgMDk6MDQ6NDkuMDAwMDAwMDAwICswOTAwCkBAIC01MDYsNiArNTA2LDcg
QEAKIAlpZiAocmVhZGxpbmsoIi9ldGMvbWFrZS5wcm9maWxlIiwgcH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4yNDogcXNpemUKT25seSBpbiBwb3J0YWdlLXV0aWxzLTAuMS4y
NDogcXRiejIKT25seSBpbiBwb3J0YWdlLXV0aWxzLTAuMS4yNDogcXVzZQpPbmx5IGluIHBvcnRh
Z2UtdXRpbHMtMC4xLjI0OiBxeHBhawo=
</data>        

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>111369</attachid>
            <date>2007-02-27 00:12 0000</date>
            <desc>portage-utils-chdir.patch</desc>
            <filename>putils-chdir.patch</filename>
            <type>text/plain</type>
            <data encoding="base64">ZGlmZiAtcnUgcG9ydGFnZS11dGlscy0wLjEuMjQub3JpZy9tYWluLmMgcG9ydGFnZS11dGlscy0w
LjEuMjQvbWFpbi5jCi0tLSBwb3J0YWdlLXV0aWxzLTAuMS4yNC5vcmlnL21haW4uYwkyMDA3LTAy
LTEyIDA3OjMzOjQ2LjAwMDAwMDAwMCArMDkwMAorKysgcG9ydGFnZS11dGlscy0wLjEuMjQvbWFp
bi5jCTIwMDctMDItMjcgMDk6MTA6NDIuMDAwMDAwMDAwICswOTAwCkBAIC01MDUsNiArNTA1LDcg
QEAKIAlmID0gMDsKIAlpZiAocmVhZGxpbmsoIi9ldGMvbWFrZS5wcm9maWxlIiwgcHJvZmlsZSwg
c2l6ZW9mKHByb2ZpbGUpKSA9PSAtMSkKIAkJc3RyY3B5KHByb2ZpbGUsICIvZXRjL21ha2UucHJv
ZmlsZSIpOworCWNoZGlyKCIvZXRjIik7CiAJZG8gewogCQlpZiAoZiA9PSAwKQogCQkJc25wcmlu
dGYocG9ydGFnZV9maWxlLCBzaXplb2YocG9ydGFnZV9maWxlKSwgIiVzL21ha2UuZGVmYXVsdHMi
LCBwcm9maWxlKTsK
</data>        

          </attachment>
    </bug>

</bugzilla>