net-misc/can-utils: New package 2020.12.0

Package-Manager: Portage-3.0.13, Repoman-3.0.2
Signed-off-by: Hans Fredrik Nordhaug <hansfn@gmail.com>
This commit is contained in:
Hans Fredrik Nordhaug
2021-02-26 22:17:24 +01:00
parent d42141c6df
commit 2e7aa9eed8
9 changed files with 251 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
DIST can-utils-2020.02.04.tar.gz 121866 BLAKE2B 64a9e0dbc2e65ef01b6709fc608daecce53592f98c002a46b15a282fff33f52d1d7b34d22ed85f1e2a2eb8a7be6e5ce69a85ba4e2ba19f251994f5022697f474 SHA512 5f12a84b82564da5a47e6dc906bf26f0e56db77ce367b5b72a2820cf18447d78a355d0173c678e33dc0e4cc07ef3a12b3a84d6b016c7ee0b1ac5a7f10daee1c8
DIST can-utils-2020.12.0.tar.gz 132010 BLAKE2B 626c0b88973c0579728869013f48ec7de4bcd94dd98ed4ae8349a0b71ec2eb9892d267501ff7af58b34ac528f2d6e733aad795582bcc96b03d20ae0710986ea8 SHA512 b9d92b7734611deaf445708aabf4f46f7cf3ad88f46618fbae6821d308b2950da014420b194792e4d2458f396bd85f200a8d10112c10191a98624073b8502c19

View File

@@ -0,0 +1,49 @@
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit autotools systemd
DESCRIPTION="CAN userspace utilities and tools"
HOMEPAGE="https://github.com/linux-can/"
SRC_URI="https://github.com/linux-can/can-utils/archive/v${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64"
IUSE="systemd"
DEPEND=""
src_prepare() {
default
eautoreconf
}
# Default src_install + newconfd and newinitd
src_install() {
emake DESTDIR="${D}" install
if ! declare -p DOCS >/dev/null 2>&1 ; then
local d
for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS \
FAQ CREDITS CHANGELOG ; do
[[ -s "${d}" ]] && dodoc "${d}"
done
elif declare -p DOCS | grep -q "^declare -a " ; then
dodoc "${DOCS[@]}"
else
dodoc ${DOCS}
fi
if use systemd ; then
systemd_dounit "${FILESDIR}/slcan.service"
systemd_install_serviced "${FILESDIR}/slcan.service.conf"
else
newconfd "${FILESDIR}/slcand.confd" slcand
newinitd "${FILESDIR}/slcand.initd" slcand
fi
}

View File

@@ -0,0 +1,49 @@
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit autotools systemd
DESCRIPTION="CAN userspace utilities and tools"
HOMEPAGE="https://github.com/linux-can/"
SRC_URI="https://github.com/linux-can/can-utils/archive/v${PV}.tar.gz -> ${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64"
IUSE="systemd"
DEPEND=""
src_prepare() {
default
eautoreconf
}
# Default src_install + newconfd and newinitd
src_install() {
emake DESTDIR="${D}" install
if ! declare -p DOCS >/dev/null 2>&1 ; then
local d
for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS \
FAQ CREDITS CHANGELOG ; do
[[ -s "${d}" ]] && dodoc "${d}"
done
elif declare -p DOCS | grep -q "^declare -a " ; then
dodoc "${DOCS[@]}"
else
dodoc ${DOCS}
fi
if use systemd ; then
systemd_dounit "${FILESDIR}/slcan.service"
systemd_install_serviced "${FILESDIR}/slcan.service.conf"
else
newconfd "${FILESDIR}/slcand.confd" slcand
newinitd "${FILESDIR}/slcand.initd" slcand
fi
}

View File

