NetBSD Problem Report #50614

From www@NetBSD.org  Sun Jan  3 00:05:02 2016
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 190747ABC4
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  3 Jan 2016 00:05:02 +0000 (UTC)
Message-Id: <20160103000500.CDFEE7ABE7@mollari.NetBSD.org>
Date: Sun,  3 Jan 2016 00:05:00 +0000 (UTC)
From: mmayer@mmayer.net
Reply-To: mmayer@mmayer.net
To: gnats-bugs@NetBSD.org
Subject: Architecture mismatch on Darwin
X-Send-Pr-Version: www-1.0

>Number:         50614
>Category:       pkg
>Synopsis:       Architecture mismatch on Darwin
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 03 00:10:00 +0000 2016
>Last-Modified:  Sun Jan 03 01:35:00 +0000 2016
>Originator:     Markus Mayer
>Release:        HEAD on January 2, 2016
>Organization:
>Environment:
Darwin edmonds.home.lan 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64 i386 Macmini6,2 Darwin

>Description:
Bootstrapping a new pkgsrc installation, the bootstrap command would fail during the very first pkg_add. pkg_add would complain that the package was built for a different architecture than it is being installed on.

(This turned out to be a confusion between i386 [architecture] and x86_64 [binary format]).
>How-To-Repeat:
Simply run ./bootstrap --prefix=/opt/pkg --varbase=/var (just "./bootstrap" would likely do, too)
>Fix:
I think this is the right thing to do. Since "uname -p" always returns i386 on Darwin (but "uname -m" returns the actual machine architecture), one cannot rely on the output of "uname -p" if it is to be compared to the ouput of "uname -m" later.

Once I made this simple change to the bootstrap script, I was able to bootstrap my new pkgsrc installation.

$ git diff .
diff --git a/bootstrap/bootstrap b/bootstrap/bootstrap
index 48f1abd..db0136e 100755
--- a/bootstrap/bootstrap
+++ b/bootstrap/bootstrap
@@ -555,7 +555,7 @@ Darwin)
        need_sed=no
        set_opsys=no
        get_abi "Darwin"
-       machine_arch=`uname -p`
+       machine_arch=`uname -m`
        CC=${CC:-"cc -isystem /usr/include"}; export CC
        check_compiler=yes
        osrev=`uname -r`

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: install-manager->pkg-manager
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Sun, 03 Jan 2016 00:34:12 +0000
Responsible-Changed-Why:
pkgsrc issue


From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: pkgsrc-bugs@netbsd.org, gnats-admin@netbsd.org, mmayer@mmayer.net
Subject: Re: pkg/50614 (Architecture mismatch on Darwin)
Date: Sun, 3 Jan 2016 02:34:38 +0100

 Better approach (untested):

 Index: bootstrap
 ===================================================================
 RCS file: /home/joerg/repo/netbsd/pkgsrc/bootstrap/bootstrap,v
 retrieving revision 1.225
 diff -u -p -r1.225 bootstrap
 --- bootstrap	29 Dec 2015 21:13:57 -0000	1.225
 +++ bootstrap	3 Jan 2016 01:33:16 -0000
 @@ -560,6 +560,11 @@ Darwin)
  	check_compiler=yes
  	osrev=`uname -r`
  	macosx_version=`echo $osrev | awk -F . '{ print "10."$1-4; }'`
 +	case "$machine_arch/$abi" in
 +	i386/64)
 +		machine_arch=x86_64
 +		;;
 +	esac
  	case "$macosx_version" in
  	10.[7-9])
  		packagemaker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker

 Joerg

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.