diff options
Diffstat (limited to 'PKGBUILD')
-rw-r--r-- | PKGBUILD | 162 |
1 files changed, 101 insertions, 61 deletions
@@ -8,19 +8,30 @@ _opt_DKMS=1 # This can be toggled between installs set -u pkgname='moxa-mxu11x0' -pkgver='1.4' -pkgrel='2' +pkgver='5.0' +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' +url='https://www.moxa.com/en/products/industrial-edge-connectivity/usb-to-serial-converters-usb-hubs/usb-to-serial-converters/uport-1000-series' license=('GPL') depends=('glibc') optdepends=('setserial: set RS-422 485 modes') options=('!strip') 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') +_srcdir='moxa-all' +#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") +source=( + "https://www.moxa.com/Moxa/media/PDIM/S100000385/moxa-uport-1000-series-linux-kernel-5.0-for-uport-11x0-series-driver-v${pkgver}.zip" + 'https://www.moxa.com/Moxa/media/PDIM/S100000385/moxa-uport-1000-series-linux-kernel-4.0-for-uport-11x0-series-driver-v4.0.zip' + 'https://www.moxa.com/Moxa/media/PDIM/S100000385/moxa-uport-1000-series-linux-kernel-3.0-for-uport-11x0-series-driver-v3.0.zip' +) +noextract=("${source[@]##*/}") +md5sums=('e38bb66d6b830c490a90ce9c549d6124' + '611e04ddfc0432a98776368ff899c0b6' + 'e1ae31fdac579083afe96051cd9ceaa6') +sha256sums=('e4fd3cd953c98017691daf51e25cad4f311877aa498531efff0075fbdd9819df' + '809f5d1a3e75498727ecf4a0925483672b0e8c7f3583c4839e84dcbc8cc0b935' + 'da510884b6ea2a6c72a822d84bc7faea85908ad5736ea18f4bafdd2f7e22e761') if [ "${_opt_DKMS}" -ne 0 ]; then depends+=('linux' 'dkms' 'linux-headers') @@ -31,6 +42,22 @@ fi _modulename="${pkgname#*-}" _builtinmod='ti_usb_3410_5052' +declare -gA _folders +_setfolders() { + local _src _dst + for _src in "${source[@]##*/}"; do + if [[ "${_src}" =~ 'driver-v'([0-9]+)'.' ]]; then + _dst="moxa-${BASH_REMATCH[1]}" + _folders["${_src}"]="${_dst}" + else + echo "Unable to identify version in ${_src}" + set +u + false + fi + done +} +_setfolders + # We can't modify .install but we can stop and force the user to fix it. _install_check() { local _ckvar @@ -38,7 +65,7 @@ _install_check() { local _pkgname="${pkgname}" for _ckvar in '_pkgname' '_modulename' '_builtinmod'; do _ckline="${_ckvar}='${!_ckvar}'" - if ! grep -q "^${_ckline}"'$' "${startdir}/${install}"; then + if ! grep -qe "^${_ckline}"'$' "${startdir}/${install}"; then set +u msg "${install} must be fixed" echo "${_ckline}" @@ -47,51 +74,68 @@ _install_check() { done } +_multipatch() { + # Remove MACOS files + rm -r '__MACOSX' + rm -f 'readme.txt' + + cd 'source' + + # Scorched Earth, all new Makefile now that the build system is totally broken for any distro with more than one kernel version. + rm '.DS_Store' 'Makefile' 'mxinstall' + rm -f 'readme.txt' + + cd 'driver' + rm 'Makefile' 'mxconf' 'ver.mk' +} + prepare() { set -u + + mkdir "${_srcdir}" + local _src _dst + for _src in "${!_folders[@]}"; do + _dst="${_folders[${_src}]}" + mkdir "${_dst}" + set +u; msg2 "Extracting ${_src} with bsdtar"; set -u + bsdtar -x -C "${_dst}" -f "${_src}" + pushd "${_dst}" > /dev/null + _multipatch + popd > /dev/null + mv "${_dst}/source/driver" "${_srcdir}/${_dst}" + rmdir "${_dst}/source" "${_dst}" + done + _install_check + cd "${_srcdir}" - # Fix /lib - sed -e 's:/lib/:/usr/lib/:g' -i driver/*/Makefile driver/*/mxconf - - # Fix umbrella Makefile - sed -e '# Disable silent' \ - -e '/make / s:\s\+-s::g' \ - -e '# Disable kernel 2.4 detection' \ - -e '/^KERNEL_VERSION_MAJOR_NUMBER/,/^$/ s:^.:#&:g' \ - -e '# Improve chdir technique' \ - -e 's:^\t@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' \ - -e '# Switch SUBDIRS= to M= for Kernel 5.4' \ - -e 's:SUBDIRS=:M=$(PWD) &:g' \ - -i 'driver/kernel2.6/Makefile' + echo > 'Makefile' " +# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# https://aur.archlinux.org/"' + +KVER := $(shell uname -r) +KDIR := /usr/lib/modules/$(KVER)/build +KMAJOR := moxa-$(shell cut -d. -f1 <<<"$(KVER)") +PWD := $(shell pwd) +TARGET := mxu11x0 + +all: module + +ifneq ($(SUBDIRS),) +obj-m := $(KMAJOR)/$(TARGET).o +else +module: + $(MAKE) -s -C $(KDIR) M=$(PWD) SUBDIRS=$(PWD) modules + cp -p $(KMAJOR)/$(TARGET).ko . +endif + +clean: + $(MAKE) -s -C $(KDIR) M=$(PWD) SUBDIRS=$(PWD) clean + +install: + install -Dp $(TARGET).ko -t $(DESTDIR)$(KDIR)/../kernel/drivers/usb/serial/ +' set +u } @@ -124,11 +168,12 @@ package() { find "${pkgdir}/usr/lib/modules/" -type 'f' -name '*.ko' -exec 'gzip' '-9' '{}' ';' # Blacklist built in module + set +u; msg2 'Blacklist built in module'; set -u install -Dm644 <(cat << EOF # Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR # https://aur.archlinux.org/ -# This will kill other ti devices +# This will kill other TI devices like some Multitech MT9234ZBA-USB 93537152LF #blacklist ${_builtinmod} # Override alias list in ti_usb_3410_5052 @@ -138,12 +183,13 @@ alias usb:v110Ap1150d*dc*dsc*dp*ic*isc*ip*in* mxu11x0 alias usb:v110Ap1131d*dc*dsc*dp*ic*isc*ip*in* mxu11x0 alias usb:v110Ap1130d*dc*dsc*dp*ic*isc*ip*in* mxu11x0 alias usb:v110Ap1110d*dc*dsc*dp*ic*isc*ip*in* mxu11x0 -# This prefers the moxa driver over the ti driver for boot and hotplug +# This prefers the Moxa driver over the TI driver for boot and hotplug softdep ${_builtinmod} pre: ${_modulename} EOF ) "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf" if [ "${_opt_DKMS}" -ne 0 ]; then + set +u; msg2 'Installing DKMS files'; set -u rm -r "${pkgdir}/usr/lib/modules/" local _dkms="${pkgdir}/usr/src/${pkgname}-${pkgver}" install -Dm644 <(cat << EOF @@ -155,25 +201,19 @@ PACKAGE_VERSION="${pkgver}" AUTOINSTALL="yes" BUILT_MODULE_NAME[0]="${_modulename}" -BUILT_MODULE_LOCATION[0]="driver/kernel2.6" +#BUILT_MODULE_LOCATION[0]="" # 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" +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/usb/serial" EOF ) "${_dkms}/dkms.conf" - cp -pr 'driver/' "${_dkms}/" - rm -r "${_dkms}/driver/kernel2.4" - rm "${_dkms}/driver/kernel2.6/mxconf" + cp -pr './' "${_dkms}/" 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)" + -i "${_dkms}/Makefile" + make -s -C "${_dkms}/" clean KERNELRELEASE="$(uname -r)" fi set +u } |