pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/32163: pkg_create: @src does not override @cwd as advertised



>Number:         32163
>Category:       pkg
>Synopsis:       pkg_create: @src does not override @cwd as advertised
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 25 13:27:00 +0000 2005
>Originator:     Stefan Sperling
>Release:        NetBSD 2.0.2
>Organization:
Elego Software Solutions GmbH (http://elegosoft.com)
>Environment:
System: NetBSD dcvs-netbsd.elego.de 2.0.2 NetBSD 2.0.2 (GENERIC) #0: Wed Mar 23 
08:53:42 UTC 2005 
jmc%faith.netbsd.org@localhost:/home/builds/ab/netbsd-2-0-2-RELEASE/i386/200503220140Z-obj/home/builds/ab/netbsd-2-0-2-RELEASE/src/sys/arch/i386/compile/GENERIC
 i386
>Description:
I am building packages for lots of different UNIX-like systems out of a
single source tree. I install everything into an image directory using
and call the target system specific package creation tools to wrap it up
into a package.

Consider the following extract from the pkg_create man page:

     @cwd directory
             Set the internal directory pointer to point to directory.  All
             subsequent filenames will be assumed relative to this directory.
             Note: @cd is also an alias for this command.
     @src directory
             Set the internal directory pointer for _creation only_ to
             directory.  That is to say that it overrides @cwd for package
             creation but not extraction.

According to the above, I set @cwd to /usr/pkg, and @src to the image directory.
I put these right at the top of the packlist so that all subsequent files
get the right prefix.

But pkg_create's behaviour differs from what is described in the man page.
Whatever I set @src to in my packlist, as soon as there is a @cwd before or
after it, @cwd overrides @src. The result is that pkg_create cannot find any
of the files to pack, because it ends up looking in /usr/pkg instead of
my image directory.

If I understood the pkgsrc makefile jungle (grain of salt) correctly, this
problem does not show up in standard pkgsrc operation because there @src and
@cwd are always the same (/usr/pkg or whatever PKG_PREFIX is set to).
This works because packages are always directly created from files installed
in /usr/pkg.

>How-To-Repeat:
Create a packlist with @src and @cwd set to different values.
@src should point to an image of the package you want to create.
run pkg_create and watch it fail (lots of "can't stat <file>").

>Fix:
        The following patch corrects the problem for me.
        It makes sure that @src always overrides @cwd at package creation time,
        just as advertised in the man page:

--- pkgtools/pkg_install/files/create/pl.c.orig 2005-11-25 15:58:05.000000000 
+0100
+++ pkgtools/pkg_install/files/create/pl.c      2005-11-25 15:59:39.000000000 
+0100
@@ -188,8 +188,8 @@
                                /* after @cwd */
                                /* prepend DESTDIR if set?  - HF */
                                (void) snprintf(name, sizeof(name), "%s%s%s",
-                                       cwd,
-                                       (strcmp(cwd, "/") == 0) ? "" : "/",
+                                       srcdir ? srcdir : cwd,
+                                       (strcmp(srcdir ? srcdir : cwd, "/") == 
0) ? "" : "/",
                                        p->name);
                        }
                        if (lstat(name, &st) < 0) {




Home | Main Index | Thread Index | Old Index