blob: 7d43e949c86e79295eb3b86ac89b8290bec46087 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
# Maintainer: Chris Severance aur.severach aATt spamgourmet dott com
# TODO: The Linux kernel in tree rocket module is (C)2003 and should be updated to this driver.
# TODO: Test firmware updater.
# TODO: Could the RocketModem II firmware updater be launched by udev?
# TODO: Should the firmware updater be set to an earlier target to minimize conflicts with programs that use the modems?
# TODO: kernel bug lspci: The RocketPort PCI 4J is claimed to have RJ11 connectors. It has RJ45 connectors. The 8J has RJ11 connectors.
# This is for PCI and uPCI, not Express or Infinity
_opt_DKMS=1 # This can be toggled between installs
# ls -l /dev/ttyR*
# lsmod | grep rocket
# lspci -v | grep -A4 -i rocket
# sudo cat /proc/tty/driver/rocketupci
# dmesg | grep -A8 -i rocket
#[ 4.138731] rocketupci: Comtrol RocketPort driver version 4.05 Arch Linux https://aur.archlinux.org/packages/comtrol-rocketport-upci/
#[ 4.138880] rocketupci 0000:07:02.0: found RP UPCI Plus 4 port RJ45 with 4 ports
#[ 4.139228] 0000:07:02.0: ttyR0 at I/O 0x1c000 (irq = 18, base_baud = 921600) is a RP UPCI Plus 4 port RJ45
#[ 4.139622] 0000:07:02.0: ttyR1 at I/O 0x1c002 (irq = 18, base_baud = 921600) is a RP UPCI Plus 4 port RJ45
#[ 4.140027] 0000:07:02.0: ttyR2 at I/O 0x1c004 (irq = 18, base_baud = 921600) is a RP UPCI Plus 4 port RJ45
#[ 4.140448] 0000:07:02.0: ttyR3 at I/O 0x1c006 (irq = 18, base_baud = 921600) is a RP UPCI Plus 4 port RJ45
#[ 4.140504] rocketupci 0000:07:02.0: polling at 100Hz
set -u
pkgname='comtrol-rocketport-upci'
pkgver='4.05'
pkgrel='1'
pkgdesc='kernel module driver for Comtrol RocketPort PCI Plus Universal uPCI CPCI Rocketmodem serial RS-232 422 port'
arch=('i686' 'x86_64')
url='http://downloads.comtrol.com/html/RPuPCI_drivers.htm'
license=('GPL')
makedepends=('gzip' 'findutils' 'sed' 'diffutils' 'patch')
backup=('etc/modprobe.d/rocketupci.conf')
install="${pkgname}-install.sh"
_srcdir="rocketport-linux-${pkgver}"
source=("http://downloads.comtrol.com/rport/drivers/u_pci/linux/rocketport-linux-${pkgver}.tar.gz" 'rocketport-upci-firmware.sh')
sha256sums=('370f65a2dc5128e57cb7480aff5756996ceb24ad4312d1454f5debb1611fe5da'
'6fa93b24ffe0ff6849b9b05bcd55dcaf4eb09c13321c55bbb2f04b369008d149')
_modulename='rocketupci'
if [ "${_opt_DKMS}" -ne 0 ]; then
depends+=('linux' 'dkms' 'linux-headers')
else
makedepends+=('linux-headers')
fi
# We can't modify .install but we can stop and force the user to fix it.
_install_check() {
local _ckvar
local _ckline
local _pkgname="${pkgname}"
for _ckvar in _pkgname _modulename; do
_ckline="${_ckvar}='${!_ckvar}'"
if ! grep -q "^${_ckline}"'$' "${startdir}/${install}"; then
set +u
msg "${install} must be fixed"
echo "${_ckline}"
false
fi
done
}
prepare() {
set -u
_install_check
cd "${_srcdir}"
find -type 'f' -exec chmod 644 '{}' '+'
chmod 755 *.sh
# Fix umbrella makefile
sed -e 's:/lib/:/usr/lib/:g' -i 'Makefile'
# Branding
sed -e '/printk/ s@DRV_VERS@& " Arch Linux'" https://aur.archlinux.org/packages/${pkgname}/"'" @g' -i 'rocket.c'
# Change module name to prevent conflict with rocket.ko (C)2003 for RocketPort PCI
if [ "${_modulename}" != 'rocket' ]; then
sed -e "s:rocket:${_modulename}:g" -i 'Makefile'
sed -e "s|rocket:|${_modulename}:|g" \
-e "/DRV_NAME/ s:rocket:${_modulename}:g" \
-i 'rocket.c'
sed -e "s:rocket:${_modulename}:g" -i 'install.sh'
mv 'rocket.c' "${_modulename}.c"
fi
# Fix loadrm2 makefile
sed -e 's:/sbin:/usr/bin:g' \
-e 's: /usr/: $(DESTDIR)/usr/:g' \
-e 's: /etc: $(DESTDIR)/etc:g' \
-i 'loadrm2/Makefile'
# Move the firmware out of /etc
sed -e "s:/etc/:/usr/lib/firmware/${pkgname}/:g" -i 'loadrm2/loadrm2.h'
# Make installer package compatible
cp -p 'install.sh' 'install.Arch.sh' # debugging
sed -e '1a set -e' -e '1a set -u' -e '#1a set -x' -e '1a DESTDIR=' -i 'install.sh'
sed -e '# Fix sbin and lib' \
-e 's:/usr/sbin/:/usr/bin/:g' \
-e 's:/sbin/:/usr/bin/:g' \
-e 's:/lib/:/usr/lib/:g' \
-e '# Add DESTDIR' \
-e 's:/usr/:"${DESTDIR}"&:g' \
-e 's:/etc/:"${DESTDIR}"&:g' \
-e 's:""${DESTDIR}":"${DESTDIR}:g' \
-i 'install.sh'
set +u
}
build() {
set -u
cd "${_srcdir}"
make -s -j1 # too small for parallel make
set +u
}
package() {
set -u
cd "${_srcdir}"
if [ "${_opt_DKMS}" -eq 0 ]; then
# I don't want Linux version info showing on AUR web. After a few months 'linux<0.0.0' makes it look like an out of date package.
local _kernelversionsmall="$(uname -r)"
_kernelversionsmall="${_kernelversionsmall%%-*}"
_kernelversionsmall="${_kernelversionsmall%\.0}" # trim 4.0.0 -> 4.0, 4.1.0 -> 4.1
# prevent the mksrcinfo bash emulator from getting these vars!
eval 'conf''licts=("linux>${_kernelversionsmall}" "linux<${_kernelversionsmall}")'
eval 'dep''ends+=("linux=${_kernelversionsmall}")'
fi
sed -e 's:^\(DESTDIR\)=.*$'":\1=${pkgdir}:g" -i 'install.sh'
install -d \
"${pkgdir}/usr/bin" \
"${pkgdir}/usr/lib/modules/$(uname -r)/kernel/drivers" \
"${pkgdir}/etc" \
"${pkgdir}/etc/modules-load.d" \
"${pkgdir}/etc/modprobe.d"
ln -s '/usr/bin/true' "${pkgdir}/usr/bin/depmod"
make -s -j1 DESTDIR="${pkgdir}" install rm2_install
rm "${pkgdir}/usr/bin/depmod"
install -Dp "${pkgdir}/etc"/*.rm -t "${pkgdir}/usr/lib/firmware/${pkgname}"
rm "${pkgdir}/etc"/*.rm
# Modern kernels detect and load automatically
rm -r "${pkgdir}/etc/modules-load.d"
# Blacklist exiting incomplete rocket module
cat >> "${pkgdir}/etc/modprobe.d/rocketupci.conf" << EOF
# Do not load old rocket module that only supports RocketPort PCI
blacklist rocket
EOF
# The module is in the same folder as DKMS. Compress to a different name to prevent conflict.
# When future versions of DKMS compress we'll stop doing this.
find "${pkgdir}/usr/lib/modules/" -type 'f' -name '*.ko' -exec 'gzip' '-9' '{}' ';'
# Install the setcountry script with a name findable by tab completion
install -Dpm755 'setcountry.sh' "${pkgdir}/usr/bin/setcountry-rocketmodem.sh"
# Install RocketPort II firmware helper
install -Dpm755 "${srcdir}/rocketport-upci-firmware.sh" -t "${pkgdir}/usr/bin"
sed -e 's:^\(module\)=.*$'":\1='${_modulename}':g" -i "${pkgdir}/usr/bin/rocketport-upci-firmware.sh"
# Install RocketPort II firmware service
install -Dm644 <(cat << EOF
# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR
# https://aur.archlinux.org/
[Unit]
Description=Comtrol RocketModem II Firmware Loader
After=network.target
[Service]
Type=notify
# We want the logs to show that the modems were initialized
ExecStart=/usr/bin/rocketport-upci-firmware.sh --systemd -p
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
) "${pkgdir}/usr/lib/systemd/system/rocketport-upci-firmware.service"
if [ "${_opt_DKMS}" -ne 0 ]; then
rm -rf "${pkgdir}/usr/lib/modules/"
local _dkms="${pkgdir}/usr/src/${pkgname}-${pkgver}"
install -Dm644 <(cat << EOF
# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR
# https://aur.archlinux.org/
PACKAGE_NAME="${pkgname}"
PACKAGE_VERSION="${pkgver}"
AUTOINSTALL="yes"
BUILT_MODULE_NAME[0]="${_modulename}"
BUILT_MODULE_LOCATION[0]=""
# Using all processors doesn't compile this tiny module any faster.
MAKE[0]="make -j1"
CLEAN[0]="make -j1 clean"
# The install version is .ko.gz. The DKMS version is .ko. No conflicts.
DEST_MODULE_LOCATION[0]="/kernel/drivers/tty"
EOF
) "${_dkms}/dkms.conf"
install -dm755 "${_dkms}/"
cp -pr './' "${_dkms}/"
pushd "${_dkms}" > /dev/null
rm 'HISTORY' *.sh
rm -r 'loadrm2'
popd > /dev/null
sed -e '# No DKMS instructions say to do this but it works and keeps the MAKE line real simple' \
-e 's:shell uname -r:KERNELRELEASE:g' \
-e '# Disable compile loadrm2' \
-e '/loadrm2/ s:^:#:g' \
-i "${_dkms}/Makefile"
make -s -C "${_dkms}/" clean
fi
set +u
}
set +u
|