You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

352 lines
14 KiB

  1. #
  2. # Copyright (C) 2006-2015 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=nut
  9. PKG_VERSION:=2.7.3
  10. PKG_RELEASE:=2
  11. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  12. PKG_SOURCE_URL:=http://www.networkupstools.org/source/2.7/
  13. PKG_MD5SUM:=a1a7f747093663e1f39ab595b63b45e4
  14. PKG_MAINTAINER:=Martin Rowe <martin.p.rowe@gmail.com>
  15. PKG_LICENSE:=GPL-2.0
  16. PKG_LICENSE_FILES:=LICENSE-GPL2
  17. PKG_BUILD_DIR:=$(BUILD_DIR)/nut-$(PKG_VERSION)
  18. PKG_INSTALL:=1
  19. PKG_CONFIG_DEPENDS:= \
  20. CONFIG_NUT_CLIENTS_UPSC \
  21. CONFIG_NUT_CLIENTS_UPSCMD \
  22. CONFIG_NUT_CLIENTS_UPSLOG \
  23. CONFIG_NUT_CLIENTS_UPSMON \
  24. CONFIG_NUT_CLIENTS_UPSRW \
  25. CONFIG_NUT_CLIENTS_UPSSCHED \
  26. CONFIG_NUT_DRIVER_SNMP \
  27. CONFIG_NUT_DRIVER_USB \
  28. CONFIG_NUT_SERVER \
  29. CONFIG_NUT_SSL
  30. include $(INCLUDE_DIR)/package.mk
  31. define Package/nut/Default
  32. SECTION:=net
  33. CATEGORY:=Network
  34. URL:=http://www.networkupstools.org/
  35. DEPENDS:=nut
  36. endef
  37. define Package/nut/description
  38. Network UPS Tools (NUT) is a client/server monitoring system that
  39. allows computers to share uninterruptible power supply (UPS) and
  40. power distribution unit (PDU) hardware. Clients access the hardware
  41. through the server, and are notified whenever the power status
  42. changes.
  43. endef
  44. define Package/nut
  45. $(call Package/nut/Default)
  46. TITLE:=Network UPS Tools
  47. DEPENDS:= \
  48. +libpthread \
  49. +NUT_DRIVER_SNMP:libnetsnmp \
  50. +NUT_DRIVER_USB:libusb-compat \
  51. +NUT_SSL:libopenssl
  52. MENU:=1
  53. endef
  54. define Package/nut/config
  55. source "$(SOURCE)/Config.in"
  56. endef
  57. define Package/nut/conffiles
  58. /etc/nut/nut.conf
  59. $(if $(CONFIG_NUT_CLIENTS_UPSMON),/etc/nut/upsmon.conf)
  60. $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),/etc/nut/upssched.conf)
  61. $(if $(CONFIG_NUT_SERVER),/etc/nut/ups.conf)
  62. $(if $(CONFIG_NUT_SERVER),/etc/nut/upsd.conf)
  63. $(if $(CONFIG_NUT_SERVER),/etc/nut/upsd.users)
  64. endef
  65. define Package/nut/install
  66. $(INSTALL_DIR) $(1)/etc/nut
  67. $(INSTALL_DIR) $(1)/usr/bin
  68. $(INSTALL_DIR) $(1)/usr/lib
  69. $(INSTALL_DIR) $(1)/usr/sbin
  70. $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/nut.conf.sample $(1)/etc/nut/nut.conf
  71. $(if $(or $(CONFIG_NUT_CLIENTS_UPSC),\
  72. $(CONFIG_NUT_CLIENTS_UPSCMD),\
  73. $(CONFIG_NUT_CLIENTS_LOG),\
  74. $(CONFIG_NUT_CLIENTS_UPSRW),\
  75. $(CONFIG_NUT_CLIENTS_UPSMON),\
  76. $(CONFIG_NUT_CLIENTS_UPSSCHED)),$(CP) $(PKG_INSTALL_DIR)/usr/lib/libupsclient.so* $(1)/usr/lib/)
  77. $(if $(or $(CONFIG_NUT_SERVER),\
  78. $(CONFIG_NUT_CLIENTS_UPSMON)),$(INSTALL_DIR) $(1)/etc/init.d)
  79. $(if $(CONFIG_NUT_SERVER),$(INSTALL_DIR) $(1)/lib/nut)
  80. $(if $(CONFIG_NUT_SERVER),$(INSTALL_DIR) $(1)/usr/share/nut)
  81. $(if $(CONFIG_NUT_SERVER),$(CP) ./files/nut-server.init $(1)/etc/init.d/)
  82. $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsd $(1)/usr/sbin)
  83. $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsdrvctl $(1)/usr/sbin)
  84. $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/share/nut/cmdvartab $(1)/usr/share/nut/)
  85. $(if $(CONFIG_NUT_SERVER),$(CP) $(PKG_INSTALL_DIR)/usr/share/nut/driver.list $(1)/usr/share/nut/)
  86. $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/ups.conf.sample $(1)/etc/nut/ups.conf)
  87. $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.conf.sample $(1)/etc/nut/upsd.conf)
  88. $(if $(CONFIG_NUT_SERVER),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsd.users.sample $(1)/etc/nut/upsd.users)
  89. $(if $(CONFIG_NUT_CLIENTS_UPSC),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upsc $(1)/usr/bin/)
  90. $(if $(CONFIG_NUT_CLIENTS_UPSCMD),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upscmd $(1)/usr/bin/)
  91. $(if $(CONFIG_NUT_CLIENTS_UPSLOG),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upslog $(1)/usr/bin/)
  92. $(if $(CONFIG_NUT_CLIENTS_UPSRW),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upsrw $(1)/usr/bin/)
  93. $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(CP) ./files/nut-monitor.init $(1)/etc/init.d/)
  94. $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upsmon $(1)/usr/sbin/)
  95. $(if $(CONFIG_NUT_CLIENTS_UPSMON),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsmon.conf.sample $(1)/etc/nut/upsmon.conf)
  96. $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(CP) $(PKG_INSTALL_DIR)/usr/bin/upssched-cmd $(1)/usr/bin/)
  97. $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(CP) $(PKG_INSTALL_DIR)/usr/sbin/upssched $(1)/usr/sbin/)
  98. $(if $(CONFIG_NUT_CLIENTS_UPSSCHED),$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upssched.conf.sample $(1)/etc/nut/upssched.conf)
  99. endef
  100. define Package/nut-web-cgi
  101. $(call Package/nut/Default)
  102. TITLE+= Web CGI interface
  103. DEPENDS+=+libgd
  104. endef
  105. define Package/nut-web-cgi/description
  106. The CGI programs are clients that run through your web server.
  107. They allow you to see UPS status and perform certain administrative
  108. commands from any web browser. Javascript and cookies are not required.
  109. endef
  110. define Package/nut-web-cgi/conffiles
  111. /etc/nut/hosts.conf
  112. /etc/nut/upsset.conf
  113. /etc/nut/upsstats.html
  114. /etc/nut/upsstats-single.html
  115. endef
  116. define Package/nut-web-cgi/install
  117. $(INSTALL_DIR) $(1)/etc/nut
  118. $(INSTALL_DIR) $(1)/usr/share/www/cgi-bin
  119. $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/hosts.conf.sample $(1)/etc/nut/hosts.conf
  120. $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsset.conf.sample $(1)/etc/nut/upsset.conf
  121. $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats.html.sample $(1)/etc/nut/upsstats.html
  122. $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats-single.html.sample $(1)/etc/nut/upsstats-single.html
  123. $(CP) $(PKG_INSTALL_DIR)/usr/share/www/nut $(1)/usr/share/www/
  124. $(CP) $(PKG_INSTALL_DIR)/usr/share/www/cgi-bin/nut $(1)/usr/share/www/cgi-bin/
  125. endef
  126. define Package/nut-avahi-service
  127. $(call Package/nut/Default)
  128. TITLE+= (Avahi service)
  129. DEPENDS+=+avahi-daemon
  130. endef
  131. define Package/nut-avahi-service/description
  132. This package contains the service definition for announcing the
  133. attached UPS via mDNS/DNS-SD.
  134. endef
  135. define Package/nut-avahi-service/conffiles
  136. /etc/avahi/services/nut.service
  137. endef
  138. define Package/nut-avahi-service/install
  139. $(INSTALL_DIR) $(1)/etc/avahi/services
  140. $(INSTALL_CONF) ./files/nut.service $(1)/etc/avahi/services/
  141. endef
  142. # Dealing with all of the drivers is very repetitive, but the previous
  143. # maintainer had a neat solution which just needed some tweaking.
  144. define DriverPackage
  145. define Package/nut-driver-$(2)
  146. $(call Package/nut/Default)
  147. TITLE:=$(2) (NUT $(1) driver)
  148. $(if $(filter $(1),snmp),DEPENDS+= @NUT_DRIVER_SNMP)
  149. $(if $(filter $(1),usb),DEPENDS+= @NUT_DRIVER_USB)
  150. endef
  151. # Deliberately empty description in order to trigger a build failure.
  152. # It should be overridden by the list below, and when updating to a
  153. # new version of nut we will need to provide descriptions for any new
  154. # drivers.
  155. define Package/nut-driver-$(2)/description
  156. endef
  157. define Package/nut-driver-$(2)/install
  158. $(INSTALL_DIR) $$(1)/lib/nut
  159. $(CP) $$(PKG_INSTALL_DIR)/lib/nut/$(2) $$(1)/lib/nut/
  160. $(if $(filter $(2),clone),$(CP) $$(PKG_INSTALL_DIR)/lib/nut/$(2)-outlet $$(1)/lib/nut/)
  161. endef
  162. endef
  163. define DriverDescription
  164. define Package/nut-driver-$(2)/description
  165. $(3)
  166. endef
  167. endef
  168. # These lists are lifted *directly* from drivers/Makefile.am in the nut
  169. # source tree. This it to make it simpler to keep in sync when updating
  170. # to a newer version of nut. Do not edit this manually.
  171. #
  172. # DO NOT EDIT (except to update with a fresh cut/paste)!
  173. SERIAL_DRIVERLIST = al175 bcmxcp belkin belkinunv bestfcom \
  174. bestfortress bestuferrups bestups dummy-ups etapro everups \
  175. gamatronic genericups isbmex liebert liebert-esp2 masterguard metasys \
  176. oldmge-shut mge-utalk microdowell mge-shut oneac optiups powercom rhino \
  177. safenet skel solis tripplite tripplitesu upscode2 victronups powerpanel \
  178. blazer_ser clone clone-outlet ivtscd apcsmart apcsmart-old apcupsd-ups riello_ser \
  179. nutdrv_qx
  180. SNMP_DRIVERLIST = snmp-ups
  181. USB_LIBUSB_DRIVERLIST = usbhid-ups bcmxcp_usb tripplite_usb \
  182. blazer_usb richcomm_usb riello_usb \
  183. nutdrv_atcl_usb \
  184. nutdrv_qx
  185. # END: DO NOT EDIT!
  186. SERIAL_DRIVERLIST_IGNORE:=skel clone-outlet nutdrv_qx
  187. # nutdrv_qx can be either USB or serial. Given most routers have USB
  188. # instead of serial ports, and not wanting two identical packages with
  189. # different names that conflict with each other, only the option for the
  190. # driver with USB bindings is provided. If you really want to save that
  191. # tiny bit of space and build it without USB support, remove nutdrv_qx
  192. # from the previous line.
  193. $(foreach d,$(filter-out $(SERIAL_DRIVERLIST_IGNORE),$(SERIAL_DRIVERLIST)),$(eval $(call DriverPackage,serial,$(d))))
  194. $(foreach d,$(SNMP_DRIVERLIST),$(eval $(call DriverPackage,snmp,$(d))))
  195. $(foreach d,$(USB_LIBUSB_DRIVERLIST),$(eval $(call DriverPackage,usb,$(d))))
  196. $(eval $(call DriverDescription,serial,al175,\
  197. Driver for Eltek UPS models with AL175 alarm module))
  198. $(eval $(call DriverDescription,serial,bcmxcp,\
  199. Driver for UPSes supporting the serial BCM/XCP protocol))
  200. $(eval $(call DriverDescription,serial,belkin,\
  201. Driver for Belkin serial UPS equipment))
  202. $(eval $(call DriverDescription,serial,belkinunv,\
  203. Driver for Belkin "Universal UPS" and compatible))
  204. $(eval $(call DriverDescription,serial,bestfcom,\
  205. Driver for Best Power Fortress/Ferrups))
  206. $(eval $(call DriverDescription,serial,bestfortress,\
  207. Driver for old Best Fortress UPS equipment))
  208. $(eval $(call DriverDescription,serial,bestuferrups,\
  209. Driver for Best Power Micro-Ferrups))
  210. $(eval $(call DriverDescription,serial,bestups,\
  211. Driver for Best Power / SOLA (Phoenixtec protocol) UPS equipment))
  212. $(eval $(call DriverDescription,serial,dummy-ups,\
  213. Driver for multi-purpose UPS emulation))
  214. $(eval $(call DriverDescription,serial,etapro,\
  215. Driver for ETA UPS equipment))
  216. $(eval $(call DriverDescription,serial,everups,\
  217. Driver for Ever UPS models))
  218. $(eval $(call DriverDescription,serial,gamatronic,\
  219. Driver for Gamatronic UPS equipment))
  220. $(eval $(call DriverDescription,serial,genericups,\
  221. Driver for contact-closure UPS equipment))
  222. $(eval $(call DriverDescription,serial,isbmex,\
  223. Driver for ISBMEX UPS equipment))
  224. $(eval $(call DriverDescription,serial,liebert,\
  225. Driver for Liebert contact-closure UPS equipment))
  226. $(eval $(call DriverDescription,serial,liebert-esp2,\
  227. Driver for Liebert UPS, using the ESP-II serial protocol))
  228. $(eval $(call DriverDescription,serial,masterguard,\
  229. Driver for Masterguard UPS equipment))
  230. $(eval $(call DriverDescription,serial,metasys,\
  231. Driver for Meta System UPS equipment))
  232. $(eval $(call DriverDescription,serial,oldmge-shut,\
  233. Driver for SHUT Protocol UPS equipment, deprecated, use mge-shut))
  234. $(eval $(call DriverDescription,serial,mge-utalk,\
  235. Driver for MGE UPS SYSTEMS UTalk protocol equipment))
  236. $(eval $(call DriverDescription,serial,microdowell,\
  237. Driver for Microdowell Enterprise UPS series))
  238. $(eval $(call DriverDescription,serial,mge-shut,\
  239. Driver for SHUT Protocol UPS equipment))
  240. $(eval $(call DriverDescription,serial,oneac,\
  241. Driver for Oneac UPS equipment))
  242. $(eval $(call DriverDescription,serial,optiups,\
  243. Driver for Opti-UPS (Viewsonic) UPS and Zinto D (ONLINE-USV) equipment))
  244. $(eval $(call DriverDescription,serial,powercom,\
  245. Driver for serial Powercom/Trust/Advice UPS equipment))
  246. $(eval $(call DriverDescription,serial,rhino,\
  247. Driver for Brazilian Microsol RHINO UPS equipment))
  248. $(eval $(call DriverDescription,serial,safenet,\
  249. Driver for SafeNet compatible UPS equipment))
  250. $(eval $(call DriverDescription,serial,solis,\
  251. Driver for Brazilian Microsol SOLIS UPS equipment))
  252. $(eval $(call DriverDescription,serial,tripplite,\
  253. Driver for Tripp-Lite SmartPro UPS equipment))
  254. $(eval $(call DriverDescription,serial,tripplitesu,\
  255. Driver for Tripp-Lite SmartOnline (SU) UPS equipment))
  256. $(eval $(call DriverDescription,serial,upscode2,\
  257. Driver for UPScode II compatible UPS equipment))
  258. $(eval $(call DriverDescription,serial,victronups,\
  259. Driver for IMV/Victron UPS unit Match, Match Lite, NetUps))
  260. $(eval $(call DriverDescription,serial,powerpanel,\
  261. Driver for PowerPanel Plus compatible UPS equipment))
  262. $(eval $(call DriverDescription,serial,blazer_ser,\
  263. Driver for Megatec/Q1 protocol serial based UPS equipment))
  264. $(eval $(call DriverDescription,serial,clone,\
  265. UPS driver clone))
  266. $(eval $(call DriverDescription,serial,ivtscd,\
  267. Driver for the IVT Solar Controller Device))
  268. $(eval $(call DriverDescription,serial,apcsmart,\
  269. Driver for American Power Conversion Smart Protocol UPS equipment))
  270. $(eval $(call DriverDescription,serial,apcsmart-old,\
  271. Driver for American Power Conversion Smart Protocol UPS equipment))
  272. $(eval $(call DriverDescription,serial,apcupsd-ups,\
  273. Driver for apcupsd client access))
  274. $(eval $(call DriverDescription,serial,riello_ser,\
  275. Driver for Riello UPS Protocol UPS equipment))
  276. $(eval $(call DriverDescription,snmp,snmp-ups,\
  277. Multi-MIB Driver for SNMP UPS equipment))
  278. $(eval $(call DriverDescription,usb,usbhid-ups,\
  279. Driver for USB/HID UPS equipment))
  280. $(eval $(call DriverDescription,usb,bcmxcp_usb,\
  281. Experimental driver for UPSes supporting the BCM/XCP protocol over USB))
  282. $(eval $(call DriverDescription,usb,tripplite_usb,\
  283. Driver for older Tripp Lite USB UPSes (not PDC HID)))
  284. $(eval $(call DriverDescription,usb,blazer_usb,\
  285. Driver for Megatec/Q1 protocol USB based UPS equipment))
  286. $(eval $(call DriverDescription,usb,richcomm_usb,\
  287. Driver for UPS equipment using Richcomm dry-contact to USB solution))
  288. $(eval $(call DriverDescription,usb,riello_usb,\
  289. Driver for Riello UPS Protocol UPS equipment via USB))
  290. $(eval $(call DriverDescription,usb,nutdrv_atcl_usb,\
  291. Driver for ATCL FOR UPS equipment))
  292. $(eval $(call DriverDescription,usb,nutdrv_qx,\
  293. Driver for Q* protocol serial and USB based UPS equipment))
  294. CONFIGURE_ARGS += \
  295. --sysconfdir=/etc/nut \
  296. --datadir=/usr/share/nut \
  297. --with-dev \
  298. --$(if $(CONFIG_NUT_DRIVER_USB),with,without)-usb \
  299. --without-avahi \
  300. --$(if $(CONFIG_NUT_DRIVER_SNMP),with,without)-snmp \
  301. --without-neon \
  302. --without-powerman \
  303. --without-ipmi \
  304. --without-freeipmi \
  305. --$(if $(CONFIG_NUT_SSL),with,without)-ssl $(if $(CONFIG_NUT_SSL),--with-openssl) \
  306. --without-libltdl \
  307. --$(if $(CONFIG_PACKAGE_nut-web-cgi),with,without)-cgi \
  308. --with-statepath=/var/run \
  309. --with-drvpath=/lib/nut \
  310. --with-cgipath=/usr/share/www/cgi-bin/nut \
  311. --with-htmlpath=/usr/share/www/nut \
  312. --with-user=root \
  313. --with-group=root
  314. define Build/InstallDev
  315. $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib/pkgconfig
  316. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/
  317. $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
  318. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig/
  319. endef
  320. $(eval $(call BuildPackage,nut))
  321. $(eval $(call BuildPackage,nut-web-cgi))
  322. $(eval $(call BuildPackage,nut-avahi-service))
  323. $(foreach d,$(filter-out $(SERIAL_DRIVERLIST_IGNORE),$(SERIAL_DRIVERLIST)),$(eval $(call BuildPackage,nut-driver-$(d))))
  324. $(foreach d,$(SNMP_DRIVERLIST),$(eval $(call BuildPackage,nut-driver-$(d))))
  325. $(foreach d,$(USB_LIBUSB_DRIVERLIST),$(eval $(call BuildPackage,nut-driver-$(d))))