replace hardcoded system paths by variables in stx config files

1. for centos, use @SYSCONFDIR@ to represent %{_sysconfdir} which
is determined in spec file and could be different in different Linux.

2. use @PYTHONROOT@ to represent the actual %{pythonroot} which is
determined in spec file or other packaging file. For example, for
python2.7, %{pythonroot} could be "/usr/lib64/python2.7/site-packages"
or "/usr/lib64/python3.x/site-packages" for python3.x respectively.

3. test method:
  1). run "build-pkgs" and "build-iso", and then check src RPM
  "nfv-1.0-75.tis.src.rpm" in which related scripts are correctly set
  with @SYSCONFDIR@ and @PYTHONROOT@. Also check CentOS binary RPM
  "nfv-vim-1.0-75.tis.x86_64.rpm" to assure @SYSCONFDIR@ is correctly
  replaced by "/etc" for CentOS and "@PYTHON@" is actually updated to
  "/usr/lib64/python2.7/site-packages/" for python2.7.
  2). use the newly built iso, install StarlingX system on virtual or
  bare metal, and check basic functionalities.

Story: 2004039
Task: 27043

Depends-On: https://review.openstack.org/#/c/611725/

Change-Id: Ie6e05d24a476fe2977f1003d23f747f5a0b779a3
Signed-off-by: Yong Hu <yong.hu@intel.com>
This commit is contained in:
Yong Hu 2018-10-22 04:56:26 +00:00
parent fce17d8115
commit 45dfb5417c
5 changed files with 42 additions and 34 deletions

View File

