Makefile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. include $(TOPDIR)/rules.mk
  2. PKG_NAME:=usbmode
  3. PKG_RELEASE:=2
  4. PKG_SOURCE_PROTO:=git
  5. PKG_SOURCE_URL=$(PROJECT_GIT)/project/usbmode.git
  6. PKG_SOURCE_DATE:=2017-12-19
  7. PKG_SOURCE_VERSION:=f40f84c27534159066c94dadc0c08e0b255c3e26
  8. PKG_MIRROR_HASH:=840c7ee2843102b09d8943a20820025251cc259385e2b0bde6b7c8cce8190f83
  9. CMAKE_INSTALL:=1
  10. PKG_LICENSE:=GPL-2.0
  11. PKG_LICENSE_FILES:=
  12. PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
  13. PKG_DATA_VERSION:=20170806
  14. PKG_DATA_URL:=http://www.draisberghof.de/usb_modeswitch
  15. PKG_DATA_PATH:=usb-modeswitch-data-$(PKG_DATA_VERSION)
  16. PKG_DATA_FILENAME:=$(PKG_DATA_PATH).tar.bz2
  17. include $(INCLUDE_DIR)/package.mk
  18. include $(INCLUDE_DIR)/cmake.mk
  19. define Download/data
  20. FILE:=$(PKG_DATA_FILENAME)
  21. URL:=$(PKG_DATA_URL)
  22. HASH:=ce413ef2a50e648e9c81bc3ea6110e7324a8bf981034fc9ec4467d3562563c2c
  23. endef
  24. $(eval $(call Download,data))
  25. define Package/usb-modeswitch
  26. SECTION:=utils
  27. CATEGORY:=Utilities
  28. DEPENDS:=+libubox +libblobmsg-json +libusb-1.0
  29. TITLE:=USB mode switching utility
  30. endef
  31. define Build/Prepare
  32. $(Build/Prepare/Default)
  33. tar xvfj $(DL_DIR)/$(PKG_DATA_FILENAME) -C $(PKG_BUILD_DIR)
  34. #remove devices with unsupported modes
  35. for filevar in $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/* ; \
  36. do \
  37. if grep -q -E '(Quanta|Option|Blackberry|Pantech)Mode' "$$$$filevar" ; then \
  38. rm "$$$$filevar" ; \
  39. fi \
  40. done
  41. cp ./data/* $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/
  42. #in order to keep the Lede GIT repo free of filenames with colons,
  43. #we name the files xxxx-yyyy
  44. # and rename here after copying to the build directory
  45. for filevar in $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/*-* ; \
  46. do \
  47. [ -f "$$$$filevar" ] || continue ; \
  48. FILENAME=$$$$(basename $$$$filevar) ; \
  49. NEWNAME=$$$${FILENAME//-/:} ; \
  50. rm "$(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/$$$$NEWNAME" ; \
  51. mv "$(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/$$$$FILENAME" "$(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/$$$$NEWNAME" ; \
  52. done
  53. endef
  54. define Package/usb-modeswitch/install
  55. $(INSTALL_DIR) $(1)/etc/hotplug.d/usb $(1)/etc/init.d $(1)/sbin
  56. perl $(PKG_BUILD_DIR)/convert-modeswitch.pl \
  57. $(PKG_BUILD_DIR)/$(PKG_DATA_PATH)/usb_modeswitch.d/* \
  58. > $(1)/etc/usb-mode.json
  59. $(INSTALL_CONF) ./files/usbmode.hotplug $(1)/etc/hotplug.d/usb/20-usb_mode
  60. $(INSTALL_BIN) ./files/usbmode.init $(1)/etc/init.d/usbmode
  61. $(CP) $(PKG_INSTALL_DIR)/usr/sbin/usbmode $(1)/sbin/
  62. endef
  63. $(eval $(call BuildPackage,usb-modeswitch))