-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-bmros.sh
executable file
·133 lines (105 loc) · 3.43 KB
/
build-bmros.sh
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
source lib/common.sh
if [ "$(id -u)" -eq 0 ]; then
echo "This script must not be run as root or with sudo." >&2
exit 1
fi
IMAGE_TO_BUILD=${BMROS_IMAGE_BB_REF_PROD}
BASE_DIR=${PWD}
update_last_build_recipe() {
echo -e "${1} " >> "${BASE_DIR}/.last_build_recipe"
}
usage() {
echo
echo "Usage: $0 [options]"
echo "Options:"
echo
echo -e " -c, --${POKY_CORE_IMG_MIN}"
echo -e " -b, --${BMROS_IMAGE_BB_REF_PROD}\t\t(Production - default)"
echo -e " -d, --${BMROS_IMAGE_BB_REF_DEBUG}\t\t(Debug)"
echo -e " -v, --${BMROS_IMAGE_BB_REF_VANILLA}\t(Non-Debug)"
echo
echo " -u, --update-poky-meta-bare-metal-router-layer-only"
echo " -r, --remove-update-poky-meta-bare-metal-router-layer"
echo
exit 1
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-b|--bare-metal-router)
IMAGE_TO_BUILD="${BMROS_IMAGE_BB_REF_PROD}"
shift
;;
-v|--bare-metal-router-vanilla)
IMAGE_TO_BUILD="${BMROS_IMAGE_BB_REF_VANILLA}"
shift
;;
-d|--bare-metal-router-dev)
IMAGE_TO_BUILD="${BMROS_IMAGE_BB_REF_DEBUG}"
shift
;;
-c|--core-image-minimal)
IMAGE_TO_BUILD="${POKY_CORE_IMG_MIN}"
shift
;;
-u|--update-bare-metal-layer-only)
./update-layers.sh
shift
;;
-r|--remove-update-poky-meta-bare-metal-router-layer)
echo
echo "Remove directories:"
echo " * poky/meta-bare-metal-router"
echo " * poky/build-bmros/tmp"
echo
echo "Removing there directory will remove any changed outside of the standard install"
read -p "Are you sure (y/n): " confirm
if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then
rm -rf poky/meta-bare-metal-router
rm -rf poky/build-bmros/tmp
else
echo
echo "Removal of teh following directories canceled:"
echo " * poky/meta-bare-metal-router"
echo " * poky/build-bmros/tmp"
echo
exit 1
fi
./update-layers.sh
shift
;;
-h|--help)
usage
exit
;;
*)
echo "Unknown option: $1"
usage
exit
;;
esac
done
start_time=$(get_epoch_timestamp)
display_banner "Building ${IMAGE_TO_BUILD}"
BASE_DIR=${PWD}
POKY_DIR="${BASE_DIR}/${POKY_DIR_NAME}"
check_directory "$POKY_DIR" || {
echo "ERROR: Directory $POKY_DIR not found"
echo "ERROR: Run: . ${BASE_DIR}/install-yocto-poky.sh"
echo
exit 1
}
cd "$POKY_DIR"
source oe-init-build-env ${BMROS_BUILD_DIR_NAME}
if [[ -n "$IMAGE_TO_BUILD" ]]; then
display_banner "Start Build: $IMAGE_TO_BUILD"
bitbake -k $IMAGE_TO_BUILD || handle_error "Build ${IMAGE_TO_BUILD} Failed"
update_last_build_recipe "${IMAGE_TO_BUILD}"
fi
if check_directory "${BASE_DIR}/downloads"; then
echo "Adding ${BASE_DIR}/downloads to reduce time for future build"
echo "!!!!DO NOT REMOVE!!!! -> ${BASE_DIR}/downloads"
fi
elapsed_time=$(( $(get_epoch_timestamp) - start_time ))
display_banner "BUILD (${IMAGE_TO_BUILD}) COMPLETE - Build Elapse Time: $elapsed_time seconds"