wiringPi: Add udev rules to correct /dev/gpiomem permission
Signed-off-by: Yang Deokgyu <secugyu@gmail.com>
This commit is contained in:
38
build
38
build
@@ -43,7 +43,36 @@ check_make_ok() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configure_gpiomem() {
|
||||||
|
GPIOMEM="/dev/gpiomem"
|
||||||
|
|
||||||
|
if [ -z $1 ] && [ "$(stat -c "%a %G" "$GPIOMEM")" != "660"*"odroid" ]; then
|
||||||
|
case "$(echo $hardware | tr [:upper:] [:lower:])" in
|
||||||
|
*xu4)
|
||||||
|
$sudo cp -f udev/rules.d/99-odroid-wiringpi-exynos.rules /etc/udev/rules.d/
|
||||||
|
;;
|
||||||
|
*c1|*c2|*n2)
|
||||||
|
$sudo cp -f udev/rules.d/99-odroid-wiringpi-aml.rules /etc/udev/rules.d/
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "This system seems not ODROID"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "Reload udev..."
|
||||||
|
[ -x "$(command -v udevadm)" ] \
|
||||||
|
&& $sudo udevadm trigger \
|
||||||
|
|| echo "udevadm not found. Please reboot to take effect"
|
||||||
|
elif [ "$1" = "uninstall" ]; then
|
||||||
|
$sudo rm -f /etc/udev/rules.d/99-odroid-wiringpi-*
|
||||||
|
else
|
||||||
|
echo "Not found $GPIOMEM"
|
||||||
|
echo "You will not be able to use WiringPi without root permission"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
sudo=${WIRINGPI_SUDO-sudo}
|
sudo=${WIRINGPI_SUDO-sudo}
|
||||||
|
hardware=$(fgrep Hardware /proc/cpuinfo | head -1 | awk '{ printf("%s %s %s\n", $3, $4, $5) }' | xargs)
|
||||||
|
|
||||||
if [ x$1 = "xclean" ]; then
|
if [ x$1 = "xclean" ]; then
|
||||||
cd wiringPi
|
cd wiringPi
|
||||||
@@ -74,6 +103,9 @@ if [ x$1 = "xuninstall" ]; then
|
|||||||
echo -n "DevLib: " ; $sudo make uninstall
|
echo -n "DevLib: " ; $sudo make uninstall
|
||||||
cd ../gpio
|
cd ../gpio
|
||||||
echo -n "gpio: " ; $sudo make uninstall
|
echo -n "gpio: " ; $sudo make uninstall
|
||||||
|
cd ..
|
||||||
|
echo -n "Deconfigure /dev/gpiomem" ; configure_gpiomem uninstall
|
||||||
|
echo
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -104,7 +136,6 @@ fi
|
|||||||
echo "====================="
|
echo "====================="
|
||||||
echo
|
echo
|
||||||
|
|
||||||
hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
|
|
||||||
|
|
||||||
# if [ x$hardware != "xBCM2708" ]; then
|
# if [ x$hardware != "xBCM2708" ]; then
|
||||||
# echo ""
|
# echo ""
|
||||||
@@ -160,6 +191,11 @@ fi
|
|||||||
$sudo make install
|
$sudo make install
|
||||||
check_make_ok
|
check_make_ok
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Configure /dev/gpiomem"
|
||||||
|
cd ..
|
||||||
|
configure_gpiomem
|
||||||
|
|
||||||
# echo
|
# echo
|
||||||
# echo "wiringPi Daemon"
|
# echo "wiringPi Daemon"
|
||||||
# cd ../wiringPiD
|
# cd ../wiringPiD
|
||||||
|
|||||||
1
debian/odroid-wiringpi.install
vendored
1
debian/odroid-wiringpi.install
vendored
@@ -2,3 +2,4 @@ debian/tmp/usr/bin
|
|||||||
debian/tmp/usr/man usr/share
|
debian/tmp/usr/man usr/share
|
||||||
README.TXT usr/share/doc/wiringpi
|
README.TXT usr/share/doc/wiringpi
|
||||||
People usr/share/doc/wiringpi
|
People usr/share/doc/wiringpi
|
||||||
|
udev/rules.d tmp/odroid-wiringpi
|
||||||
|
|||||||
47
debian/odroid-wiringpi.postinst
vendored
Normal file
47
debian/odroid-wiringpi.postinst
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
msg() {
|
||||||
|
echo "odroid-wiringpi: $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
configure)
|
||||||
|
if [ -c "/dev/gpiomem" ] && [ "$(stat -c "%a %G" "/dev/gpiomem")" != "660"*"odroid" ]; then
|
||||||
|
hardware=$(fgrep Hardware /proc/cpuinfo | head -1 | awk '{ printf("%s %s %s\n", $3, $4, $5) }' | xargs)
|
||||||
|
case "$(echo $hardware | tr [:upper:] [:lower:])" in
|
||||||
|
*xu4)
|
||||||
|
cp -f /tmp/odroid-wiringpi/rules.d/99-odroid-wiringpi-exynos.rules /etc/udev/rules.d
|
||||||
|
;;
|
||||||
|
*c1|*c2|*n2)
|
||||||
|
cp -f /tmp/odroid-wiringpi/rules.d/99-odroid-wiringpi-aml.rules /etc/udev/rules.d
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
msg "This system seems not ODROID"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
msg "Reload udev..."
|
||||||
|
[ -x "$(command -v udevadm)" ] \
|
||||||
|
&& udevadm trigger \
|
||||||
|
|| msg "udevadm not found. Please reboot to take effect"
|
||||||
|
else
|
||||||
|
msg "Not found $GPIOMEM"
|
||||||
|
msg "You will not be able to use WiringPi without root permission"
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg "Remove temporary files..."
|
||||||
|
rm -rf /tmp/odroid-wiringpi
|
||||||
|
;;
|
||||||
|
|
||||||
|
abort-upgrade|abort-remove|abort-deconfigure)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "postinst called with unknown argument \`$1'" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
19
debian/odroid-wiringpi.postrm
vendored
Normal file
19
debian/odroid-wiringpi.postrm
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
purge)
|
||||||
|
rm -f /etc/udev/rules.d/99-odroid-wiringpi-*
|
||||||
|
;;
|
||||||
|
|
||||||
|
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "postrm called with unknown argument \`$1'" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
2
udev/rules.d/99-odroid-wiringpi-aml.rules
Normal file
2
udev/rules.d/99-odroid-wiringpi-aml.rules
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# /dev/gpiomem
|
||||||
|
SUBSYSTEM=="aml-gpiomem", GROUP="odroid", MODE="0660"
|
||||||
2
udev/rules.d/99-odroid-wiringpi-exynos.rules
Normal file
2
udev/rules.d/99-odroid-wiringpi-exynos.rules
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# /dev/gpiomem
|
||||||
|
SUBSYSTEM=="exynos-gpiomem", GROUP="odroid", MODE="0660"
|
||||||
Reference in New Issue
Block a user