Add support to easily build FreeBSD unpacked in a chroot of another
FreeBSD machine. To do this add the man 1 uname changes to __xuname.c so we can override the settings it reports. Add OSVERSION override to getosreldate. Finally which Makefile.inc1 to use uname -m instead of sysctl -n hw.machine_arch to get the arch. type. With these change you can put a complete FreeBSD OS image into a chroot set: UNAME_s=FreeBSD UNAME_r=4.7-RELEASE UNAME_v="FreeBSD $UNAME_r #1: Fri Jul 22 20:32:52 PDT 2005 fake@fake:/usr/obj/usr/src/sys/FAKE" UNAME_m=i386 UNAME_p=i386 OSVERSION=470000 on an amd64 or i386 and it just work including building ports and using pkg_add -r etc. The caveat for this example is that these patches have to be applied to FreeBSD 4.7 and the uname(1) changes need to be merged. This also addresses issue with libtool. This is usefull for when a build machine has been trashed for an old release and we want to do a build on a new machine that FreeBSD 4.7 won't run on ...
This commit is contained in:
parent
d19ff8f1d2
commit
d630a05f40
@ -122,7 +122,7 @@ _CPUTYPE!= MAKEFLAGS= CPUTYPE=${_TARGET_CPUTYPE} ${MAKE} \
|
||||
.error CPUTYPE global should be set with ?=.
|
||||
.endif
|
||||
.if make(buildworld)
|
||||
BUILD_ARCH!= sysctl -n hw.machine_arch
|
||||
BUILD_ARCH!= uname -m
|
||||
.if ${MACHINE_ARCH} != ${BUILD_ARCH}
|
||||
.error To cross-build, set TARGET_ARCH.
|
||||
.endif
|
||||
|
@ -71,6 +71,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 +97,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 +120,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 +134,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);
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <osreldate.h>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user