Makefile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. include $(TOPDIR)/rules.mk
  2. PKG_NAME:=usbmode
  3. PKG_RELEASE:=1
  4. PKG_SOURCE_PROTO:=git
  5. PKG_SOURCE_URL=$(LEDE_GIT)/project/usbmode.git
  6. PKG_SOURCE_DATE:=2017-05-24
  7. PKG_SOURCE_VERSION:=453da8e540b1c53d357b897d6c70372cd4633390
  8. PKG_MIRROR_HASH:=b4a7132b940192f2e9a74bd890bd7008ede701e1d52284c3ade0cdc7d663929f
  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:=20170205
  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:=e2dcfd9d28928d8d8f03381571a23442b3c50d48d343bc40a1a07d01662738d1
  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_DATA) ./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))