From owner-freebsd-questions@FreeBSD.ORG Thu Mar 26 20:46:09 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38982106564A for ; Thu, 26 Mar 2009 20:46:09 +0000 (UTC) (envelope-from llc2w@virginia.edu) Received: from fork10.mail.virginia.edu (fork10.mail.Virginia.EDU [128.143.2.180]) by mx1.freebsd.org (Postfix) with ESMTP id E36238FC14 for ; Thu, 26 Mar 2009 20:46:08 +0000 (UTC) (envelope-from llc2w@virginia.edu) Received: from localhost (localhost [127.0.0.1]) by fork10.mail.virginia.edu (Postfix) with ESMTP id 0458D1F5182 for ; Thu, 26 Mar 2009 16:46:08 -0400 (EDT) Received: from fork10.mail.virginia.edu ([127.0.0.1]) by localhost (fork10.mail.virginia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19834-04 for ; Thu, 26 Mar 2009 16:46:07 -0400 (EDT) Received: from yx-out-1718.google.com (yx-out-1718.google.com [74.125.44.155]) by fork10.mail.virginia.edu (Postfix) with ESMTP id CD5621F5172 for ; Thu, 26 Mar 2009 16:46:07 -0400 (EDT) Received: by yx-out-1718.google.com with SMTP id 6so508924yxn.6 for ; Thu, 26 Mar 2009 13:46:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.185.21 with SMTP id i21mr523296wff.220.1238100367233; Thu, 26 Mar 2009 13:46:07 -0700 (PDT) In-Reply-To: <792298050903261238y47cd2c01j6f645ad27d59dd84@mail.gmail.com> References: <792298050903261237o4d57a47dpb99861279ee9b4f6@mail.gmail.com> <792298050903261238y47cd2c01j6f645ad27d59dd84@mail.gmail.com> Date: Thu, 26 Mar 2009 16:46:07 -0400 Message-ID: <792298050903261346m67896d1eo75694509494ff5f8@mail.gmail.com> From: L Campbell To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-UVA-Virus-Scanned: by amavisd-new at fork10.mail.virginia.edu Subject: Re: [pkg_add] PACKAGESITE weirdness - URL not correct for dependencies? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2009 20:46:09 -0000 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.000000000 +0000 +++ usr.sbin/pkg_install/lib/url.c 2009-03-26 20:41:44.000000000 +0000 @@ -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. :(