summaryrefslogtreecommitdiffstats
path: root/external/meta-iot-cloud/recipes-connectivity/kura/kura_4.1.0.bb
blob: 88a3a1f746af3d301b58d31824c236faafa8f303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
DESCRIPTION = "The extensible open source Java/OSGi IoT Edge Framework"
HOMEPAGE = "https://www.eclipse.org/kura/"
LICENSE = "EPL-1.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=52a21f73ac77fd790dc40dc5acda0fc2"

inherit systemd update-rc.d

DEPENDS = "\
    maven-native \
    openjdk-8-native \
    unzip-native \
"

RDEPENDS_${PN} += "java2-runtime"

SRC_URI = "\
    git://github.com/eclipse/kura.git;branch=develop;tag=KURA_${PV}_RELEASE \
"

# Patches
SRC_URI += "\
    file://Remove-default-build-profiles.patch \
    file://Add-Yocto-build-profile.patch \
    file://Fix-equinox-build.patch \
    file://Disable-checksum-generation.patch \
"

# Config
SRC_URI += "\
    file://kura.properties.default \
    file://jdk.dio.properties.default \
    file://snapshot_0.xml.default \
    file://log4j.xml.default \
"

PR = "r0"

S = "${WORKDIR}/git"
B = "${WORKDIR}/${BPN}_${PV}_yocto"

KURA_MEMSIZE ?= "1024"
KURA_PROPERTIES ?= "${WORKDIR}/kura.properties.default"
KURA_DIO_PROPERTIES ?= "${WORKDIR}/jdk.dio.properties.default"
KURA_SNAPSHOT ?= "${WORKDIR}/snapshot_0.xml.default"
KURA_LOG4J_CONFIG ?= "${WORKDIR}/log4j.xml.default"


do_configure() {
    # Config
    sed -i 's|%ARCH%|${TARGET_ARCH}|g' ${S}/kura/distrib/pom.xml
    sed -i 's|%DISTRO%|${DISTRO}-${DISTRO_VERSION}|g' ${S}/kura/distrib/pom.xml
    sed -i 's|%MACHINE%|${MACHINE}|g' ${S}/kura/distrib/pom.xml
    sed -i 's|%MEMSIZE%|${KURA_MEMSIZE}|g' ${S}/kura/distrib/pom.xml
    
    if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
        sed -i 's|%SERVICE_MANAGER%|systemd|g' ${S}/kura/distrib/pom.xml
    elif ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
        sed -i 's|%SERVICE_MANAGER%|sysv|g' ${S}/kura/distrib/pom.xml
    else
        sed -i 's|%SERVICE_MANAGER%|none|g' ${S}/kura/distrib/pom.xml
    fi
    
    # Snapshot
    sed -i 's|%MACHINE%|${MACHINE}|g' ${KURA_SNAPSHOT}
    
    # Properties
    sed -i 's|%DISTRO%|${DISTRO}|g' ${KURA_PROPERTIES}
    sed -i 's|%DISTRO_VERSION%|${DISTRO_VERSION}|g' ${KURA_PROPERTIES}
    sed -i 's|%MACHINE%|${MACHINE}|g' ${KURA_PROPERTIES}
    sed -i 's|%TARGET_SYS%|${TARGET_SYS}|g' ${KURA_PROPERTIES}
    
    # Create Yocto resources
    mkdir -p ${S}/kura/distrib/src/main/resources/yocto
    cp ${KURA_SNAPSHOT} ${S}/kura/distrib/src/main/resources/yocto/snapshot_0.xml
    cp ${KURA_DIO_PROPERTIES} ${S}/kura/distrib/src/main/resources/yocto/jdk.dio.properties
    cp ${KURA_PROPERTIES} ${S}/kura/distrib/src/main/resources/yocto/kura.properties
    cp ${KURA_LOG4J_CONFIG} ${S}/kura/distrib/src/main/resources/yocto/log4j.xml
}

do_compile() {
    export JAVA_HOME="${STAGING_LIBDIR_NATIVE}/jvm/openjdk-8-native"
    export M3_HOME="${STAGING_DIR_NATIVE}/usr/bin/maven-native"

    cd ${S}
    mvn -Dmaven.test.skip=true -f target-platform/pom.xml clean install
    mvn -Dmaven.test.skip=true -f kura/pom.xml clean install
    mvn -Dmaven.test.skip=true -f kura/distrib/pom.xml clean install

    # Populate build directory
    unzip -o ${S}/kura/distrib/target/${BPN}_${PV}_yocto.zip -d ${WORKDIR}
}

do_install() {
    install -d ${D}/${bindir}
    install -d ${D}/opt/eclipse/kura
    install -d ${D}/opt/eclipse/kura/bin
    install -d ${D}/opt/eclipse/kura/framework
    install -d ${D}/opt/eclipse/kura/plugins
    install -d ${D}/opt/eclipse/kura/user
    install -d ${D}/opt/eclipse/kura/user/snapshots
    install -d ${D}/opt/eclipse/kura/user/security
    
    # License
    install -m 0644 ${B}/*.html ${D}/opt/eclipse/kura/

    # Startup Scripts
    install -m 0755 ${B}/bin/*.sh ${D}/opt/eclipse/kura/bin
    ln -s /opt/eclipse/kura/bin/start_kura.sh ${D}${bindir}/kura

    # Framework
    install -m 0644 ${B}/framework/* ${D}/opt/eclipse/kura/framework/

    # Plugins
    install -m 0644 ${B}/plugins/*.jar ${D}/opt/eclipse/kura/plugins/

    # User
    install -m 0644 ${B}/user/log4j.xml ${D}/opt/eclipse/kura/user/
    install -m 0644 ${B}/user/kura_custom.properties ${D}/opt/eclipse/kura/user/
    install -m 0644 ${B}/user/security/cacerts.ks ${D}/opt/eclipse/kura/user/security/
    install -m 0644 ${B}/user/snapshots/*.xml ${D}/opt/eclipse/kura/user/snapshots/

    # Systemd Service
    install -d ${D}${systemd_unitdir}/system
    install -m 0644 ${B}/install/kura.service ${D}${systemd_unitdir}/system

    # Sysvinit Service
    install -d ${D}/${INIT_D_DIR}
    install -m 0755 ${B}/install/kura.init.yocto ${D}/${INIT_D_DIR}/kura

}

SYSTEMD_SERVICE_${PN} = "kura.service"
SYSTEMD_AUTO_ENABLE ?= "enable"
INITSCRIPT_PACKAGES = "${PN}"
INITSCRIPT_NAME_${PN} = "kura"

FILES_${PN} = "\
    ${bindir} \
    ${INIT_D_DIR} \
    ${systemd_unitdir}/system \
    /opt/eclipse/kura \
"