swupdate.inc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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}-progress-sd \
  17. ${PN}-sd \
  18. ${PN}-sv \
  19. ${PN}-tools \
  20. ${PN}-tools-hawkbit \
  21. ${PN}-usb \
  22. ${PN}-usb-sd \
  23. ${PN}-www \
  24. "
  25. FILES_${PN}-client = "${bindir}/swupdate-client"
  26. FILES_${PN}-lua += "${libdir}/lua/"
  27. FILES_${PN}-progress = "${bindir}/swupdate-progress"
  28. FILES_${PN}-progress-sd = "${systemd_system_unitdir}/swupdate-progress.service"
  29. FILES_${PN}-sd = " \
  30. ${systemd_system_unitdir}/swupdate.socket \
  31. ${systemd_system_unitdir}/swupdate.service \
  32. "
  33. FILES_${PN}-sv = "${sysconfdir}/init.d/*"
  34. FILES_${PN}-usb = "${sysconfdir}/udev/rules.d/swupdate-usb.rules"
  35. FILES_${PN}-usb-sd = "${systemd_system_unitdir}/swupdate-usb@.service"
  36. FILES_${PN}-tools-hawkbit = " \
  37. ${bindir}/swupdate-hawkbitcfg \
  38. ${bindir}/swupdate-sendtohawkbit \
  39. "
  40. FILES_${PN} += " \
  41. ${libdir}/tmpfiles.d \
  42. ${libdir}/swupdate/* \
  43. "
  44. FILES_${PN}-www = " \
  45. ${libdir}/swupdate/conf.d/*mongoose* \
  46. /www/* \
  47. "
  48. RDEPENDS_${PN}-progress += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'swupdate-progress-sd', '', d)}"
  49. RDEPENDS_${PN}-usb += "${PN}-client ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'swupdate-usb-sd', '', d)}"
  50. RDEPENDS_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'swupdate-sd', 'swupdate-sv', d)}"
  51. # The tools package is deprecated, it is an empty meta package for backward compatibility
  52. RDEPENDS_${PN}-tools += "${PN}-client ${PN}-progress ${PN}-tools-hawkbit ${PN}-usb"
  53. S = "${WORKDIR}/git/"
  54. EXTRA_OEMAKE += " HOSTCC="${BUILD_CC}" HOSTCXX="${BUILD_CXX}" LD="${CC}" DESTDIR="${D}" V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y"
  55. DEPENDS += "kern-tools-native"
  56. # returns all the elements from the src uri that are .cfg files
  57. def find_cfgs(d):
  58. return [s for s in src_patches(d, True) if s.endswith('.cfg')]
  59. python () {
  60. try:
  61. defconfig = bb.fetch2.localpath('file://defconfig', d)
  62. except bb.fetch2.FetchError:
  63. return
  64. try:
  65. configfile = open(defconfig)
  66. except IOError:
  67. return
  68. features = configfile.readlines()
  69. configfile.close()
  70. if 'CONFIG_REMOTE_HANDLER=y\n' in features:
  71. depends = d.getVar('DEPENDS', False)
  72. d.setVar('DEPENDS', depends + ' zeromq')
  73. 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:
  74. depends = d.getVar('DEPENDS', False)
  75. d.setVar('DEPENDS', depends + ' openssl')
  76. if 'CONFIG_JSON=y\n' in features:
  77. depends = d.getVar('DEPENDS', False)
  78. d.setVar('DEPENDS', depends + ' json-c')
  79. if 'CONFIG_SYSTEMD=y\n' in features:
  80. depends = d.getVar('DEPENDS', False)
  81. d.setVar('DEPENDS', depends + ' systemd')
  82. if 'CONFIG_ARCHIVE=y\n' in features:
  83. depends = d.getVar('DEPENDS', False)
  84. d.setVar('DEPENDS', depends + ' libarchive')
  85. if 'CONFIG_LUA=y\n' in features:
  86. depends = d.getVar('DEPENDS', False)
  87. d.setVar('DEPENDS', depends + ' lua')
  88. if 'CONFIG_UBOOT=y\n' in features:
  89. depends = d.getVar('DEPENDS', False)
  90. if 'CONFIG_UBOOT_NEWAPI=y\n' in features:
  91. d.setVar('DEPENDS', depends + ' libubootenv')
  92. else:
  93. d.setVar('DEPENDS', depends + ' u-boot-fw-utils')
  94. if 'CONFIG_DOWNLOAD=y\n' in features or 'CONFIG_SURICATTA=y\n' in features:
  95. depends = d.getVar('DEPENDS', False)
  96. d.setVar('DEPENDS', depends + ' curl')
  97. if 'CONFIG_MTD=y\n' in features:
  98. depends = d.getVar('DEPENDS', False)
  99. d.setVar('DEPENDS', depends + ' mtd-utils')
  100. if 'CONFIG_CFI=y\n' in features:
  101. depends = d.getVar('DEPENDS', False)
  102. d.setVar('DEPENDS', depends + ' mtd-utils')
  103. if 'CONFIG_UBIVOL=y\n' in features:
  104. depends = d.getVar('DEPENDS', False)
  105. d.setVar('DEPENDS', depends + ' mtd-utils')
  106. if 'CONFIG_UCFWHANDLER=y\n' in features:
  107. depends = d.getVar('DEPENDS', False)
  108. d.setVar('DEPENDS', depends + ' libgpiod')
  109. if 'CONFIG_SWUFORWARDER_HANDLER=y\n' in features:
  110. depends = d.getVar('DEPENDS', False)
  111. d.setVar('DEPENDS', depends + ' curl libwebsockets uriparser')
  112. if 'CONFIG_RDIFFHANDLER=y\n' in features:
  113. depends = d.getVar('DEPENDS', False)
  114. d.setVar('DEPENDS', depends + ' librsync')
  115. if 'CONFIG_MONGOOSE_WEB_API_V2=y\n' in features:
  116. d.setVar('SWUPDATE_WWW', 'webapp')
  117. if 'CONFIG_BOOTLOADER_EBG=y\n' in features:
  118. depends = d.getVar('DEPENDS', False)
  119. d.setVar('DEPENDS', depends + ' efibootguard')
  120. }
  121. do_configure () {
  122. # Always install systemd support and the swupdate.sh shell wrapper.
  123. # This allows to build swupdate packages init manager agnostic and splitt the file to separate packages.
  124. #grep -v 'CONFIG_SYSTEMD' ${WORKDIR}/defconfig > ${S}/.config
  125. #echo "# Global settings from swupdate recipe" >> ${S}/.config
  126. #echo "CONFIG_SYSTEMD=y" >> ${S}/.config
  127. #echo "CONFIG_SYSTEMD_SYSTEM_UNITDIR=\"${systemd_system_unitdir}\"" >> ${S}/.config
  128. cp ${WORKDIR}/defconfig ${S}/.config
  129. merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
  130. cml1_do_configure
  131. }
  132. do_compile() {
  133. unset LDFLAGS
  134. oe_runmake
  135. }
  136. do_install () {
  137. oe_runmake install
  138. install -m 0755 -d ${D}/www
  139. if [ -d ${S}/web-app ];then
  140. cp -R --no-dereference --preserve=mode,links -v ${S}/examples/www/v2/* ${D}/www
  141. else
  142. install -m 0755 ${S}/www/* ${D}/www
  143. fi
  144. install -d ${D}${sysconfdir}/init.d
  145. install -m 755 ${WORKDIR}/swupdate ${D}${sysconfdir}/init.d
  146. }
  147. INITSCRIPT_NAME = "swupdate"
  148. INITSCRIPT_PARAMS = "defaults 70"
  149. SYSTEMD_PACKAGES_append = " ${PN}-sd ${PN}-progress-sd ${PN}-usb-sd"
  150. SYSTEMD_SERVICE_${PN}-sd = "swupdate.service"
  151. SYSTEMD_SERVICE_${PN}-progress-sd = "swupdate-progress.service"
  152. SYSTEMD_SERVICE_${PN}-usb-sd = "swupdate-usb@.service"
  153. # Prevents the systemd.bbclass from deleting scripts or service files.
  154. rm_systemd_unitdir () {
  155. return 0
  156. }
  157. rm_sysvinit_initddir () {
  158. return 0
  159. }