add a install script

This commit is contained in:
Baozhu Zuo 2017-05-22 18:20:29 +08:00
parent f6e665e6fe
commit b242c36f45
2 changed files with 72 additions and 0 deletions

5
dkms.conf Normal file
View file

@ -0,0 +1,5 @@
PACKAGE_NAME="seeed-voicecard"
PACKAGE_VERSION="0.1"
BUILT_MODULE_NAME[0]="wm8960"
DEST_MODULE_LOCATION[0]="/kernel/sound/soc/codecs"
AUTOINSTALL="yes"

67
install.sh Executable file
View file

@ -0,0 +1,67 @@
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
ver="0.1"
# we create a dir with this version to ensure that 'dkms remove' won't delete
# the sources during kernel updates
marker="0.0.0"
apt update
apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel
apt-get -y install dkms
# locate currently installed kernels (may be different to running kernel if
# it's just been updated)
kernels=$(ls /lib/modules | sed "s/^/-k /")
function install_module {
src=$1
mod=$2
if [[ -d /var/lib/dkms/$mod/$ver/$marker ]]; then
rmdir /var/lib/dkms/$mod/$ver/$marker
fi
if [[ -e /usr/src/$mod-$ver || -e /var/lib/dkms/$mod/$ver ]]; then
dkms remove -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/
dkms add -m $mod -v $ver
dkms build $kernels -m $mod -v $ver && dkms install $kernels -m $mod -v $ver
mkdir -p /var/lib/dkms/$mod/$ver/$marker
}
install_module "./" "seeed-voicecard"
(
cp seeed-voicecard.dtbo /boot/overlays
cp asound.state /var/lib/alsa/asound.state
)
echo 'wm8960' | sudo tee --append /etc/modules > /dev/null
sed -i \
-e "s/^dtparam=audio=on/#\0/" \
-e "s/^#\(dtparam=i2s=on\)/\1/" \
/boot/config.txt
grep -q "dtoverlay=i2s-mmap" /boot/config.txt || \
echo "dtoverlay=i2s-mmap" >> /boot/config.txt
grep -q "dtoverlay=seeed-voicecard" /boot/config.txt || \
echo "dtoverlay=seeed-voicecard" >> /boot/config.txt
grep -q "dtparam=i2s=on" /boot/config.txt || \
echo "dtparam=i2s=on" >> /boot/config.txt
echo "------------------------------------------------------"
echo "Please reboot your raspberry pi to apply all settings"
echo "Enjoy!"
echo "------------------------------------------------------"