@@ -0,0 +1,49 @@
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
EGIT_REPO_URI="https://github.com/linux-can/${PN}.git"
EGIT_BRANCH="master"
inherit autotools git-r3 systemd
DESCRIPTION="CAN userspace utilities and tools"
HOMEPAGE="https://github.com/linux-can/"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64"
IUSE="systemd"
DEPEND=""
src_prepare() {
eautoreconf
}
# Default src_install + newconfd and newinitd
src_install() {
emake DESTDIR="${D}" install
if ! declare -p DOCS >/dev/null 2>&1 ; then
local d
for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS \
FAQ CREDITS CHANGELOG ; do
[[ -s "${d}" ]] && dodoc "${d}"
done
elif declare -p DOCS | grep -q "^declare -a " ; then
dodoc "${DOCS[@]}"
else
dodoc ${DOCS}
fi
if use systemd ; then
systemd_dounit "${FILESDIR}/slcan.service"
systemd_install_serviced "${FILESDIR}/slcan.service.conf"
else
newconfd "${FILESDIR}/slcand.confd" slcand
newinitd "${FILESDIR}/slcand.initd" slcand
fi
}

View File

@@ -0,0 +1,19 @@
[Unit]
Description=Userspace daemon for serial line CAN interface driver SLCAN
[Service]
Environment=can_speed=S5
Environment=tty_baud=460800
Environment=tty_device=ttyUSB0
Environment=can_device=can0
ExecStartPre=/sbin/modprobe slcan
ExecStartPre=/bin/stty -F /dev/${tty_device} ${tty_baud} line 0 cs8 -onlcr -echo raw min 100 time 2
ExecStartPre=/bin/sh -c 'echo -e -n "C\rF\r${can_speed}\rO\r" > /dev/${tty_device}'
ExecStart=/usr/bin/slcand -F ${tty_device} ${can_device}
ExecStartPost=/bin/sleep 1
ExecStartPost=/bin/ip link set can0 txqueuelen 1000 up
ExecStopPost=/sbin/modprobe -r slcan

View File

@@ -0,0 +1,18 @@
# This file contains the configuration for the slcan daemon
# The `stty' command includes support for speeds of 57600, 115200,
# 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000,
# 2000000, 2500000, 3000000, 3500000, or 4000000
# 921600 baud for S6
# 460800 baud for S5
# Case sensitive speed setting
[Service]
Environment=can_speed=S5
Environment=tty_baud=460800
Environment=tty_device=ttyUSB0
Environment=can_device=can0

View File

@@ -0,0 +1,18 @@
# /etc/conf.d/slcand
# This file contains the configuration for the slcan daemon
# The `stty' command includes support for speeds of 57600, 115200,
# 230400, 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000,
# 2000000, 2500000, 3000000, 3500000, or 4000000
# 921600 baud for S6
# 460800 baud for S5
# Case sensitive speed setting
can_speed="S5"
tty_baud="460800"
tty_device="ttyUSB0"
can_device="can0"

View File

@@ -0,0 +1,39 @@
#!/sbin/runscript
# Copyright 2013 Brunvoll AS
start() {
if [ -z "${can_speed}" -o -z "${tty_baud}" -o -z "${tty_device}" -o -z "${can_device}" ]; then
eerror "CAN speed, CAN device, tty_baud or tty_device not set"
return 1
fi
if ! grep -q slcan /proc/modules; then
einfo "Loading module slcan"
modprobe slcan || return 1
fi
ebegin "Creating can0 at speed ${can_speed} on device ${tty_device}"
einfo "Setting baudrate of ${tty_device} to ${tty_baud}"
stty -F /dev/${tty_device} ${tty_baud} line 0 cs8 -onlcr -echo raw min 100 time 2
sleep 1
einfo "Set bitrate of slcan on ${tty_device} to ${can_speed}: "
echo -e -n "C\rF\r${can_speed}\rO\r" > /dev/${tty_device}
sleep 1
einfo "Starting slcand"
start-stop-daemon --start --background --make-pidfile \
--pidfile /var/run/slcand.pid \
--exec /usr/bin/slcand -- ${tty_device} ${can_device}
sleep 1
ifconfig ${can_device} up
eend $?
}
stop() {
ebegin "Stopping slcand"
start-stop-daemon --stop --quiet --pidfile /var/run/slcand.pid
sleep 1
rmmod slcan
eend $?
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>hansfn@gmail.com</email>
<name>Hans Fredrik Nordhaug</name>
</maintainer>
</pkgmetadata>