Re: [pkg_add] PACKAGESITE weirdness - URL not correct for dependencies?

2009-03-28 Thread L Campbell
On Sat, Mar 28, 2009 at 7:37 AM, Mel Flynn
 wrote:
> On Thursday 26 March 2009 21:46:07 L Campbell wrote:
>> Okay, so apparently there's some serious weirdness in the logic in
>> src/usr.sbin/pkg_install/lib/url.c, in fileGetURL. This function takes
>> two parameters, base and spec, and has the following behavior --
>
> 
>
> Yes, it is a bit counter-intuitive. However it's documented in the pkg_add(1)
> manpage that PACKAGESITE should resolve to the full URL where packages can be
> found (even the trailing slash).

The additional stipulation that any dependent packages must be in an
"../All/" directory relative to the path of the initial package is an
undocumented feature.

It's a bit counter-intuitive, but once it works, it works.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: [pkg_add] PACKAGESITE weirdness - URL not correct for dependencies?

2009-03-28 Thread Mel Flynn
On Thursday 26 March 2009 21:46:07 L Campbell wrote:
> Okay, so apparently there's some serious weirdness in the logic in
> src/usr.sbin/pkg_install/lib/url.c, in fileGetURL. This function takes
> two parameters, base and spec, and has the following behavior --



Yes, it is a bit counter-intuitive. However it's documented in the pkg_add(1) 
manpage that PACKAGESITE should resolve to the full URL where packages can be 
found (even the trailing slash).

I've found in practice, that it is the easiest to set your webroot below All/, 
so that All/foo-1.2.3.tbz resolves to the foo 1.2.3 package. Then also 
maintain the various categories links like devel/foo.tbz and as human use 
pkg_add like so:
pkg_add -r devel/foo

This will do the right thing(tm) and you don't have to look up/remember the 
version numbers as a bonus.
-- 
Mel
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: [pkg_add] PACKAGESITE weirdness - URL not correct for dependencies?

2009-03-26 Thread L Campbell
Okay, so apparently there's some serious weirdness in the logic in
src/usr.sbin/pkg_install/lib/url.c, in fileGetURL. This function takes
two parameters, base and spec, and has the following behavior --

* if spec is a valid URL, it's used unchanged as the path to the remote package.
* if base is non-NULL, the last two '/'s are chopped off and "All/" +
package name + ".tbz" is used as the result.
* if PKG_ADD_BASE is set in the environment, it's concatenated with
the package name and ".tbz"

When fileGetURL is called on the dependencies by pkg_do in
add/perform.c, it always gets passed the remote URL of the parent
package as the base and the package name as the spec, so the second
branch is always taken.

Unfortunately, this doesn't work with the PACKAGESITE code in
add/main.c, because fileGetURL is expecting the base argument to be of
the form "http://host/directory/package.tbz";, as in
"www/lighttpd-1.4.22.tbz". The problem is, when using PACKAGESITE, the
actual URL (in my case) is just "http://host/lighttpd-1.4.22.tbz";, so
that gets incorrectly chopped down to "http:/" + "Add/" +
"lighttpd-1.4.22.tbz".

It works fine if your PACKAGESITE puts all the packages in the "All/"
subdirectory (as I think the official ones do), but at the very least,
that's an undocumented constraint.

My solution was to add another case into fileGetURL which gets
overrides the three currently in there and is invoked if and only if
PACKAGESITE is set in the environment.

The following patch makes it work for me --

--- usr.sbin/pkg_install/lib/url.c.orig 2009-03-26 19:56:12.0 +
+++ usr.sbin/pkg_install/lib/url.c  2009-03-26 20:41:44.0 +
@@ -57,7 +57,21 @@
 * to construct a composite one out of that and the basename we were
 * handed as a dependency.
 */
-   if (base) {
+   if (getenv("PACKAGESITE")) {
+   if (strlcpy(fname, getenv("PACKAGESITE"), sizeof(fname))
+   >= sizeof(fname)) {
+   return NULL;
+   }
+   if (strlcat(fname, spec, sizeof(fname))
+   >= sizeof(fname)) {
+   return NULL;
+   }
+   if (strlcat(fname, ".tbz", sizeof(fname))
+   >= sizeof(fname)) {
+   return NULL;
+   }
+   }
+   else if (base) {
strcpy(fname, base);
/*
 * Advance back two slashes to get to the root of the package

Though I think, in the long-run I'm just going to put all my packages
in http://10.0.0.4/All/ and call it a day -- I hate maintaining a
bunch of patches for stuff.

:(
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: [pkg_add] PACKAGESITE weirdness - URL not correct for dependencies?

2009-03-26 Thread L Campbell
On Thu, Mar 26, 2009 at 3:37 PM, L Campbell  wrote:
> blah

Oh, and please CC me on any replies since I don't follow this list.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"