-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-bmr.sh
executable file
·109 lines (93 loc) · 2.85 KB
/
build-bmr.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
#!/usr/bin/bash
# Source the common script
source lib/common.sh
IMAGE_TO_BUILD=${BMR_IMAGE_BB_REF}
BASE_DIR=${PWD}
# Function to display usage
usage() {
echo "Usage: $0 [options]"
echo "Options:"
echo
echo " --clean"
echo " --clean-all"
echo " --clean-all-world"
echo
echo " [-b], [--bare-metal-router] (default)"
echo " -c, --core-image-minimal"
exit 1
}
update_last_build_recipe() {
echo -e $1 >> "${BASE_DIR}/.last_build_recipe"
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-b|--bare-metal-router)
IMAGE_TO_BUILD="${BMR_IMAGE_BB_REF}"
shift
;;
-c|--core-image-minimal)
IMAGE_TO_BUILD="${POKY_CORE_IMG_MIN}"
shift
;;
--clean)
CLEAN=true
# Add code for handling --clean option here
## bitbake -c cleanall reciep
shift
;;
--clean-all)
CLEANALL=true
# Add code for handling --clean-all option here
# bitbake -c cleanall core-image-minimal
shift
;;
--clean-all-world)
CLEANALL_WORLD=true
# bitbake world -c cleanall --continue
# The --continue will ignore any dependency errors while cleaning.
# Continue as much as possible after an error.
shift
;;
-h|--help)
display_usage
;;
*)
echo "Unknown option: $1"
display_usage
;;
esac
done
# Display banner
display_banner "Building Bare Metal Router"
BASE_DIR=${PWD}
POKY_DIR="${BASE_DIR}/${POKY_DIR_NAME}"
# Check if POKY_DIR exists, exit with error if not found
check_directory "$POKY_DIR" || {
echo "ERROR: Directory $POKY_DIR not found"
echo "ERROR: Run: . ${BASE_DIR}/install-poky.sh"
echo
exit 1
}
# Change to POKY_DIR and source environment
cd "$POKY_DIR" || {display_banner "BUILD FAILED"; exit}
source oe-init-build-env ${BMR_BUILD_DIR_NAME}
if [ "${CLEANALL_WORLD}" = true ]; then
bitbake world -c cleanall --continue || {display_banner "BUILD FAILED (clean all world)"; exit 1}
display_banner "CLEAN COMPLETE"
exit
fi
# Build selected image if specified
if [[ -n "$IMAGE_TO_BUILD" ]]; then
display_banner "Start Bare Metal Router Build: $IMAGE_TO_BUILD"
bitbake -k $IMAGE_TO_BUILD
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"
# mkdir -p "${BASE_DIR}/downloads"
# cp -r "${POKY_BUILD_PATH}/downloads/*" "${BASE_DIR}/downloads" || handle_warning "Unable to copy download files from ${POKY_BUILD_PATH}/downloads"
fi
# Display completion message
display_banner "BUILD COMPLETE"