Skip to content

Commit

Permalink
feat(distrib): added generic x86_64 profile (#4451)
Browse files Browse the repository at this point in the history
* feat(distrib): addded generic x86_64 profile

Signed-off-by: Marcello Martina <[email protected]>

* fix: corrected property in kura.properties

Signed-off-by: Marcello Martina <[email protected]>

---------

Signed-off-by: Marcello Martina <[email protected]>
  • Loading branch information
marcellorinaldo authored Mar 15, 2023
1 parent 43bafac commit 0ba65f0
Show file tree
Hide file tree
Showing 12 changed files with 927 additions and 0 deletions.
99 changes: 99 additions & 0 deletions kura/distrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,105 @@
</build>
</profile>

<profile>
<id>generic-x86_64</id>
<activation>
<property>
<name>buildAll</name>
</property>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create-timestamp</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>generic-x86_64-jars</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="buildNumber" value="buildNumber" />
<property name="project.version" value="${project.version}" />
<property name="project.build.profile" value="${project.build.profile}" />
<property name="project.build.directory" value="${project.build.directory}" />
<property name="build.name" value="generic-x86_64" />
<property name="target.device" value="generic-x86_64" />
<property name="native.tag" value="x86_64" />
<property name="kura.os.version" value="raspbian" />
<property name="kura.arch" value="x86_64" />
<property name="service.manager" value="systemd" />
<property name="os.base" value="debian" />
<property name="kura.mem.size" value="512m" />
<property name="kura.install.dir" value="/opt/eclipse" />
<property name="network.provider" value="network-manager" />
<ant antfile="${basedir}/src/main/ant/build_equinox_distrib.xml" target="dist-linux" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.vafer</groupId>
<artifactId>jdeb</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>generic-x86_64-deb</id>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<verbose>true</verbose>
<deb>${basedir}/target/kura_${project.version}_generic-x86_64_installer.deb</deb>
<controlDir>${basedir}/src/main/resources/generic-x86_64/deb/control</controlDir>
<dataSet>
<data>
<src>${basedir}/target/kura_${project.version}_generic-x86_64.zip</src>
<type>file</type>
<mapper>
<type>perm</type>
<prefix>/tmp</prefix>
</mapper>
</data>
<data>
<src>${project.basedir}/src/main/resources/common/99kura-nm.conf</src>
<dst>/etc/NetworkManager/conf.d/99kura-nm.conf</dst>
<type>file</type>
</data>
</dataSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>generic-aarch64</id>
<activation>
Expand Down
30 changes: 30 additions & 0 deletions kura/distrib/src/main/resources/generic-x86_64/deb/control/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Copyright (c) 2023 Eurotech and/or its affiliates and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eurotech
#
Package: kura
Version: [[project.version]]
Section: misc
Priority: low
Depends: openjdk-8-jre-headless | temurin-8-jdk | openjdk-17-jre-headless | temurin-17-jdk,
network-manager, bind9, isc-dhcp-server, iw,
bluez, bluez-hcidump,
iptables,
chrony, ntpdate, cron,
telnet, dos2unix, unzip
Recommends: python3
Architecture: all
Maintainer: [email protected]
Description: Kura is an inclusive software framework that puts a layer
between the operating system and the customer application, with industry
standard interfaces that shorten custom development time, simplified coding
and software that can be easily ported from one hardware platform
to another.
101 changes: 101 additions & 0 deletions kura/distrib/src/main/resources/generic-x86_64/deb/control/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/bin/bash
#
# Copyright (c) 2023 Eurotech and/or its affiliates and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eurotech
#

INSTALL_DIR=/opt/eclipse
TIMESTAMP=`date +%Y%m%d%H%M%S`
LOG=/tmp/kura_install_${TIMESTAMP}.log
WD_TMP_FILE=/tmp/watchdog
REFRESH_TIME=5
TIMEOUT_TIME=300

##############################################
# UTILITY FUNCTIONS
##############################################
# Run postInstall function and start watchdog if needed
function runPostInstall {
if [ -f "${WD_TMP_FILE}" ]; then
WATCHDOG_DEVICE=`cat ${WD_TMP_FILE}`
echo "Got watchdog ${WATCHDOG_DEVICE}" >> $LOG 2>&1
postInstall &
PID=$!
START=$(date +%s)

while [ -d "/proc/$PID" ]; do
echo w > ${WATCHDOG_DEVICE}
DELTA=$(($(date +%s) - $START))
if [ "$DELTA" -ge "$TIMEOUT_TIME" ]; then
echo "The installation process is not responding. It'll be stopped."
kill -9 $PID >> /dev/null 2>&1
fi
sleep $REFRESH_TIME
done
stopWatchdog
else
postInstall &
PID=$!
START=$(date +%s)

while [ -d "/proc/$PID" ]; do
DELTA=$(($(date +%s) - $START))
if [ "$DELTA" -ge "$TIMEOUT_TIME" ]; then
echo "The installation process is not responding. It'll be stopped."
kill -9 $PID >> /dev/null 2>&1
fi
sleep $REFRESH_TIME
done
fi
}

# Deactivate watchdog device if possible
function stopWatchdog {
if [ -n "${WATCHDOG_DEVICE}" ]; then
echo V > ${WATCHDOG_DEVICE}
fi
}

# Pre-install script
function postInstall {
mkdir -p ${INSTALL_DIR} >> ${LOG} 2>&1
unzip /tmp/kura_*.zip -d ${INSTALL_DIR} >> ${LOG} 2>&1

#install KURA files
sh ${INSTALL_DIR}/kura_*/install/kura_install.sh >> ${LOG} 2>&1

#clean up
rm -rf ${INSTALL_DIR}/kura/install >> ${LOG} 2>&1
rm /tmp/kura_*.zip >> ${LOG} 2>&1

#move the log file
mkdir -p ${INSTALL_DIR}/kura/log
mv ${LOG} ${INSTALL_DIR}/kura/log/

#flush all cached filesystem to disk
sync

echo ""
echo "Finished. KURA has been installed to ${INSTALL_DIR}/kura and will start automatically after a reboot"
}
##############################################
# END UTILITY FUNCTIONS
##############################################

##############################################
# POST INSTALL SCRIPT
##############################################
runPostInstall
exit 0
#############################################
# END POST INSTALL SCRIPT
##############################################

106 changes: 106 additions & 0 deletions kura/distrib/src/main/resources/generic-x86_64/deb/control/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/bash
#
# Copyright (c) 2023 Eurotech and/or its affiliates and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Eurotech
#

INSTALL_DIR=/opt/eclipse
WD_TMP_FILE=/tmp/watchdog
REFRESH_TIME=5
TIMEOUT_TIME=300

##############################################
# UTILITY FUNCTIONS
##############################################
# Run preInstall function and start watchdog if needed
function runPreInstall {
if [ -f "${WD_TMP_FILE}" ]; then
WATCHDOG_DEVICE=`cat ${WD_TMP_FILE}`
preInstall &
PID=$!
START=$(date +%s)

while [ -d "/proc/$PID" ]; do
echo w > ${WATCHDOG_DEVICE}
DELTA=$(($(date +%s) - $START))
if [ "$DELTA" -ge "$TIMEOUT_TIME" ]; then
echo "The installation process is not responding. It'll be stopped."
kill -9 $PID >> /dev/null 2>&1
fi
sleep $REFRESH_TIME
done
stopWatchdog
else
preInstall &
PID=$!
START=$(date +%s)

while [ -d "/proc/$PID" ]; do
DELTA=$(($(date +%s) - $START))
if [ "$DELTA" -ge "$TIMEOUT_TIME" ]; then
echo "The installation process is not responding. It'll be stopped."
kill -9 $PID >> /dev/null 2>&1
fi
sleep $REFRESH_TIME
done
fi
}

# Deactivate watchdog device if possible
function stopWatchdog {
if [ -n "${WATCHDOG_DEVICE}" ]; then
echo V > ${WATCHDOG_DEVICE}
fi
}

# Pre-install script
function preInstall {
#clean up old installation if present
rm -fr /opt/eclipse/kura* >> /tmp/kura_install.log 2>&1
rm -fr ${INSTALL_DIR}/kura* >> /tmp/kura_install.log 2>&1
rm -fr /tmp/.kura/ >> /tmp/kura_install.log 2>&1
rm /etc/init.d/firewall >> /tmp/kura_install.log 2>&1
rm /tmp/coninfo-* >> /tmp/kura_install.log 2>&1
rm /var/log/kura.log >> /tmp/kura_install.log 2>&1
rm -f kura-*.zip >> /tmp/kura_install.log 2>&1
rm -f kura_*.zip >> /tmp/kura_install.log 2>&1
echo ""
}
##############################################
# END UTILITY FUNCTIONS
##############################################

##############################################
# PRE-INSTALL SCRIPT
##############################################
PIDS=`pgrep java`

echo ""
echo "Installing Kura..."
echo "Installing Kura..." > /tmp/kura_install.log 2>&1

#Kill JVM and monit for installation
if [ -f "/var/run/kura.pid" ] ; then
KURA_PID=`cat /var/run/kura.pid`

for pid in "${PIDS[@]}"
do
if [ "$KURA_PID" == "$pid" ] ; then
`kill $pid` >> /tmp/kura_install.log 2>&1
fi
done
fi

runPreInstall
##############################################
# END PRE-INSTALL SCRIPT
##############################################

Loading

0 comments on commit 0ba65f0

Please sign in to comment.