build: more on cross-building using qemu
This commit is contained in:
parent
b725261952
commit
767afa741f
12
README.md
12
README.md
|
@ -130,6 +130,18 @@ A virtual machine disk image is created using:
|
|||
|
||||
# make vm
|
||||
|
||||
Cross-building for other architecures
|
||||
=====================================
|
||||
|
||||
This feature is currently experimental. It requires
|
||||
to install a qemu package for user mode emulation:
|
||||
|
||||
# pkg install qemu-user-static
|
||||
|
||||
The current target is the Raspberry Pi 1 / 2 using the
|
||||
option ARCH=arm:armv6 and is supposed to run best on
|
||||
i386 for a matching 32 bit size.
|
||||
|
||||
About other scripts and tweaks
|
||||
==============================
|
||||
|
||||
|
|
|
@ -43,14 +43,15 @@ usage()
|
|||
while getopts a:C:c:d:f:K:k:L:l:m:n:o:P:p:R:S:s:T:t:U:u:v: OPT; do
|
||||
case ${OPT} in
|
||||
a)
|
||||
case "${OPTARG}" in
|
||||
amd64|i386)
|
||||
case ${OPTARG} in
|
||||
amd64|i386|arm:armv6)
|
||||
export PRODUCT_TARGET=${OPTARG%%:*}
|
||||
export PRODUCT_ARCH=${OPTARG##*:}
|
||||
export PRODUCT_HOST=$(uname -m)
|
||||
SCRUB_ARGS=${SCRUB_ARGS};shift;shift
|
||||
;;
|
||||
*)
|
||||
echo "ARCH wants amd64 or i386" >&2
|
||||
echo "ARCH wants amd64, arm:armv6 or i386" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -303,9 +304,18 @@ setup_chroot()
|
|||
{
|
||||
echo ">>> Setting up chroot in ${1}"
|
||||
|
||||
if [ ${PRODUCT_HOST} != ${PRODUCT_ARCH} ]; then
|
||||
# additional emulation layer so that chroot
|
||||
# looks like a native environment later on
|
||||
mkdir -p ${1}/usr/local/bin
|
||||
cp /usr/local/bin/qemu-${PRODUCT_TARGET}-static \
|
||||
${1}/usr/local/bin
|
||||
/usr/local/etc/rc.d/qemu_user_static onerestart
|
||||
fi
|
||||
|
||||
cp /etc/resolv.conf ${1}/etc
|
||||
mount -t devfs devfs ${1}/dev
|
||||
chroot ${1} /etc/rc.d/ldconfig start
|
||||
chroot ${1} /bin/sh /etc/rc.d/ldconfig start
|
||||
}
|
||||
|
||||
setup_marker()
|
||||
|
|
|
@ -57,8 +57,13 @@ fi
|
|||
trap : 2
|
||||
|
||||
if ! chroot ${STAGEDIR} /bin/sh -es << EOF; then SELF=; fi
|
||||
# overwrites the ports tree variable, behaviour is unwanted...
|
||||
# overwrites the ports tree variable, behaviour is unwanted:
|
||||
unset STAGEDIR
|
||||
# clobbers build for pkg(8) at least, since ARCH= is in there:
|
||||
unset MAKEFLAGS
|
||||
|
||||
export TARGET_ARCH=${PRODUCT_ARCH}
|
||||
export TARGET=${PRODUCT_TARGET}
|
||||
|
||||
if pkg -N; then
|
||||
# no need to rebuild
|
||||
|
@ -99,7 +104,8 @@ trap - 2
|
|||
|
||||
echo ">>> Creating binary packages..."
|
||||
|
||||
chroot ${STAGEDIR} /bin/sh -es << EOF && bundle_packages ${STAGEDIR} ${SELF} plugins core
|
||||
chroot ${STAGEDIR} /bin/sh -es << EOF && \
|
||||
bundle_packages ${STAGEDIR} ${SELF} plugins core
|
||||
pkg autoremove -y
|
||||
pkg create -nao ${PACKAGESDIR}/All -f txz
|
||||
EOF
|
||||
|
|
Loading…
Reference in New Issue