summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-04-22 19:30:13 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-04-22 19:30:13 (EDT)
commit5176e0a9942b4f1a7ebb32d516a284dedcf0d0b5 (patch)
treef8ea46c819d7cd8182aa8715cd14a20494661834
parent1bda44ec2da198adb5ae5b6342a6a0fe158d9437 (diff)
Detect build platform like build architecture.
-rw-r--r--src/opkbuild.sh35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/opkbuild.sh b/src/opkbuild.sh
index a184501..a525e4b 100644
--- a/src/opkbuild.sh
+++ b/src/opkbuild.sh
@@ -121,7 +121,7 @@ if [ "$(cat format)" != '1.0' ]; then
exit 1
fi
-# Attempt to detect the build architecture tuple.
+# Attempt to detect the build architecture.
build_arch=$(opkg print-architecture | sed -n \
's/^arch \([^ -][^ -]*-[^ -][^ -]*-[^ -][^ -]*\) [0-9][0-9]*$/\1/p')
if [ -z "${build_arch}" ]; then
@@ -137,28 +137,24 @@ if [ -z "${host_arch}" ]; then
host_arch="${build_arch}"
fi
-# Attempt to detect the host platform.
+# Attempt to detect the build platform.
+build_platform=$(opkg print-architecture | sed -n \
+ 's/^arch \([^ -][^ -]*\) [0-9][0-9]*$/\1/p' | \
+ grep -v 'all')
+if [ -z "${build_platform}" ]; then
+ printf 'opkbuild: Error: No build platforms found\n' >&2
+ exit 1
+elif [ $(echo "${build_platform}" | wc -l) -gt 1 ]; then
+ printf 'opkbuild: Error: Multiple build platforms found\n' >&2
+ exit 1
+fi
+
# If there no config files to copy, build platform-independent packages.
if [ ! -f config ]; then
host_platform=''
-# If a host platform was not specified ...
+# If a host platform was not specified, natively configure.
elif [ -z "${host_platform}" ]; then
- host_platform=$(opkg print-architecture | \
- sed -n 's/^arch \([^ -][^ -]*\) [0-9][0-9]*$/\1/p' | \
- grep -v 'all')
- # ... and there are config files and zero installable platforms, fail.
- if [ -z "${host_platform}" ]; then
- printf 'opkbuild: Error: %s\n' \
- 'Building platform-dependent package and no platforms detected' >&2
- exit 1
- # ... and there are config files and multiple installable platforms, request
- # explicit selection.
- elif [ $(echo "${host_platform}" | wc -l) -gt 1 ]; then
- printf 'opkbuild: Error: %s\n' \
- 'Multiple platforms found while detecting host' >&2
- exit 1
- fi
- # ... and there are config files and one installable platform, build for it.
+ host_platform="${build_platform}"
fi
# Resolve status override file path.
@@ -185,6 +181,7 @@ IFS=- read OH_BUILD_ARCH_CPU OH_BUILD_ARCH_KERNEL OH_BUILD_ARCH_LIBS <<EOF
${OH_BUILD_ARCH_DIST}
EOF
export OH_BUILD_ARCH_CPU OH_BUILD_ARCH_KERNEL OH_BUILD_ARCH_LIBS
+export OH_BUILD_PLATFORM="${build_platform}"
# Set environment variables for the host architecture and platform.
export OH_HOST_ARCH_DIST="${host_arch}"