forked from garmin/pyrex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyrex-init-build-env
83 lines (69 loc) · 1.94 KB
/
pyrex-init-build-env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#! /bin/bash
#
# Copyright 2019 Garmin Ltd. or its subsidiaries
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if [ -n "${BASH_SOURCE[*]}" ]; then
THIS_SCRIPT=$BASH_SOURCE
elif [ -n "$ZSH_NAME" ]; then
THIS_SCRIPT=$0
else
THIS_SCRIPT="$(pwd)/pyrex-init-build-env"
fi
if [ -z "$ZSH_NAME" ] && [ "$0" = "$THIS_SCRIPT" ]; then
echo "Error: This script needs to be sourced. Please run as '. $THIS_SCRIPT'"
exit 1
fi
export PYREX_CONFIG_BIND
if [ -z "$PYREX_CONFIG_BIND" ]; then
PYREX_CONFIG_BIND=$(readlink -f "$(dirname "$THIS_SCRIPT")")
fi
if [ -z "$PYREX_ROOT" ]; then
PYREX_ROOT=$(dirname "$(readlink -f "$THIS_SCRIPT")")
fi
if [ -z "$PYREX_OEINIT" ]; then
if [ -z "$OEROOT" ]; then
PYREX_OEINIT="$(pwd)/oe-init-build-env"
else
PYREX_OEINIT="$OEROOT/oe-init-build-env"
fi
fi
unset THIS_SCRIPT
if [ -z "$PYREX_TEMP_ENV_FILE" ]; then
PYREX_TEMP_ENV_FILE=$(mktemp -t pyrex-env.XXXXXX)
fi
pyrex_cleanup() {
rm -f "$PYREX_TEMP_ENV_FILE"
unset PYREX_OEINIT PYREX_ROOT PYREX_TEMP_ENV_FILE pyrex_cleanup
}
export PYREXCONFFILE
if [ -n "$PYREXCONFFILE" ] && [ "${PYREXCONFFILE#/}" = "$PYREXCONFFILE" ]; then
PYREXCONFFILE="$(pwd)/$PYREXCONFFILE"
fi
"$PYREX_ROOT/pyrex.py" capture \
-a PYREX_OEINIT "$PYREX_OEINIT" \
-e PYREXCONFFILE \
-e TEMPLATECONF \
-- 9 "$@" \
9> "$PYREX_TEMP_ENV_FILE"
if [ $? -ne 0 ]; then
pyrex_cleanup
return 1
fi
. "$PYREX_TEMP_ENV_FILE"
if [ $? -ne 0 ]; then
pyrex_cleanup
return 1
fi
pyrex_cleanup
# vim: noexpandtab