Skip to content

Commit

Permalink
NC | Online Upgrade | RPM spec changes
Browse files Browse the repository at this point in the history
Signed-off-by: Romy <[email protected]>
  • Loading branch information
romayalon committed Nov 10, 2024
1 parent fc266c3 commit a237086
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/deploy/RPM_build/noobaa.spec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

%define noobaatar %{name}-%{version}-%{revision}.tar.gz
%define buildroot %{_tmppath}/%{name}-%{version}-%{release}
%global noobaa_core_version_path .noobaa-core-%{noobaaver}

Name: noobaa-core
Version: %{noobaaver}
Expand All @@ -39,6 +40,10 @@ Recommends: jemalloc
%description
NooBaa is a data service for cloud environments, providing S3 object-store interface with flexible tiering, mirroring, and spread placement policies, over any storage resource that allows GET/PUT including S3, GCS, Azure Blob, Filesystems, etc.

%pre
# Get the current installed version of the package
current_version=$(rpm -q --qf '%{VERSION}-%{RELEASE}' noobaa 2>/dev/null || echo "")

%prep
%setup -n noobaa -q

Expand Down Expand Up @@ -69,38 +74,45 @@ GYP_DEFINES="BUILD_S3SELECT=%{BUILD_S3SELECT} BUILD_S3SELECT_PARQUET=%{BUILD_S3S
rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT/usr/local/
cp -R %{_builddir}/noobaa $RPM_BUILD_ROOT/usr/local/noobaa-core
mv %{_builddir}/node/* $RPM_BUILD_ROOT/usr/local/noobaa-core/node
cp -R %{_builddir}/noobaa $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}
mv %{_builddir}/node/* $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/node

mkdir -p $RPM_BUILD_ROOT/usr/local/noobaa-core/bin
ln -s /usr/local/noobaa-core/node/bin/node $RPM_BUILD_ROOT/usr/local/noobaa-core/bin/node
ln -s /usr/local/noobaa-core/node/bin/npm $RPM_BUILD_ROOT/usr/local/noobaa-core/bin/npm
ln -s /usr/local/noobaa-core/node/bin/npx $RPM_BUILD_ROOT/usr/local/noobaa-core/bin/npx
mkdir -p $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/bin
ln -s /usr/local/%{noobaa_core_version_path}/node/bin/node $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/bin/node
ln -s /usr/local/%{noobaa_core_version_path}/node/bin/npm $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/bin/npm
ln -s /usr/local/%{noobaa_core_version_path}/node/bin/npx $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/bin/npx

mkdir -p $RPM_BUILD_ROOT/usr/local/bin/
chmod +x $RPM_BUILD_ROOT/usr/local/noobaa-core/src/deploy/noobaa-cli
cp $RPM_BUILD_ROOT/usr/local/noobaa-core/src/deploy/noobaa-cli $RPM_BUILD_ROOT/usr/local/bin/noobaa-cli
chmod +x $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/src/deploy/noobaa-cli
cp $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/src/deploy/noobaa-cli $RPM_BUILD_ROOT/usr/local/bin/.noobaa-cli-%{noobaaver}

mkdir -p $RPM_BUILD_ROOT%{_unitdir}/
mv $RPM_BUILD_ROOT/usr/local/noobaa-core/src/deploy/noobaa.service $RPM_BUILD_ROOT%{_unitdir}/noobaa.service
mv $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/src/deploy/noobaa.service $RPM_BUILD_ROOT%{_unitdir}/noobaa.service
mkdir -p $RPM_BUILD_ROOT/etc/noobaa.conf.d/

mkdir -p $RPM_BUILD_ROOT/etc/rsyslog.d/
mv $RPM_BUILD_ROOT/usr/local/noobaa-core/src/deploy/standalone/noobaa_syslog.conf $RPM_BUILD_ROOT/etc/rsyslog.d/noobaa_syslog.conf
mv $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/src/deploy/standalone/noobaa_syslog.conf $RPM_BUILD_ROOT/etc/rsyslog.d/noobaa_syslog.conf

mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
mv $RPM_BUILD_ROOT/usr/local/noobaa-core/src/deploy/standalone/noobaa-logrotate $RPM_BUILD_ROOT/etc/logrotate.d/noobaa-logrotate
mv $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path}/src/deploy/standalone/noobaa-logrotate $RPM_BUILD_ROOT/etc/logrotate.d/noobaa-logrotate

%files
/usr/local/noobaa-core
/usr/local/%{noobaa_core_version_path}
%{_unitdir}/noobaa.service
%config(noreplace) /etc/logrotate.d/noobaa-logrotate
%config(noreplace) /etc/rsyslog.d/noobaa_syslog.conf
/etc/noobaa.conf.d/
/usr/local/bin/noobaa-cli
/usr/local/bin/.noobaa-cli-%{noobaaver}
%doc

%post
if [ -n "$current_version" ]; then
mv $RPM_BUILD_ROOT/usr/local/noobaa-core $RPM_BUILD_ROOT/usr/local/.noobaa-core-%{current_version}
mv $RPM_BUILD_ROOT/usr/local/bin/noobaa-cli $RPM_BUILD_ROOT/usr/local/bin/.noobaa-cli-%{current_version}
fi
mv $RPM_BUILD_ROOT/usr/local/%{noobaa_core_version_path} $RPM_BUILD_ROOT/usr/local/noobaa-core
mv $RPM_BUILD_ROOT/usr/local/bin/.noobaa-cli-%{noobaaver} $RPM_BUILD_ROOT/usr/local/bin/noobaa-cli

state=$(systemctl show -p ActiveState --value rsyslog)
if [ "${state}" == "active" ]; then
service rsyslog restart
Expand Down
30 changes: 30 additions & 0 deletions src/test/unit_tests/test_rpm_install.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright (C) 2016 NooBaa */
'use strict';

const mocha = require('mocha');
const os_utils = require('../../util/os_utils');

mocha.describe('rpm install tests', function() {
mocha.it(async () => {
const make_rpm_command = `sudo make rpm BUILD_S3SELECT=0`;
await exec(make_rpm_command);
const get_noobaa_rpm_path_command = `noobaa_pkg=$(ls ./build/rpm/ | grep noobaa | grep .x86_64.rpm)`;
await exec(get_noobaa_rpm_path_command);
const install_boost_deps = `sudo apt-get update && sudo apt-get install -y libboost-system-dev libboost-thread-dev`;
await exec(install_boost_deps);
const install_rpm_command = `rpm -i "./build/rpm/$noobaa_pkg"`;
await exec(install_rpm_command);
});
});

async function exec(command) {
try {
const res = await os_utils.exec(command, {
return_stdout: true
});
return res;
} catch (err) {
console.error('test_rpm_install.error', err);
throw err;
}
}

0 comments on commit a237086

Please sign in to comment.