@ -74,6 +74,14 @@ Network Function Virtualization Client
%prep
%setup
# use actual value of %{_sysconfdir} to repace @SYSCONFDIR@ in config files
# use actual value of %{pythonroot} to replace @PYTHONROOT@ in config.ini.
sed -i -e 's|@SYSCONFDIR@|%{_sysconfdir}|g' nfv-vim/scripts/vim
sed -i -e 's|@SYSCONFDIR@|%{_sysconfdir}|g' nfv-vim/scripts/vim-api
sed -i -e 's|@SYSCONFDIR@|%{_sysconfdir}|g' nfv-vim/scripts/vim-webserver
sed -i -e 's|@SYSCONFDIR@|%{_sysconfdir}|g' nfv-vim/nfv_vim/config.ini
sed -i -e 's|@PYTHONROOT@|%{pythonroot}|g' nfv-vim/nfv_vim/config.ini
%build
%build_python nfv-common
%build_python nfv-plugins
@ -93,26 +101,26 @@ install -d -m 755 %{buildroot}%{_sysconfdir}/bash_completion.d
install -m 444 nfv-client/scripts/sw-manager.completion %{buildroot}%{_sysconfdir}/bash_completion.d/sw-manager
# nfv-plugins
install -d -m 755 %{buildroot}/etc/nfv/
install -d -m 755 %{buildroot}/etc/nfv/nfv_plugins/
install -d -m 755 %{buildroot}/etc/nfv/nfv_plugins/alarm_handlers/
install -p -D -m 600 nfv-plugins/nfv_plugins/alarm_handlers/config.ini %{buildroot}/etc/nfv/nfv_plugins/alarm_handlers/config.ini
install -d -m 755 %{buildroot}/etc/nfv/nfv_plugins/event_log_handlers/
install -p -D -m 600 nfv-plugins/nfv_plugins/event_log_handlers/config.ini %{buildroot}/etc/nfv/nfv_plugins/event_log_handlers/config.ini
install -d -m 755 %{buildroot}/etc/nfv/nfv_plugins/nfvi_plugins/
install -p -D -m 600 nfv-plugins/nfv_plugins/nfvi_plugins/config.ini %{buildroot}/etc/nfv/nfv_plugins/nfvi_plugins/config.ini
install -d -m 755 %{buildroot}/%{_sysconfdir}/nfv/
install -d -m 755 %{buildroot}/%{_sysconfdir}/nfv/nfv_plugins/
install -d -m 755 %{buildroot}/%{_sysconfdir}/nfv/nfv_plugins/alarm_handlers/
install -p -D -m 600 nfv-plugins/nfv_plugins/alarm_handlers/config.ini %{buildroot}/%{_sysconfdir}/nfv/nfv_plugins/alarm_handlers/config.ini
install -d -m 755 %{buildroot}/%{_sysconfdir}/nfv/nfv_plugins/event_log_handlers/
install -p -D -m 600 nfv-plugins/nfv_plugins/event_log_handlers/config.ini %{buildroot}/%{_sysconfdir}/nfv/nfv_plugins/event_log_handlers/config.ini
install -d -m 755 %{buildroot}/%{_sysconfdir}/nfv/nfv_plugins/nfvi_plugins/
install -p -D -m 600 nfv-plugins/nfv_plugins/nfvi_plugins/config.ini %{buildroot}/%{_sysconfdir}/nfv/nfv_plugins/nfvi_plugins/config.ini
install -d -m 755 %{buildroot}/
install -p -D -m 644 nfv-plugins/scripts/nfvi-plugins.logrotate %{buildroot}/etc/logrotate.d/nfvi-plugins.logrotate
install -p -D -m 644 nfv-plugins/scripts/nfvi-plugins.logrotate %{buildroot}/%{_sysconfdir}/logrotate.d/nfvi-plugins.logrotate
# nfv-vim
install -d -m 755 %{buildroot}/usr/lib/ocf/resource.d/nfv
install -p -D -m 755 nfv-vim/scripts/vim %{buildroot}/usr/lib/ocf/resource.d/nfv/vim
install -p -D -m 755 nfv-vim/scripts/vim-api %{buildroot}/usr/lib/ocf/resource.d/nfv/vim-api
install -p -D -m 755 nfv-vim/scripts/vim-webserver %{buildroot}/usr/lib/ocf/resource.d/nfv/vim-webserver
install -d -m 755 %{buildroot}/etc/nfv/
install -d -m 755 %{buildroot}/etc/nfv/vim/
install -p -D -m 600 nfv-vim/nfv_vim/config.ini %{buildroot}/etc/nfv/vim/config.ini
install -p -D -m 600 nfv-vim/nfv_vim/debug.ini %{buildroot}/etc/nfv/vim/debug.ini
install -d -m 755 %{buildroot}/%{_sysconfdir}/nfv/
install -d -m 755 %{buildroot}/%{_sysconfdir}/nfv/vim/
install -p -D -m 600 nfv-vim/nfv_vim/config.ini %{buildroot}/%{_sysconfdir}/nfv/vim/config.ini
install -p -D -m 600 nfv-vim/nfv_vim/debug.ini %{buildroot}/%{_sysconfdir}/nfv/vim/debug.ini
%post -n nfv-common
@ -135,13 +143,13 @@ rm -rf $RPM_BUILD_ROOT
%files -n nfv-plugins
%defattr(-,root,root,-)
%doc nfv-plugins/LICENSE
%dir /etc/logrotate.d/
/etc/logrotate.d/nfvi-plugins.logrotate
%dir /etc/nfv/nfv_plugins/
%config(noreplace)/etc/nfv/nfv_plugins/alarm_handlers/config.ini
%config(noreplace)/etc/nfv/nfv_plugins/event_log_handlers/config.ini
%config(noreplace)/etc/nfv/nfv_plugins/nfvi_plugins/config.ini
/etc/nfv/nfv_plugins/*
%dir %{_sysconfdir}/logrotate.d/
%{_sysconfdir}/logrotate.d/nfvi-plugins.logrotate
%dir %{_sysconfdir}/nfv/nfv_plugins/
%config(noreplace)/%{_sysconfdir}/nfv/nfv_plugins/alarm_handlers/config.ini
%config(noreplace)/%{_sysconfdir}/nfv/nfv_plugins/event_log_handlers/config.ini
%config(noreplace)/%{_sysconfdir}/nfv/nfv_plugins/nfvi_plugins/config.ini
%{_sysconfdir}/nfv/nfv_plugins/*
%dir %{pythonroot}/nfv_plugins/
%{pythonroot}/nfv_plugins/*
%dir %{pythonroot}/windriver_nfv_plugins-%{version}.0-py2.7.egg-info
@ -164,9 +172,9 @@ rm -rf $RPM_BUILD_ROOT
%{local_bindir}/nfv-vim-api
%{local_bindir}/nfv-vim-manage
%{local_bindir}/nfv-vim-webserver
%dir /etc/nfv/vim/
%config(noreplace)/etc/nfv/vim/config.ini
%config(noreplace)/etc/nfv/vim/debug.ini
%dir %{_sysconfdir}/nfv/vim/
%config(noreplace)/%{_sysconfdir}/nfv/vim/config.ini
%config(noreplace)/%{_sysconfdir}/nfv/vim/debug.ini
%dir /usr/lib/ocf/resource.d/nfv/
/usr/lib/ocf/resource.d/nfv/vim
/usr/lib/ocf/resource.d/nfv/vim-api

View File

@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
#
[debug]
config_file=/etc/nfv/vim/debug.ini
config_file=@SYSCONFDIR@/nfv/vim/debug.ini
handlers=syslog, stdout
syslog_address=/dev/log
syslog_facility=user
@ -16,16 +16,16 @@ database_dir=/var/lib/vim
namespace= nfv_vim.alarm.handlers.v1
handlers=File-Storage, Fault-Management
audit_interval=30
config_file=/etc/nfv/nfv_plugins/alarm_handlers/config.ini
config_file=@SYSCONFDIR@/nfv/nfv_plugins/alarm_handlers/config.ini
[event-log]
namespace=nfv_vim.event_log.handlers.v1
handlers=File-Storage, Event-Log-Management
config_file=/etc/nfv/nfv_plugins/event_log_handlers/config.ini
config_file=@SYSCONFDIR@/nfv/nfv_plugins/event_log_handlers/config.ini
[nfvi]
namespace=nfv_vim.nfvi.plugins.v1
config_file=/etc/nfv/nfv_plugins/nfvi_plugins/config.ini
config_file=@SYSCONFDIR@/nfv/nfv_plugins/nfvi_plugins/config.ini
[host-configuration]
max_host_deleting_wait_in_secs=60
@ -60,4 +60,4 @@ rpc_port=0
[vim-webserver]
host=127.0.0.1
port=32323
source_dir=/usr/lib64/python2.7/site-packages/nfv_vim/webserver
source_dir=@PYTHONROOT@/nfv_vim/webserver

View File

@ -26,7 +26,7 @@ binname="${process}"
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default=${binname}
OCF_RESKEY_config_default="/etc/nfv/vim/config.ini"
OCF_RESKEY_config_default="@SYSCONFDIR@/nfv/vim/config.ini"
OCF_RESKEY_pid_default="/var/run/${binname}.pid"
@ -314,4 +314,4 @@ case ${__OCF_ACTION} in
*) usage
exit ${OCF_ERR_UNIMPLEMENTED}
;;
esac
esac

View File

@ -26,7 +26,7 @@ binname="${process}"
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default=${binname}
OCF_RESKEY_config_default="/etc/nfv/vim/config.ini"
OCF_RESKEY_config_default="@SYSCONFDIR@/nfv/vim/config.ini"
OCF_RESKEY_pid_default="/var/run/${binname}.pid"
@ -314,4 +314,4 @@ case ${__OCF_ACTION} in
*) usage
exit ${OCF_ERR_UNIMPLEMENTED}
;;
esac
esac

View File

@ -26,7 +26,7 @@ binname="${process}"
# Fill in some defaults if no values are specified
OCF_RESKEY_binary_default=${binname}
OCF_RESKEY_config_default="/etc/nfv/vim/config.ini"
OCF_RESKEY_config_default="@SYSCONFDIR@/nfv/vim/config.ini"
OCF_RESKEY_pid_default="/var/run/${binname}.pid"
@ -314,4 +314,4 @@ case ${__OCF_ACTION} in
*) usage
exit ${OCF_ERR_UNIMPLEMENTED}
;;
esac
esac