Skip to content

Commit 820d131

Browse files
authored
Merge pull request #2964 from hboyd2003/stop-build-on-error
Add error detection to ubuntu_chroot_armbian
2 parents 958dc76 + acc87b9 commit 820d131

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

compile-kernel/tools/script/ubuntu_chroot_armbian.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ error_msg() {
6666

6767
# Install the required dependencies
6868
check_dependencies() {
69-
echo -e "${STEPS} Start checking dependencies..."
69+
trap 'error_msg "Failed to check dependencies."' ERR
70+
echo -e "${STEPS} Checking dependencies..."
7071
# Check the compression algorithm
7172
if [[ -f "${compress_initrd_file}" ]]; then
7273
compress_settings="$(cat ${compress_initrd_file} | grep -E ^COMPRESS= | awk -F'=' '{print $2}')"
@@ -81,19 +82,22 @@ check_dependencies() {
8182
zstd) necessary_packages="zstd" ;;
8283
gzip | *) necessary_packages="gzip" ;;
8384
esac
84-
85-
# Check the necessary packages
85+
86+
# Install the necessary packages
87+
trap 'error_msg "Failed to install required dependencies."' ERR
8688
[[ -n "$(dpkg -l | awk '{print $2}' | grep -w "^${necessary_packages}$")" ]] || {
87-
echo -e "${INFO} Install the required dependencies..."
89+
echo -e "${INFO} Installing required dependencies..."
8890
apt-get update -y
8991
apt-get install -y ${necessary_packages}
9092
}
93+
trap - ERR
9194
}
9295

9396
# Generate uInitrd
9497
generate_uinitrd() {
98+
trap 'error_msg "Failed to generate the uInitrd file."' ERR
9599
cd /boot
96-
echo -e "${STEPS} Generate uInitrd file..."
100+
echo -e "${STEPS} Generating uInitrd file..."
97101

98102
# Enable update_initramfs
99103
[[ -f "${initramfs_conf}" ]] && sed -i "s|^update_initramfs=.*|update_initramfs=yes|g" ${initramfs_conf}
@@ -102,25 +106,27 @@ generate_uinitrd() {
102106
update-initramfs -c -k ${chroot_kernel_version}
103107

104108
if [[ -f "uInitrd" ]]; then
105-
echo -e "${SUCCESS} The initrd.img and uInitrd file is Successfully generated."
109+
echo -e "${SUCCESS} The initrd.img and uInitrd file were successfully generated."
106110
[[ ! -L "uInitrd" ]] && mv -vf uInitrd uInitrd-${chroot_kernel_version}
107111
sync && sleep 3
108112
else
109-
echo -e "${WARNING} The initrd.img and uInitrd file not updated."
113+
echo -e "${WARNING} The initrd.img and uInitrd files were not updated."
110114
fi
111115

112-
echo -e "${INFO} File situation in the /boot directory after update: \n$(ls -hl *${chroot_kernel_version})"
116+
echo -e "${INFO} /boot directory after update: \n$(ls -hl *${chroot_kernel_version})"
117+
trap - ERR
113118
}
114119

115120
# Make kernel scripts
116121
make_kernel_scripts() {
122+
trap 'error_msg "Failed to generate the kernel scripts."' ERR
117123
cd ${armbian_kernel_path}
118-
echo -e "${STEPS} Make kernel scripts..."
124+
echo -e "${STEPS} Making kernel scripts..."
119125

120126
# Download Arm GNU Toolchain
121127
[[ -d "${toolchain_path}" ]] || mkdir -p ${toolchain_path}
122128
if [[ ! -d "${toolchain_path}/${gun_file//.tar.xz/}/bin" ]]; then
123-
echo -e "${INFO} Start downloading the ARM GNU toolchain [ ${gun_file} ]..."
129+
echo -e "${INFO} Downloading the ARM GNU toolchain [ ${gun_file} ]..."
124130
curl -fsSL "${dev_repo}/${gun_file}" -o "${toolchain_path}/${gun_file}"
125131
[[ "${?}" -eq "0" ]] || error_msg "GNU toolchain file download failed."
126132
tar -xJf ${toolchain_path}/${gun_file} -C ${toolchain_path}
@@ -151,12 +157,14 @@ make_kernel_scripts() {
151157
# Set max process
152158
PROCESS="$(cat /proc/cpuinfo | grep "processor" | wc -l)"
153159
[[ -z "${PROCESS}" || "${PROCESS}" -lt "1" ]] && PROCESS="1" && echo "PROCESS: 1"
154-
160+
echo -e "${INFO} Compiling kernel scripts..."
155161
make ${MAKE_SET_STRING} modules_prepare -j${PROCESS}
156-
[[ "${?}" -eq "0" ]] && echo -e "${SUCCESS} The kernel scripts are successfully generated."
162+
echo -e "${SUCCESS} The kernel scripts were successfully generated."
163+
trap - ERR
157164
}
158165

159166
packit_header() {
167+
trap 'error_msg "Failed to generate the kernel header files."' ERR
160168
cd ${armbian_kernel_path}
161169
echo -e "${STEPS} Packit header files..."
162170

@@ -194,7 +202,8 @@ packit_header() {
194202
# Compress the header files
195203
cd ${header_output_path}
196204
tar -czf header-${chroot_kernel_version}.tar.gz *
197-
[[ "${?}" -eq "0" ]] && echo -e "${SUCCESS} The kernel header files are successfully generated."
205+
echo -e "${SUCCESS} The kernel header files are successfully generated."
206+
trap - ERR
198207
}
199208

200209
# Show welcome message

0 commit comments

Comments
 (0)