@@ -66,7 +66,8 @@ error_msg() {
66
66
67
67
# Install the required dependencies
68
68
check_dependencies () {
69
- echo -e " ${STEPS} Start checking dependencies..."
69
+ trap ' error_msg "Failed to check dependencies."' ERR
70
+ echo -e " ${STEPS} Checking dependencies..."
70
71
# Check the compression algorithm
71
72
if [[ -f " ${compress_initrd_file} " ]]; then
72
73
compress_settings=" $( cat ${compress_initrd_file} | grep -E ^COMPRESS= | awk -F' =' ' {print $2}' ) "
@@ -81,19 +82,22 @@ check_dependencies() {
81
82
zstd) necessary_packages=" zstd" ;;
82
83
gzip | * ) necessary_packages=" gzip" ;;
83
84
esac
84
-
85
- # Check the necessary packages
85
+
86
+ # Install the necessary packages
87
+ trap ' error_msg "Failed to install required dependencies."' ERR
86
88
[[ -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..."
88
90
apt-get update -y
89
91
apt-get install -y ${necessary_packages}
90
92
}
93
+ trap - ERR
91
94
}
92
95
93
96
# Generate uInitrd
94
97
generate_uinitrd () {
98
+ trap ' error_msg "Failed to generate the uInitrd file."' ERR
95
99
cd /boot
96
- echo -e " ${STEPS} Generate uInitrd file..."
100
+ echo -e " ${STEPS} Generating uInitrd file..."
97
101
98
102
# Enable update_initramfs
99
103
[[ -f " ${initramfs_conf} " ]] && sed -i " s|^update_initramfs=.*|update_initramfs=yes|g" ${initramfs_conf}
@@ -102,25 +106,27 @@ generate_uinitrd() {
102
106
update-initramfs -c -k ${chroot_kernel_version}
103
107
104
108
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."
106
110
[[ ! -L " uInitrd" ]] && mv -vf uInitrd uInitrd-${chroot_kernel_version}
107
111
sync && sleep 3
108
112
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."
110
114
fi
111
115
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
113
118
}
114
119
115
120
# Make kernel scripts
116
121
make_kernel_scripts () {
122
+ trap ' error_msg "Failed to generate the kernel scripts."' ERR
117
123
cd ${armbian_kernel_path}
118
- echo -e " ${STEPS} Make kernel scripts..."
124
+ echo -e " ${STEPS} Making kernel scripts..."
119
125
120
126
# Download Arm GNU Toolchain
121
127
[[ -d " ${toolchain_path} " ]] || mkdir -p ${toolchain_path}
122
128
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} ]..."
124
130
curl -fsSL " ${dev_repo} /${gun_file} " -o " ${toolchain_path} /${gun_file} "
125
131
[[ " ${?} " -eq " 0" ]] || error_msg " GNU toolchain file download failed."
126
132
tar -xJf ${toolchain_path} /${gun_file} -C ${toolchain_path}
@@ -151,12 +157,14 @@ make_kernel_scripts() {
151
157
# Set max process
152
158
PROCESS=" $( cat /proc/cpuinfo | grep " processor" | wc -l) "
153
159
[[ -z " ${PROCESS} " || " ${PROCESS} " -lt " 1" ]] && PROCESS=" 1" && echo " PROCESS: 1"
154
-
160
+ echo -e " ${INFO} Compiling kernel scripts... "
155
161
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
157
164
}
158
165
159
166
packit_header () {
167
+ trap ' error_msg "Failed to generate the kernel header files."' ERR
160
168
cd ${armbian_kernel_path}
161
169
echo -e " ${STEPS} Packit header files..."
162
170
@@ -194,7 +202,8 @@ packit_header() {
194
202
# Compress the header files
195
203
cd ${header_output_path}
196
204
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
198
207
}
199
208
200
209
# Show welcome message
0 commit comments