Skip to content

Commit

Permalink
fix: dkms.post_install: optimize code logic
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeChenL committed Mar 19, 2024
1 parent 2c93316 commit 7f858cc
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions debian/dkms.post_install
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@ set -e
base_dir="${PWD%/*}/$kernelver/$arch/module/arch/arm64/boot/dts"
install_dir="/usr/lib/linux-image-$kernelver"

if [[ ! -e "$install_dir/amlogic/overlays" ]] || [[ "$(readlink "$install_dir/amlogic/overlays")" == "$base_dir/amlogic/overlays" ]] && [[ -d "$install_dir/amlogic" ]]
then
echo "Link $base_dir/amlogic/overlays to $install_dir/amlogic/overlays"
rm -f $install_dir/amlogic/overlays
ln -s "$base_dir/amlogic/overlays" "$install_dir/amlogic/overlays"
fi
for vendor in "rockchip" "amlogic"
do
if [[ ! -L "$install_dir/$vendor" ]] && [[ ! -d "$install_dir/$vendor" ]]
then
# Vendor not supported by the kernel
continue
fi

if [[ ! -e "$install_dir/rockchip/overlays" ]] || [[ "$(readlink "$install_dir/rockchip/overlays")" == "$base_dir/rockchip/overlays" ]] && [[ -d "$install_dir/rockchip" ]]
then
echo "Link $base_dir/rockchip/overlays to $install_dir/rockchip/overlays"
rm -f $install_dir/rockchip/overlays
ln -s "$base_dir/rockchip/overlays" "$install_dir/rockchip/overlays"
fi
if [[ -e "$install_dir/$vendor/overlays" ]] && [[ ! -L "$install_dir/$vendor/overlays" ]]
then
# The kernel already comes with overlays.
continue
fi

if [[ ! "$(readlink "$install_dir/$vendor/overlays")" == "$base_dir/$vendor/overlays" ]]
then
echo "Link $base_dir/$vendor/overlays to $install_dir/$vendor/overlays"
rm -f $install_dir/$vendor/overlays
ln -s "$base_dir/$vendor/overlays" "$install_dir/$vendor/overlays"
fi
done

0 comments on commit 7f858cc

Please sign in to comment.