diff --git a/make_rpm b/make_rpm index 45bc71e..7bdd920 100755 --- a/make_rpm +++ b/make_rpm @@ -21,15 +21,17 @@ set -e -PKG_ROOT=`pwd` # The script must be executed from the root git directory +PKG_ROOT=$(pwd) # The script must be executed from the root git directory repo_name="fledge" # Name of the Git repository branch="main" # Default Git branch to use pkg_name="fledge" # Name of the package to build architecture="x86_64" # The architecture for which the rpm should be created -rhpg_pkg="rh-postgresql13" # Name of the Red Hat package for postgres -rhgcc_pkg="devtoolset-7" # Name of the Red Hat package for the newer g++ skip_build=0 # 1=skip Git repo extraction and Fledge build +# Check OS Name and OS Version +os_name=$(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g') +os_version=$(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g') + usage="$(basename "$0") [-h] [-c] [-a] [-s] [-b ] This script is used to create the RPM package of Fledge @@ -121,27 +123,31 @@ if [[ $skip_build == 0 ]]; then cd ${FLEDGE_ROOT} sudo ./requirements.sh + # Use Red Hat packages and scl_source for postgres and newer g++ only if OS is RedHat/CentOS 7 + if [[ ( $os_name == *"Red Hat"* || $os_name == *"CentOS"* ) && $os_version == *"7"* ]] + then + rhpg_pkg="rh-postgresql13" # Name of the Red Hat package for postgres + rhgcc_pkg="devtoolset-7" # Name of the Red Hat package for the newer g++ + + # Enables/verifies the environment for the build + source scl_source enable ${rhpg_pkg} + status_rh_postgresql=$? + if [[ $status_rh_postgresql != 0 ]]; then + echo "ERROR : it is not possible to enable the ${rhpg_pkg} environment" + exit 1 + fi - # Enables/verifies the environment for the build - source scl_source enable ${rhpg_pkg} - status_rh_postgresql=$? - - source scl_source enable ${rhgcc_pkg} - status_devtoolset=$? + source scl_source enable ${rhgcc_pkg} + status_devtoolset=$? + if [[ $status_devtoolset != 0 ]]; then + echo "ERROR : it is not possible to enable the ${rhgcc_pkg} environment" + exit 1 + fi + fi command -v pg_isready > /dev/null status_pg_isready=$? - if [[ $status_rh_postgresql != 0 ]]; then - echo "ERROR : it is not possible to enable the ${rhpg_pkg} environment" - exit 1 - fi - - if [[ $status_devtoolset != 0 ]]; then - echo "ERROR : it is not possible to enable the ${rhgcc_pkg} environment" - exit 1 - fi - if [[ $status_pg_isready != 0 ]]; then echo "ERROR : the command pg_isready is not available" exit 1 diff --git a/others/scripts/gcp/VERSION b/others/scripts/gcp/VERSION index a10cd17..e8d1050 100644 --- a/others/scripts/gcp/VERSION +++ b/others/scripts/gcp/VERSION @@ -1,2 +1,2 @@ -fledge_gcp_version=2.0.1 -fledge_version>=2.0 +fledge_gcp_version=2.1.0 +fledge_version>=2.1 diff --git a/others/scripts/iec/VERSION b/others/scripts/iec/VERSION index d3b4399..75eb1d4 100644 --- a/others/scripts/iec/VERSION +++ b/others/scripts/iec/VERSION @@ -1,2 +1,2 @@ -fledge_iec_version=2.0.1 -fledge_version>=2.0 +fledge_iec_version=2.1.0 +fledge_version>=2.1 diff --git a/others/scripts/mqtt/VERSION b/others/scripts/mqtt/VERSION index b4a1dac..3881f49 100644 --- a/others/scripts/mqtt/VERSION +++ b/others/scripts/mqtt/VERSION @@ -1,2 +1,2 @@ -fledge_mqtt_version=2.0.1 -fledge_version>=2.0 +fledge_mqtt_version=2.1.0 +fledge_version>=2.1 diff --git a/others/scripts/s2opcua/VERSION b/others/scripts/s2opcua/VERSION index 2445dbd..f6a43d9 100644 --- a/others/scripts/s2opcua/VERSION +++ b/others/scripts/s2opcua/VERSION @@ -1,2 +1,2 @@ -fledge_s2opcua_version=2.0.1 -fledge_version>=2.0 +fledge_s2opcua_version=2.1.0 +fledge_version>=2.1 diff --git a/packages/RPM/SPECS/fledge.spec b/packages/RPM/SPECS/fledge.spec index 18768b1..c8ccaaa 100644 --- a/packages/RPM/SPECS/fledge.spec +++ b/packages/RPM/SPECS/fledge.spec @@ -15,7 +15,11 @@ VCS: __VCS__ %define install_path /usr/local Prefix: /usr/local +%if 0%{?centos} < 9 || 0%{?rhel} < 9 Requires: dbus-devel, glib2-devel, boost, openssl, rh-python36, yum-utils, gcc, autoconf, curl, libtool, rsyslog, wget, zlib, libuuid, avahi, sudo, krb5-workstation, curl-devel +%else +Requires: dbus-devel, glib2-devel, boost, openssl, python3, yum-utils, gcc, autoconf, curl, libtool, rsyslog, wget, zlib, libuuid, avahi, sudo, krb5-workstation, curl-devel +%endif AutoReqProv: no %description @@ -211,6 +215,7 @@ fi set -e PKG_NAME="fledge" +OS_VERSION=$(cat /etc/os-release | grep 'VERSION_ID=' | cut -f2 -d= | sed 's/"//g') get_fledge_script () { fledge_script=$(rpm -ql ${PKG_NAME} | grep 'fledge/bin/fledge$') @@ -324,7 +329,12 @@ copy_fledge_sudoer_file() { } copy_service_file() { - cp /usr/local/fledge/extras/scripts/fledge.service /etc/init.d/fledge + if [[ ${OS_VERSION} == *"7"* ]] + then + cp /usr/local/fledge/extras/scripts/fledge.service /etc/init.d/fledge + else + cp /usr/local/fledge/extras/scripts/fledge.service /etc/rc.d/init.d/fledge + fi } enable_fledge_service() { @@ -400,14 +410,24 @@ install_pip3_packages () { then echo "# " >> /home/${SUDO_USER}/.bashrc echo "# ${foglam_test}" >> /home/${SUDO_USER}/.bashrc - echo "source scl_source enable rh-python36" >> /home/${SUDO_USER}/.bashrc + if [[ ${OS_VERSION} == *"7"* ]] + then + echo "source scl_source enable rh-python36" >> /home/${SUDO_USER}/.bashrc + fi + fi + if [[ ${OS_VERSION} == *"7"* ]] + then + source scl_source enable rh-python36 fi - source scl_source enable rh-python36 # TODO: we may need with --no-cache-dir - pip3 install -Ir /usr/local/fledge/python/requirements.txt - - sudo bash -c 'source scl_source enable rh-python36; python3 -m pip install dbus-python numpy==1.19.5' + python3 -m pip install -Ir /usr/local/fledge/python/requirements.txt + if [[ ${OS_VERSION} == *"7"* ]] + then + sudo bash -c 'source scl_source enable rh-python36; python3 -m pip install dbus-python numpy==1.19.5' + else + sudo bash -c 'python3 -m pip install dbus-python numpy==1.19.5' + fi set -e } diff --git a/plugins/make_deb b/plugins/make_deb index b69d992..4e1c654 100755 --- a/plugins/make_deb +++ b/plugins/make_deb @@ -244,6 +244,8 @@ EOF if [ -f requirements.sh ]; then ./requirements.sh fi + # version replaced in VERSION file + echo ${version} > VERSION; mkdir -p build; cd build; cmake ..; make) mkdir -p "plugins/${plugin_type_install}/${plugin_install_dirname}" if [ -f "${GIT_ROOT}/extras_install.sh" ]; then diff --git a/plugins/make_rpm b/plugins/make_rpm index a4b0cf4..0505629 100755 --- a/plugins/make_rpm +++ b/plugins/make_rpm @@ -253,6 +253,8 @@ EOF if [ -f requirements.sh ]; then ./requirements.sh fi + # version replaced in VERSION file + echo ${version} > VERSION; if [ -f build.sh ]; then ./build.sh else diff --git a/plugins/packages/DEBIAN/postinst b/plugins/packages/DEBIAN/postinst index e593f1a..fe41a56 100755 --- a/plugins/packages/DEBIAN/postinst +++ b/plugins/packages/DEBIAN/postinst @@ -41,7 +41,7 @@ if [ -f /usr/local/fledge/python/extras_install___PLUGIN_NAME__.sh ]; then fi # Install Python pip dependencies; if any if [ -f /usr/local/fledge/__INSTALL_DIR__/requirements.txt ]; then - pip3 install -Ir /usr/local/fledge/__INSTALL_DIR__/requirements.txt + python3 -m pip install -Ir /usr/local/fledge/__INSTALL_DIR__/requirements.txt fi # For C based plugins