Regression in PREFIX handling in packages

Alexander Leidinger Alexander at Leidinger.net
Wed Aug 29 20:03:04 UTC 2012


On Wed, 29 Aug 2012 21:48:31 +0200 Alexander Leidinger
<Alexander at Leidinger.net> wrote:

> On Wed, 29 Aug 2012 15:28:36 -0400 Eitan Adler <eadler at freebsd.org>
> wrote:
> 
> > On 29 August 2012 15:17, Alexander Leidinger
> > <Alexander at leidinger.net> wrote:
> > > Could it be that my problem comes from r231300 and I was lucky
> > > that I didn't create a package on the machine with the
> > > symlinked /usr/local and used it on a machine with a
> > > normal /usr/local?
> > 
> > I have not been following this thread, so if you traced the bug to
> > this commit, I'll accept that.
> 
> It's a guess, I haven't tried to back it out and test again.
> 
> > > http://svnweb.freebsd.org/base/head/usr.sbin/pkg_install/create/perform.c?r1=228990&r2=231300
> > >
> > > What's the problem this patch tries to solve? Shouldn't the plist
> > > use the prefix as specified by the env variable instead of the
> > > realpath?
> > 
> > The specific problem this patch was trying to solve is to allow the
> > use of "." or other relative paths in the -p argument to pkg_create.
> 
> Wouldn't it be better to use
> ---snip---
> if (Prefix[0] != '/' && realpath(...
> ---snip---
> in this case? Attention: I just guessed what Prefix is and what it
> should contain by looking at the diff, I didn't had a look at the
> declaraction and assignments of Prefix.

And this one is tested (copy&paste, may have lost tabs and add
linebreaks from my mailer):
---snip---
# svn diff
Index: perform.c
===================================================================
--- perform.c   (revision 239708)
+++ perform.c   (working copy)
@@ -215,10 +215,15 @@

     /* Prefix should add an @cwd to the packing list */
     if (Prefix) {
-        char resolved_prefix[PATH_MAX];
-        if (realpath(Prefix, resolved_prefix) == NULL)
-           err(EXIT_FAILURE, "couldn't resolve path for prefix: %s",
     Prefix);
-       add_plist_top(&plist, PLIST_CWD, resolved_prefix);
+       if (Prefix[0] != '/') {
+               char resolved_prefix[PATH_MAX];
+               if (realpath(Prefix, resolved_prefix) == NULL)
+                       err(EXIT_FAILURE,
+                           "couldn't resolve path for prefix: %s",
     Prefix);
+               add_plist_top(&plist, PLIST_CWD, resolved_prefix);
+       } else {
+               add_plist_top(&plist, PLIST_CWD, Prefix);
+       }
     }

     /* Add the origin if asked, at the top */
---snip---

Bye,
Alexander.

-- 
http://www.Leidinger.net    Alexander @ Leidinger.net: PGP ID = B0063FE7
http://www.FreeBSD.org       netchild @ FreeBSD.org  : PGP ID = 72077137


More information about the freebsd-ports mailing list