Skip to content

Commit

Permalink
Adjust the header installation path
Browse files Browse the repository at this point in the history
  • Loading branch information
ophub committed Jun 16, 2022
1 parent 56ccd83 commit 4dab653
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
20 changes: 11 additions & 9 deletions build-armbian/common-files/rootfs/usr/sbin/armbian-update
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ check_kernel() {
[[ "${sha256sums_check}" -eq "1" ]] && echo -e "${INFO} Enable sha256sum checking..."

# Loop check file
kernel_list=("boot" "dtb-amlogic" "modules" "header")
kernel_list=("boot" "dtb-amlogic" "header" "modules")
i="1"
for kernel_file in ${kernel_list[*]}; do
# Set check filename
Expand Down Expand Up @@ -249,17 +249,19 @@ update_kernel() {
[[ "$(ls /boot/dtb/amlogic -l 2>/dev/null | grep "^-" | wc -l)" -ge "10" ]] || error_msg "/boot/dtb/amlogic file is missing."
echo -e "${INFO} (2/4) Unpacking [ dtb-amlogic-${kernel_name}.tar.gz ] done."

# 03. For /usr/lib/modules/*
# 03. For /usr/src/linux-5.x.y
header_path="$(echo ${inputs_kernel} | awk -F "." '{print "linux-"$1"."$2".y"}')"
rm -rf "/usr/src/linux-*" 2>/dev/null && mkdir -p "/usr/src/${header_path}" && sync
tar -xzf header-${kernel_name}.tar.gz -C /usr/src/${header_path} && sync
[[ -d "/usr/include" ]] || error_msg "/usr/include folder is missing."
echo -e "${INFO} (3/4) Unpacking [ header-${kernel_name}.tar.gz ] done."

# 04. For /usr/lib/modules/*
rm -rf /usr/lib/modules/* 2>/dev/null && sync
tar -xzf modules-${kernel_name}.tar.gz -C /usr/lib/modules && sync
(cd /usr/lib/modules/${kernel_name} && echo "build source" | xargs rm -f)
(cd /usr/lib/modules/${kernel_name}/ && rm -f build source && ln -sf /usr/src/${header_path} build && ln -sf /usr/src/${header_path} source)
[[ -d "/usr/lib/modules/${kernel_name}" ]] || error_msg "/usr/lib/modules/${kernel_name} kernel folder is missing."
echo -e "${INFO} (3/4) Unpacking [ modules-${kernel_name}.tar.gz ] done."

# 04. For /usr/include/*
tar -xzf header-${kernel_name}.tar.gz -C /usr && sync
[[ -d "/usr/include" ]] || error_msg "/usr/include folder is missing."
echo -e "${INFO} (4/4) Unpacking [ header-${kernel_name}.tar.gz ] done."
echo -e "${INFO} (4/4) Unpacking [ modules-${kernel_name}.tar.gz ] done."

# Delete kernel tmpfiles
rm -f *${kernel_name}*.tar.gz sha256sums 2>/dev/null
Expand Down
14 changes: 8 additions & 6 deletions rebuild
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ refactor_files() {
# Replace the kernel
build_boot="$(ls ${kernel_path}/${kernel}/boot-${kernel}-*.tar.gz 2>/dev/null | head -n 1)"
build_dtb="$(ls ${kernel_path}/${kernel}/dtb-amlogic-${kernel}-*.tar.gz 2>/dev/null | head -n 1)"
build_modules="$(ls ${kernel_path}/${kernel}/modules-${kernel}-*.tar.gz 2>/dev/null | head -n 1)"
build_header="$(ls ${kernel_path}/${kernel}/header-${kernel}-*.tar.gz 2>/dev/null | head -n 1)"
build_modules="$(ls ${kernel_path}/${kernel}/modules-${kernel}-*.tar.gz 2>/dev/null | head -n 1)"
[[ -n "${build_boot}" && -n "${build_dtb}" && -n "${build_modules}" && -n "${build_header}" ]] || error_msg "The 4 kernel missing."

# 01. For /boot five files
Expand All @@ -452,14 +452,16 @@ refactor_files() {
# 02. For /boot/dtb/amlogic/*
tar -xzf ${build_dtb} -C ${tag_bootfs}/dtb/amlogic && sync

# 03. For /usr/lib/modules/*
# 03. For /usr/src/linux-5.x.y
header_path="$(echo ${kernel} | awk -F "." '{print "linux-"$1"."$2".y"}')"
rm -rf "/usr/src/linux-*" 2>/dev/null && mkdir -p "/usr/src/${header_path}" && sync
tar -xzf ${build_header} -C ${tag_rootfs}/usr/src/${header_path} && sync

# 04. For /usr/lib/modules/*
tar -xzf ${build_modules} -C ${tag_rootfs}/usr/lib/modules && sync
(cd ${tag_rootfs}/usr/lib/modules/${kernel}-*/ && rm -f build source 2>/dev/null && sync)
(cd ${tag_rootfs}/usr/lib/modules/${kernel}-*/ && rm -f build source && ln -sf /usr/src/${header_path} build && ln -sf /usr/src/${header_path} source)
[[ "$(ls ${tag_rootfs}/usr/lib/modules/${kernel}-* -l 2>/dev/null | grep "^d" | wc -l)" -eq "1" ]] || error_msg "Missing kernel."

# 04. For /usr/include/*
tar -xzf ${build_header} -C ${tag_rootfs}/usr && sync

# Set the type of file system
if [[ "${ROOTFS_TYPE}" == "btrfs" ]]; then
uenv_mount_string="UUID=${ROOTFS_UUID} rootflags=compress=zstd:6 rootfstype=btrfs"
Expand Down

0 comments on commit 4dab653

Please sign in to comment.