Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions build_raspOVOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,11 @@ fi
echo "Tuning /etc/fstab..."
bash /mounted-github-repo/scripts/setup_fstab.sh

#echo "Updating ovos-i2csound and raspovos-audio-setup"
#bash /mounted-github-repo/scripts/update.sh
echo "Installing respeaker drivers"
bash /mounted-github-repo/scripts/setup_respeaker.sh

# echo "Updating ovos-i2csound and raspovos-audio-setup"
# bash /mounted-github-repo/scripts/update.sh

# Copy raspOVOS overlay to the system.
echo "Copying raspOVOS overlay..."
Expand Down
Empty file modified local_build.sh
100644 → 100755
Empty file.
19 changes: 16 additions & 3 deletions scripts/setup_respeaker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ marker="0.0.0"

git clone https://github.com/HinTak/seeed-voicecard
cd seeed-voicecard
git checkout v6.6
kernel=$(uname -r)
k_ver=$(echo $kernel | cut -d '.' -f2)
checkout_version="v6.$k_ver"
Comment on lines +17 to +19
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve kernel version extraction logic
Current code only captures the minor version and hardcodes major as “6”, which will break on non-6.x kernels and may mis-handle tags. Also, variable expansions should be quoted to prevent word-splitting.

Proposed diff:

- kernel=$(uname -r)
- k_ver=$(echo $kernel | cut -d '.' -f2)
- checkout_version="v6.$k_ver"
+ # Extract major and minor from the raw kernel version (ignore suffix)
+ kernel_base=$(uname -r | cut -d '-' -f1)
+ major=$(echo "$kernel_base" | cut -d '.' -f1)
+ minor=$(echo "$kernel_base" | cut -d '.' -f2)
+ checkout_version="v${major}.${minor}"

This makes the tag dynamic and robust across kernel series.

🤖 Prompt for AI Agents
In scripts/setup_respeaker.sh around lines 17 to 19, the kernel version
extraction hardcodes the major version as "6" and only extracts the minor
version, which breaks compatibility with other kernel series. Update the code to
dynamically extract both the major and minor kernel version parts from the uname
output, and quote all variable expansions to prevent word splitting. Construct
the checkout_version variable using these extracted parts to make the tag
dynamic and robust across different kernel versions.


if git checkout $checkout_version; then
echo "using version $checkout_version of respeaker drivers"
else
echo "Could not checkout version $checkout_version"
echo "Trying default branch"
fi

function install_respeaker {
local _i
Expand All @@ -30,7 +39,7 @@ function install_respeaker {
dkms remove --force -m $mod -v $ver --all
rm -rf /usr/src/$mod-$ver
fi

mkdir -p /usr/src/$mod-$ver
cp -a $src/* /usr/src/$mod-$ver/

Expand All @@ -55,7 +64,11 @@ apt-get -y install dkms git i2c-tools libasound2-plugins

kernels=($(ls /boot/vmlinuz-* | sort -V | sed 's|/boot/vmlinuz-||'))

install_respeaker "./" "seeed-voicecard"
if install_respeaker "./" "seeed-voicecard"; then
echo "seeed-voicecard drivers are installed"
else
echo "could not build respeaker drivers"
fi

cd ..

Expand Down