swupdate.inc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. SUMMARY="Image updater for Yocto projects"
  2. DESCRIPTION = "Application for automatic software update from USB Pen"
  3. SECTION="swupdate"
  4. DEPENDS = "libconfig"
  5. LICENSE = "GPLv2+"
  6. LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3"
  7. inherit cml1 update-rc.d systemd pkgconfig
  8. SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=https \
  9. file://defconfig \
  10. file://swupdate \
  11. "
  12. PACKAGES =+ " \
  13. ${PN}-client \
  14. ${PN}-lua \
  15. ${PN}-progress \
  16. ${PN}-tools \
  17. ${PN}-tools-hawkbit \
  18. ${PN}-usb \
  19. ${PN}-www \
  20. "
  21. # tools is now an empty meta package for backward compatibility
  22. ALLOW_EMPTY_${PN}-tools = "1"
  23. FILES_${PN}-client = "${bindir}/swupdate-client"
  24. FILES_${PN}-lua += "${libdir}/lua/"
  25. FILES_${PN}-progress = " \
  26. ${bindir}/swupdate-progress \
  27. ${systemd_system_unitdir}/swupdate-progress.service \
  28. "
  29. FILES_${PN}-usb = " \
  30. ${sysconfdir}/udev/rules.d/swupdate-usb.rules \
  31. ${systemd_system_unitdir}/swupdate-usb@.service \
  32. "
  33. FILES_${PN}-tools-hawkbit = " \
  34. ${bindir}/swupdate-hawkbitcfg \
  35. ${bindir}/swupdate-sendtohawkbit \
  36. "
  37. FILES_${PN} += " \
  38. ${libdir}/tmpfiles.d \
  39. ${libdir}/swupdate/* \
  40. ${systemd_system_unitdir}/swupdate.socket \
  41. ${systemd_system_unitdir}/swupdate.service \
  42. ${sysconfdir}/init.d/* \
  43. "
  44. FILES_${PN}-www = " \
  45. ${libdir}/swupdate/conf.d/*mongoose* \
  46. /www/* \
  47. "
  48. RDEPENDS_${PN}-usb += "${PN}-client"
  49. # The tools package is deprecated, it is an empty meta package for backward compatibility
  50. RDEPENDS_${PN}-tools += "${PN}-client ${PN}-progress ${PN}-tools-hawkbit ${PN}-usb"
  51. S = "${WORKDIR}/git/"
  52. EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}" LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y"
  53. DEPENDS += "kern-tools-native"
  54. # returns all the elements from the src uri that are .cfg files
  55. def find_cfgs(d):
  56. return [s for s in src_patches(d, True) if s.endswith('.cfg')]
  57. python () {
  58. try:
  59. defconfig = bb.fetch2.localpath('file://defconfig', d)
  60. except bb.fetch2.FetchError:
  61. return
  62. try:
  63. configfile = open(defconfig)
  64. except IOError:
  65. return
  66. features = configfile.readlines()
  67. configfile.close()
  68. if 'CONFIG_REMOTE_HANDLER=y\n' in features:
  69. depends = d.getVar('DEPENDS', False)
  70. d.setVar('DEPENDS', depends + ' zeromq')
  71. if 'CONFIG_ENCRYPTED_IMAGES=y\n' in features or 'CONFIG_MONGOOSESSL=y\n' in features or 'CONFIG_HASH_VERIFY=y\n' in features or 'CONFIG_SURICATTA_SSL=y\n' in features:
  72. depends = d.getVar('DEPENDS', False)
  73. d.setVar('DEPENDS', depends + ' openssl')
  74. if 'CONFIG_JSON=y\n' in features:
  75. depends = d.getVar('DEPENDS', False)
  76. d.setVar('DEPENDS', depends + ' json-c')
  77. if 'CONFIG_SYSTEMD=y\n' in features:
  78. depends = d.getVar('DEPENDS', False)
  79. d.setVar('DEPENDS', depends + ' systemd')
  80. if 'CONFIG_ARCHIVE=y\n' in features:
  81. depends = d.getVar('DEPENDS', False)
  82. d.setVar('DEPENDS', depends + ' libarchive')
  83. if 'CONFIG_LUA=y\n' in features:
  84. depends = d.getVar('DEPENDS', False)
  85. d.setVar('DEPENDS', depends + ' lua')
  86. if 'CONFIG_UBOOT=y\n' in features:
  87. depends = d.getVar('DEPENDS', False)
  88. if 'CONFIG_UBOOT_NEWAPI=y\n' in features:
  89. d.setVar('DEPENDS', depends + ' libubootenv')
  90. else:
  91. d.setVar('DEPENDS', depends + ' u-boot-fw-utils')
  92. if 'CONFIG_DOWNLOAD=y\n' in features or 'CONFIG_SURICATTA=y\n' in features:
  93. depends = d.getVar('DEPENDS', False)
  94. d.setVar('DEPENDS', depends + ' curl')
  95. if 'CONFIG_MTD=y\n' in features:
  96. depends = d.getVar('DEPENDS', False)
  97. d.setVar('DEPENDS', depends + ' mtd-utils')
  98. if 'CONFIG_CFI=y\n' in features:
  99. depends = d.getVar('DEPENDS', False)
  100. d.setVar('DEPENDS', depends + ' mtd-utils')
  101. if 'CONFIG_UBIVOL=y\n' in features:
  102. depends = d.getVar('DEPENDS', False)
  103. d.setVar('DEPENDS', depends + ' mtd-utils')
  104. if 'CONFIG_UCFWHANDLER=y\n' in features:
  105. depends = d.getVar('DEPENDS', False)
  106. d.setVar('DEPENDS', depends + ' libgpiod')
  107. if 'CONFIG_SWUFORWARDER_HANDLER=y\n' in features:
  108. depends = d.getVar('DEPENDS', False)
  109. d.setVar('DEPENDS', depends + ' curl libwebsockets uriparser')
  110. if 'CONFIG_RDIFFHANDLER=y\n' in features:
  111. depends = d.getVar('DEPENDS', False)
  112. d.setVar('DEPENDS', depends + ' librsync')
  113. if 'CONFIG_MONGOOSE_WEB_API_V2=y\n' in features:
  114. d.setVar('SWUPDATE_WWW', 'webapp')
  115. if 'CONFIG_BOOTLOADER_EBG=y\n' in features:
  116. depends = d.getVar('DEPENDS', False)
  117. d.setVar('DEPENDS', depends + ' efibootguard')
  118. }
  119. do_configure () {
  120. cp ${WORKDIR}/defconfig ${S}/.config
  121. merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
  122. cml1_do_configure
  123. }
  124. do_compile() {
  125. unset LDFLAGS
  126. oe_runmake
  127. }
  128. do_install () {
  129. oe_runmake install
  130. install -m 0755 -d ${D}/www
  131. if [ -d ${S}/web-app ];then
  132. cp -R --no-dereference --preserve=mode,links -v ${S}/examples/www/v2/* ${D}/www
  133. else
  134. install -m 0755 ${S}/www/* ${D}/www
  135. fi
  136. install -d ${D}${sysconfdir}/init.d
  137. install -m 755 ${WORKDIR}/swupdate ${D}${sysconfdir}/init.d
  138. }
  139. INITSCRIPT_NAME = "swupdate"
  140. INITSCRIPT_PARAMS = "defaults 70"
  141. SYSTEMD_PACKAGES = "${PN} ${PN}-progress ${PN}-usb"
  142. SYSTEMD_SERVICE_${PN} = "swupdate.service"
  143. SYSTEMD_SERVICE_${PN}-progress = "swupdate-progress.service"
  144. SYSTEMD_SERVICE_${PN}-usb = "swupdate-usb@.service"