From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Apr 16 19:50:01 2010 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BAD501065674 for ; Fri, 16 Apr 2010 19:50:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 97AE78FC1E for ; Fri, 16 Apr 2010 19:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o3GJo1s7066522 for ; Fri, 16 Apr 2010 19:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o3GJo1C6066521; Fri, 16 Apr 2010 19:50:01 GMT (envelope-from gnats) Resent-Date: Fri, 16 Apr 2010 19:50:01 GMT Resent-Message-Id: <201004161950.o3GJo1C6066521@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Emil Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98DE81065678 for ; Fri, 16 Apr 2010 19:42:32 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 87D548FC1A for ; Fri, 16 Apr 2010 19:42:32 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o3GJgWQo049306 for ; Fri, 16 Apr 2010 19:42:32 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o3GJgWhO049305; Fri, 16 Apr 2010 19:42:32 GMT (envelope-from nobody) Message-Id: <201004161942.o3GJgWhO049305@www.freebsd.org> Date: Fri, 16 Apr 2010 19:42:32 GMT From: Emil To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/145763: pkg_add doesn't fetch packages from other architectures X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Apr 2010 19:50:01 -0000 >Number: 145763 >Category: ports >Synopsis: pkg_add doesn't fetch packages from other architectures >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Apr 16 19:50:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Emil >Release: 8.0-RELEASE >Organization: >Environment: >Description: pkg_add cannot be used to fetch packages from other architectures than the own. For use with embedded image generation tools, like nanobsd, this is a limitation, as it means that one must fetch all desired packages manually. Which is time consuming and error-prone. Cross-compilation is possible, so this is one of the few obstacles to be circumvented in order to have a fully automated build process. I propose adding a new switch (-A,--architecture) to rewrite the URL to the package repository in order to allow fetching of other architecture packages. This feature should be used with caution as it will potentially overwrite the installed packages with wrong ones. >How-To-Repeat: run pkg_add on a machine of a different architecture than the desired embedded target >Fix: See attached diff-file Patch attached with submission follows: *** main.c.bak.20100414 2009-12-26 19:15:51.000000000 +0100 --- /usr/src/usr.sbin/pkg_install/add/main.c 2010-04-14 18:38:15.000000000 +0200 *************** *** 95,108 **** { 0, 0, NULL } }; static char *getpackagesite(void); int getosreldate(void); static void usage(void); ! static char opts[] = "hviIRfFnrp:P:SMt:C:K"; static struct option longopts[] = { { "chroot", required_argument, NULL, 'C' }, { "dry-run", no_argument, NULL, 'n' }, { "force", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, --- 95,109 ---- { 0, 0, NULL } }; static char *getpackagesite(void); int getosreldate(void); + char* architecture; static void usage(void); ! static char opts[] = "hviIRfFnrp:P:SMt:C:KA:"; static struct option longopts[] = { { "chroot", required_argument, NULL, 'C' }, { "dry-run", no_argument, NULL, 'n' }, { "force", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, *************** *** 114,123 **** --- 115,125 ---- { "prefix", required_argument, NULL, 'p' }, { "remote", no_argument, NULL, 'r' }, { "template", required_argument, NULL, 't' }, { "slave", no_argument, NULL, 'S' }, { "verbose", no_argument, NULL, 'v' }, + { "architecture", required_argument, NULL, 'A' }, { NULL, 0, NULL, 0 } }; int main(int argc, char **argv) *************** *** 125,134 **** --- 127,140 ---- int ch, error; char **start; char *cp, *packagesite = NULL, *remotepkg = NULL, *ptr; static char temppackageroot[MAXPATHLEN]; static char pkgaddpath[MAXPATHLEN]; + struct utsname u; + + uname(&u); + architecture = u.machine; if (*argv[0] != '/' && strchr(argv[0], '/') != NULL) PkgAddCmd = realpath(argv[0], pkgaddpath); else PkgAddCmd = argv[0]; *************** *** 196,205 **** --- 202,214 ---- break; case 'i': IgnoreDeps = TRUE; break; + case 'A': + architecture = optarg; + break; case 'h': default: usage(); break; *************** *** 297,307 **** static char * getpackagesite(void) { int reldate, i; static char sitepath[MAXPATHLEN]; - struct utsname u; if (getenv("PACKAGESITE")) { if (strlcpy(sitepath, getenv("PACKAGESITE"), sizeof(sitepath)) >= sizeof(sitepath)) return NULL; --- 306,315 ---- *************** *** 320,331 **** if (strlcat(sitepath, "/pub/FreeBSD/ports/", sizeof(sitepath)) >= sizeof(sitepath)) return NULL; ! uname(&u); ! if (strlcat(sitepath, u.machine, sizeof(sitepath)) >= sizeof(sitepath)) return NULL; reldate = getosreldate(); for(i = 0; releases[i].directory != NULL; i++) { if (reldate >= releases[i].lowver && reldate <= releases[i].hiver) { --- 328,338 ---- if (strlcat(sitepath, "/pub/FreeBSD/ports/", sizeof(sitepath)) >= sizeof(sitepath)) return NULL; ! if (strlcat(sitepath, architecture, sizeof(sitepath)) >= sizeof(sitepath)) return NULL; reldate = getosreldate(); for(i = 0; releases[i].directory != NULL; i++) { if (reldate >= releases[i].lowver && reldate <= releases[i].hiver) { >Release-Note: >Audit-Trail: >Unformatted: