# Maintainer: Chris Severance aur.severach aATt spamgourmet dott com # Todo: should we make a udev startup for setserial RS-422 485 # lsmod | grep -Ee '(mxu11x0|ti_usb_3410_5052)' _opt_DKMS=1 # This can be toggled between installs set -u pkgname='moxa-mxu11x0' pkgver='1.4' pkgrel='1' pkgdesc='kernel module driver for Moxa UPort USB serial 1110 1130i 1150i RS-232 422 485' arch=('i686' 'x86_64') url='https://www.moxa.com/support/support_home.aspx' license=('GPL') depends=('glibc') optdepends=('setserial: set RS-422 485 modes') install="${pkgname}-install.sh" _srcdir="${pkgname#*-}" source=("https://www.moxa.com/drivers/IDC_SW/UPort/Driver/UPort%201100%20Series/Linux/V${pkgver}/legacy/driv_linux_kernel2.x_uport1p_v${pkgver}_build_18050314.tgz") sha256sums=('b9878842c3cd05f66647b584e10ed0689f7614b2b37ac31ba9c4da87d0bcba19') if [ "${_opt_DKMS}" -ne 0 ]; then depends+=('linux' 'dkms' 'linux-headers') else makedepends+=('linux-headers') fi _modulename="${pkgname#*-}" _builtinmod='ti_usb_3410_5052' # 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' '_builtinmod'; do _ckline="${_ckvar}='${!_ckvar}'" if ! grep -q "^${_ckline}"'$' "${startdir}/${install}"; then msg "${install} must be fixed" echo "${_ckline}" set +u false fi done } prepare() { set -u _install_check cd "${_srcdir}" # Fix /lib sed -e 's:/lib/:/usr/lib/:g' -i driver/*/Makefile driver/*/mxconf # Fix umbrella Makefile sed -e '# Too quiet' \ -e '/make / s: -s::g' \ -e '# Disable kernel 2.4 detection' \ -e '/^KERNEL_VERSION_MAJOR_NUMBER/,/^$/ s:^.:#&:g' \ -e '# Improve chdir technique' \ -e 's:^.*@cd.*$:#&-:g' \ -e 's:^\tmake:\t@make -C $(DRIVER_PATH):g' \ -i 'Makefile' # Fix driver Makefile sed -e '# CentOS option is only for Kernel 3.10, its easier to redo blackisting than to fix it' \ -e '/^TI_3410/,/^BLACKLIST_LINE/ s:^.:#&:g' \ -e '# Ungroup make targets' \ -e '/^module:/ s: envchk::g' \ -e '/^install:/ s: module::g' \ -e '# Extra file in gcc8' \ -e 's/^clean_local:.*$/&\n\t@rm -f .cache.mk/g' \ -e '# Make package compatible' \ -e '/^install:/,/^$/ s:/usr:$(DESTDIR)&:g' \ -e '# Fix install by removing every line' \ -e '/^install:/,/^$/ s:^\t:#&:g' \ -e '# Put back the lines we want' \ -e '\:kernel/drivers/usb/serial: s:^#::g' \ -e '# Fedora detection isnt used anywhere' \ -e 's:^KDISVER:#&:g' \ -e '/fc6/,/^$/ s:^.:#&:g' \ -e '# Cut the noise' \ -e '/^module:/,/^$/ s:\t@echo:#&:g' \ -e 's:^DRV_VER:#&:g' \ -e 's:^REL_DATE:#&:g' \ -e '# Change to kernel built in make clean' \ -e 's/^clean:/clean_orig:/g' \ -e 's/^clean_orig:/clean:\n\t@$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean\n\n&/g' \ -i 'driver/kernel2.6/Makefile' set +u } build() { set -u cd "${_srcdir}" make -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 make -j1 DESTDIR="${pkgdir}" install # 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' '{}' ';' # Blacklist built in module install -Dm644 <(cat << EOF # Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR # https://aur.archlinux.org/ blacklist ${_builtinmod} EOF ) "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf" if [ "${_opt_DKMS}" -ne 0 ]; then rm -r "${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]="driver/kernel2.6" # Using all processors doesn't compile this tiny module any faster. MAKE[0]="make -j1 -C 'driver/kernel2.6'" CLEAN[0]="make -j1 -C 'driver/kernel2.6' clean" # The install version is .ko.gz. The DKMS version is .ko. No conflicts. DEST_MODULE_LOCATION[0]="/kernel/drivers/usb/serial" EOF ) "${_dkms}/dkms.conf" install -dm755 "${_dkms}/driver/" cp -pr 'driver/' "${_dkms}/" rm -r "${_dkms}/driver/kernel2.4" rm "${_dkms}/driver/kernel2.6/mxconf" 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 '# DKMS sets KERNELRELEASE which accidentally launches phase 2 of this Makefile' \ -e '# Fix by changing the detection var.' \ -e '# SUBDIRS makes more sense to me because I can see it in the Makefile!' \ -e 's:ifneq ($(KERNELRELEASE),):ifneq ($(SUBDIRS),):g' \ -i "${_dkms}/driver/kernel2.6/Makefile" make -s -C "${_dkms}/driver/kernel2.6/" clean KERNELRELEASE="$(uname -r)" fi set +u } set +u