swupdate.inc 3.6 KB

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