swupdate.inc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. file://swupdate.service \
  12. file://swupdate-usb.rules \
  13. file://swupdate-usb@.service \
  14. file://swupdate-progress.service \
  15. "
  16. SRCREV = "${AUTOREV}"
  17. INSANE_SKIP_${PN} = "ldflags"
  18. PACKAGES =+ "${PN}-www"
  19. FILES_${PN}-www = "/www/*"
  20. FILES_${PN}-dev = "${includedir}"
  21. FILES_${PN}-staticdev = "${libdir}"
  22. FILES_${PN} = "${bindir}/* ${sysconfdir}"
  23. S = "${WORKDIR}/git/"
  24. EXTRA_OEMAKE += "V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y"
  25. DEPENDS += "kern-tools-native"
  26. # returns all the elements from the src uri that are .cfg files
  27. def find_cfgs(d):
  28. return [s for s in src_patches(d, True) if s.endswith('.cfg')]
  29. python () {
  30. try:
  31. defconfig = bb.fetch2.localpath('file://defconfig', d)
  32. except bb.fetch2.FetchError:
  33. return
  34. try:
  35. configfile = open(defconfig)
  36. except IOError:
  37. return
  38. features = configfile.readlines()
  39. configfile.close()
  40. if 'CONFIG_REMOTE_HANDLER=y\n' in features:
  41. depends = d.getVar('DEPENDS', False)
  42. d.setVar('DEPENDS', depends + ' zeromq')
  43. 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:
  44. depends = d.getVar('DEPENDS', False)
  45. d.setVar('DEPENDS', depends + ' openssl')
  46. if 'CONFIG_JSON=y\n' in features:
  47. depends = d.getVar('DEPENDS', False)
  48. d.setVar('DEPENDS', depends + ' json-c')
  49. if 'CONFIG_SYSTEMD=y\n' in features:
  50. depends = d.getVar('DEPENDS', False)
  51. d.setVar('DEPENDS', depends + ' systemd')
  52. if 'CONFIG_ARCHIVE=y\n' in features:
  53. depends = d.getVar('DEPENDS', False)
  54. d.setVar('DEPENDS', depends + ' libarchive')
  55. if 'CONFIG_LUA=y\n' in features:
  56. depends = d.getVar('DEPENDS', False)
  57. d.setVar('DEPENDS', depends + ' lua')
  58. if 'CONFIG_UBOOT=y\n' in features:
  59. depends = d.getVar('DEPENDS', False)
  60. d.setVar('DEPENDS', depends + ' u-boot-fw-utils')
  61. if 'CONFIG_DOWNLOAD=y\n' in features or 'CONFIG_SURICATTA=y\n' in features:
  62. depends = d.getVar('DEPENDS', False)
  63. d.setVar('DEPENDS', depends + ' curl')
  64. if 'CONFIG_MTD=y\n' in features:
  65. depends = d.getVar('DEPENDS', False)
  66. d.setVar('DEPENDS', depends + ' mtd-utils')
  67. }
  68. do_configure () {
  69. cp ${WORKDIR}/defconfig ${S}/.config
  70. merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
  71. cml1_do_configure
  72. }
  73. do_compile() {
  74. unset LDFLAGS
  75. oe_runmake swupdate_unstripped progress_unstripped
  76. cp swupdate_unstripped swupdate
  77. cp progress_unstripped progress
  78. }
  79. do_install () {
  80. install -d ${D}${bindir}/
  81. install -m 0755 swupdate ${D}${bindir}/
  82. install -m 0755 -d ${D}/www
  83. install -m 0755 ${S}www/* ${D}/www
  84. install -d ${D}${libdir}/
  85. install -d ${D}${includedir}/
  86. install -m 0644 ${S}include/network_ipc.h ${D}${includedir}
  87. install -m 0644 ${S}include/swupdate_status.h ${D}${includedir}
  88. install -m 0644 ${S}include/progress.h ${D}${includedir}
  89. install -m 0755 ${S}ipc/lib.a ${D}${libdir}/libswupdate.a
  90. install -d ${D}${sysconfdir}/init.d
  91. install -m 755 ${WORKDIR}/swupdate ${D}${sysconfdir}/init.d
  92. install -d ${D}${systemd_unitdir}/system
  93. install -m 644 ${WORKDIR}/swupdate.service ${D}${systemd_unitdir}/system
  94. install -m 644 ${WORKDIR}/swupdate-usb@.service ${D}${systemd_unitdir}/system
  95. install -m 644 ${WORKDIR}/swupdate-progress.service ${D}${systemd_unitdir}/system
  96. if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
  97. install -d ${D}${sysconfdir}/udev/rules.d
  98. install -m 0644 ${WORKDIR}/swupdate-usb.rules ${D}${sysconfdir}/udev/rules.d/
  99. fi
  100. }
  101. INITSCRIPT_NAME = "swupdate"
  102. INITSCRIPT_PARAMS = "defaults 70"
  103. SYSTEMD_SERVICE_${PN} = "swupdate.service"
  104. SYSTEMD_SERVICE_${PN} += "swupdate-usb@.service swupdate-progress.service"