From owner-freebsd-emulation@FreeBSD.ORG Tue Oct 18 18:22:50 2005 Return-Path: X-Original-To: freebsd-emulation@freebsd.org Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F1C2F16A41F for ; Tue, 18 Oct 2005 18:22:49 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [64.174.51.43]) by mx1.FreeBSD.org (Postfix) with ESMTP id 844B943D45 for ; Tue, 18 Oct 2005 18:22:49 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from server2.ambrisko.com (HELO www.ambrisko.com) ([192.168.1.2]) by mail.ambrisko.com with ESMTP; 18 Oct 2005 11:22:49 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by www.ambrisko.com (8.12.11/8.12.9) with ESMTP id j9IIMmvC057649; Tue, 18 Oct 2005 11:22:48 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.12.11/8.12.11/Submit) id j9IIMmHk057648; Tue, 18 Oct 2005 11:22:48 -0700 (PDT) (envelope-from ambrisko) From: Doug Ambrisko Message-Id: <200510181822.j9IIMmHk057648@ambrisko.com> In-Reply-To: <20051018181351.GB89074@xor.obsecurity.org> To: Kris Kennaway Date: Tue, 18 Oct 2005 11:22:48 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL94b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Cc: freebsd-emulation@freebsd.org Subject: Re: cross platform building under emulation X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2005 18:22:50 -0000 Kris Kennaway writes: | On Fri, Oct 14, 2005 at 07:27:00PM -0700, Doug Ambrisko wrote: | > Dan Langille writes: | > | Daris has got me thinking about unpacking 4.9-release/bin into a | > | directory, and then doing a chroot. | > | > That sort-of works. I've done some setups for companies and get | > iteratively better solutions. I copy over some host bins & libs | > into special directories so mount, ps etc can be run from inside. | > I also have mods to libc so that uname & getosreldate so it can | > be set via env. variables so pkg_add, autoconf etc picks up the | > right stuff. Now this is a little trickier for old version of | > libc that I haven't modified locally yet so I build a stub lib. | > of these in the chroot then load this then LD_PRELOAD. If you don't | > then some things get messed up. | > | > This lets me build on a FreeBSD 6.X/amd64 host for FreeBSD 4.X/386, | > FreeBSD amd64 etc. I've also at times loaded in the Linux tools and | > made that work so I could build Linux bins in chroots. | > | > I hope to commit my changes to getosreldate(3) and uname(3). | > This mirrors the env. variables in /usr/bin/uname. | | I'd find this very useful too (and will start using your patch), | thanks! Please don't use that. Instead this one works better. The prior one caused getty and xdm to core dump :-( Index: lib/libc/gen/__xuname.c =================================================================== RCS file: /cvs/src/lib/libc/gen/__xuname.c,v retrieving revision 1.9 diff -u -p -r1.9 __xuname.c --- lib/libc/gen/__xuname.c 1 Feb 2002 00:57:29 -0000 1.9 +++ lib/libc/gen/__xuname.c 18 Oct 2005 18:18:29 -0000 @@ -41,6 +41,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include int __xuname(int namesize, void *namebuf) @@ -71,6 +73,8 @@ __xuname(int namesize, void *namebuf) rval = -1; } name->sysname[sizeof(name->sysname) - 1] = '\0'; + if ((p = getenv("UNAME_s"))) + strncpy(name->sysname, p, sizeof(name->sysname)); mib[0] = CTL_KERN; mib[1] = KERN_HOSTNAME; @@ -95,6 +99,8 @@ __xuname(int namesize, void *namebuf) rval = -1; } name->release[sizeof(name->release) - 1] = '\0'; + if ((p = getenv("UNAME_r"))) + strncpy(name->release, p, sizeof(name->release)); /* The version may have newlines in it, turn them into spaces. */ mib[0] = CTL_KERN; @@ -116,6 +122,8 @@ __xuname(int namesize, void *namebuf) *p = '\0'; } } + if ((p = getenv("UNAME_v"))) + strncpy(name->version, p, sizeof(name->version)); mib[0] = CTL_HW; mib[1] = HW_MACHINE; @@ -128,5 +136,7 @@ __xuname(int namesize, void *namebuf) rval = -1; } name->machine[sizeof(name->machine) - 1] = '\0'; + if ((p = getenv("UNAME_m"))) + strncpy(name->machine, p, sizeof(name->machine)); return (rval); } Index: lib/libc/gen/getosreldate.c =================================================================== RCS file: /cvs/src/lib/libc/gen/getosreldate.c,v retrieving revision 1.7 diff -u -p -r1.7 getosreldate.c --- lib/libc/gen/getosreldate.c 12 Sep 2005 19:52:41 -0000 1.7 +++ lib/libc/gen/getosreldate.c 18 Oct 2005 18:18:29 -0000 @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include @@ -49,10 +50,14 @@ getosreldate(void) size_t size; int value; + char *temp; + mib[0] = CTL_KERN; mib[1] = KERN_OSRELDATE; size = sizeof value; if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) return (-1); + if ((temp = getenv("OSVERSION"))) + value = atoi(temp); return (value); } Please let me know how this one goes. If you are interested I could give you stuff to build a shared lib wedge of this to retrofit it into older shared lib binaries. Doug A.