Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Apr 2010 19:42:32 GMT
From:      Emil <the_mix_room@hotmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/145763: pkg_add doesn't fetch packages from other architectures
Message-ID:  <201004161942.o3GJgWhO049305@www.freebsd.org>
Resent-Message-ID: <201004161950.o3GJo1C6066521@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004161942.o3GJgWhO049305>