mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Revise .spec and readme files
This commit is contained in:
committed by
Dan Christian Bogos
parent
310876837d
commit
ddc6fd24db
@@ -1,4 +1,4 @@
|
||||
#! /bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# $Id$
|
||||
|
||||
|
||||
42
packages/redhat_fedora/README.md
Normal file
42
packages/redhat_fedora/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# Building a CGRateS RPM package for RHEL/Centos/Oracle Linux/Scientific Linux/Fedora
|
||||
|
||||
This document provides step-by-step instructions on building a CGRateS .rpm package.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Go
|
||||
2. Git
|
||||
3. rpm-build and make packages.
|
||||
|
||||
Install the packages using the following command:
|
||||
|
||||
```bash
|
||||
sudo dnf install rpm-build make
|
||||
```
|
||||
|
||||
## Build Instructions
|
||||
|
||||
1. **Create a build environment:**
|
||||
|
||||
- Create necessary directories:
|
||||
|
||||
```bash
|
||||
mkdir -p $HOME/cgr_build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
```
|
||||
|
||||
- Download the source file. Replace `[GIT_COMMIT]` with the actual commit hash.
|
||||
|
||||
```bash
|
||||
wget -P $HOME/cgr_build/SOURCES https://github.com/cgrates/cgrates/archive/[GIT_COMMIT].tar.gz
|
||||
```
|
||||
|
||||
- Place `cgrates.spec` file into `$HOME/cgr_build/SPECS` directory.
|
||||
|
||||
2. **Build the package:**
|
||||
|
||||
```bash
|
||||
cd $HOME/cgr_build
|
||||
rpmbuild -bb --define "_topdir $HOME/cgr_build" SPECS/cgrates.spec
|
||||
```
|
||||
|
||||
Your .rpm package should now be ready.
|
||||
@@ -1,12 +1,14 @@
|
||||
# Define global variables
|
||||
%global version 0.10.3
|
||||
%global git_commit %(echo $gitLastCommit)
|
||||
%global releaseTag %(echo $rpmTag)
|
||||
|
||||
%define debug_package %{nil}
|
||||
# Define system paths
|
||||
%global _logdir /var/log/%name
|
||||
%global _spooldir /var/spool/%name
|
||||
%global _libdir /var/lib/%name
|
||||
|
||||
# Define package metadata
|
||||
Name: cgrates
|
||||
Version: %{version}
|
||||
Release: %{releaseTag}
|
||||
@@ -14,17 +16,12 @@ Summary: Carrier Grade Real-time Charging System
|
||||
License: GPLv3
|
||||
URL: https://github.com/cgrates/cgrates
|
||||
Source0: https://github.com/cgrates/cgrates/archive/%{git_commit}.tar.gz
|
||||
BuildRequires:git
|
||||
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
|
||||
Requires(pre): shadow-utils
|
||||
Requires(post): systemd
|
||||
Requires(preun): systemd
|
||||
Requires(postun): systemd
|
||||
%else
|
||||
Requires(post): chkconfig
|
||||
Requires(preun):chkconfig
|
||||
Requires(preun):initscripts
|
||||
%endif
|
||||
BuildRequires: git wget
|
||||
Requires(pre): shadow-utils
|
||||
|
||||
# Systemd service management macros
|
||||
%{?systemd_requires}
|
||||
BuildRequires: systemd-rpm-macros
|
||||
|
||||
%description
|
||||
CGRateS is a very fast and easy scalable real-time charging system for Telecom environments.
|
||||
@@ -33,6 +30,8 @@ CGRateS is a very fast and easy scalable real-time charging system for Telecom e
|
||||
%setup -q -n %{name}-%{version} -c
|
||||
mkdir -p src/github.com/cgrates
|
||||
ln -sf ../../../$(ls |grep %{name}-) src/github.com/cgrates/cgrates
|
||||
wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz
|
||||
tar -xzf go1.20.5.linux-amd64.tar.gz -C %{_builddir}
|
||||
|
||||
%pre
|
||||
getent group %{name} >/dev/null || groupadd -r %{name}
|
||||
@@ -40,76 +39,63 @@ getent passwd %{name} >/dev/null || \
|
||||
useradd -r -g %{name} -d %{_localstatedir}/run/%{name} -s /sbin/nologin \
|
||||
-c "CGRateS" %{name} 2>/dev/null || :
|
||||
|
||||
%post
|
||||
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
|
||||
if [ $1 -eq 1 ] ; then
|
||||
# Initial installation
|
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||
fi
|
||||
%else
|
||||
/sbin/chkconfig --add %{name}
|
||||
%endif
|
||||
/bin/chown -R %{name}:%{name} %{_logdir}
|
||||
/bin/chown -R %{name}:%{name} %{_spooldir}
|
||||
/bin/chown -R %{name}:%{name} %{_libdir}
|
||||
sudo systemctl restart rsyslog
|
||||
|
||||
%preun
|
||||
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
|
||||
if [ $1 -eq 0 ] ; then
|
||||
# Package removal, not upgrade
|
||||
/bin/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || :
|
||||
/bin/systemctl stop %{name}.service > /dev/null 2>&1 || :
|
||||
fi
|
||||
%else
|
||||
if [ $1 = 0 ]; then
|
||||
/sbin/service %{name} stop > /dev/null 2>&1
|
||||
/sbin/chkconfig --del %{name}
|
||||
fi
|
||||
%endif
|
||||
|
||||
%build
|
||||
export GOPATH=$RPM_BUILD_DIR/%{name}-%{version}
|
||||
cd $RPM_BUILD_DIR/%{name}-%{version}/src/github.com/cgrates/cgrates
|
||||
export GOPATH=%{_builddir}/%{name}-%{version}
|
||||
cd %{_builddir}/%{name}-%{version}/src/github.com/cgrates/cgrates
|
||||
export PATH=$PATH:%{_builddir}/go/bin
|
||||
./build.sh
|
||||
|
||||
%undefine _missing_build_ids_terminate_build
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/conf/ $RPM_BUILD_ROOT%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/diameter/ $RPM_BUILD_ROOT%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/postman/ $RPM_BUILD_ROOT%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/radius/ $RPM_BUILD_ROOT%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/tariffplans/ $RPM_BUILD_ROOT%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/tutorial_tests/ $RPM_BUILD_ROOT%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/tutorials/ $RPM_BUILD_ROOT%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/storage/mongo $RPM_BUILD_ROOT%{_datarootdir}/%{name}/storage
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/storage/mysql $RPM_BUILD_ROOT%{_datarootdir}/%{name}/storage
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/storage/postgres $RPM_BUILD_ROOT%{_datarootdir}/%{name}/storage
|
||||
install -D -m 0644 -p src/github.com/cgrates/cgrates/data/conf/%{name}/%{name}.json $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/%{name}.json
|
||||
install -D -m 0755 -p bin/cgr-console $RPM_BUILD_ROOT%{_bindir}/cgr-console
|
||||
install -D -m 0755 -p bin/cgr-engine $RPM_BUILD_ROOT%{_bindir}/cgr-engine
|
||||
install -D -m 0755 -p bin/cgr-loader $RPM_BUILD_ROOT%{_bindir}/cgr-loader
|
||||
install -D -m 0755 -p bin/cgr-tester $RPM_BUILD_ROOT%{_bindir}/cgr-tester
|
||||
install -D -m 0755 -p bin/cgr-migrator $RPM_BUILD_ROOT%{_bindir}/cgr-migrator
|
||||
mkdir -p $RPM_BUILD_ROOT%{_logdir}/cdre/csv
|
||||
mkdir -p $RPM_BUILD_ROOT%{_logdir}/cdre/fwv
|
||||
mkdir -p $RPM_BUILD_ROOT%{_spooldir}/cdre/csv
|
||||
mkdir -p $RPM_BUILD_ROOT%{_spooldir}/cdre/fwv
|
||||
mkdir -p $RPM_BUILD_ROOT%{_spooldir}/tpe
|
||||
mkdir -p $RPM_BUILD_ROOT%{_spooldir}/failed_posts
|
||||
mkdir -p $RPM_BUILD_ROOT%{_libdir}/cache_dump
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/rsyslog.d
|
||||
install -m 755 src/github.com/cgrates/cgrates/data/conf/logging/logrotate.conf $RPM_BUILD_ROOT/etc/logrotate.d/%{name}
|
||||
install -m 755 src/github.com/cgrates/cgrates/data/conf/logging/rsyslog.conf $RPM_BUILD_ROOT/etc/rsyslog.d/%{name}.conf
|
||||
install -D -m 0644 -p src/github.com/cgrates/cgrates/packages/redhat_fedora/%{name}.options $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name}
|
||||
rm -rf %{buildroot}
|
||||
mkdir -p %{buildroot}%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/conf/ %{buildroot}%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/diameter/ %{buildroot}%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/postman/ %{buildroot}%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/radius/ %{buildroot}%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/tariffplans/ %{buildroot}%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/tutorial_tests/ %{buildroot}%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/tutorials/ %{buildroot}%{_datarootdir}/%{name}
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/storage/mongo %{buildroot}%{_datarootdir}/%{name}/storage
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/storage/mysql %{buildroot}%{_datarootdir}/%{name}/storage
|
||||
cp -rpf src/github.com/cgrates/cgrates/data/storage/postgres %{buildroot}%{_datarootdir}/%{name}/storage
|
||||
install -D -m 0644 -p src/github.com/cgrates/cgrates/data/conf/%{name}/%{name}.json %{buildroot}%{_sysconfdir}/%{name}/%{name}.json
|
||||
install -D -m 0755 -p bin/cgr-console %{buildroot}%{_bindir}/cgr-console
|
||||
install -D -m 0755 -p bin/cgr-engine %{buildroot}%{_bindir}/cgr-engine
|
||||
install -D -m 0755 -p bin/cgr-loader %{buildroot}%{_bindir}/cgr-loader
|
||||
install -D -m 0755 -p bin/cgr-tester %{buildroot}%{_bindir}/cgr-tester
|
||||
install -D -m 0755 -p bin/cgr-migrator %{buildroot}%{_bindir}/cgr-migrator
|
||||
mkdir -p %{buildroot}%{_logdir}/cdre/csv
|
||||
mkdir -p %{buildroot}%{_logdir}/cdre/fwv
|
||||
mkdir -p %{buildroot}%{_spooldir}/cdre/csv
|
||||
mkdir -p %{buildroot}%{_spooldir}/cdre/fwv
|
||||
mkdir -p %{buildroot}%{_spooldir}/tpe
|
||||
mkdir -p %{buildroot}%{_spooldir}/failed_posts
|
||||
mkdir -p %{buildroot}%{_libdir}/cache_dump
|
||||
mkdir -p %{buildroot}/etc/logrotate.d
|
||||
mkdir -p %{buildroot}/etc/rsyslog.d
|
||||
install -m 755 src/github.com/cgrates/cgrates/data/conf/logging/logrotate.conf %{buildroot}/etc/logrotate.d/%{name}
|
||||
install -m 755 src/github.com/cgrates/cgrates/data/conf/logging/rsyslog.conf %{buildroot}/etc/rsyslog.d/%{name}.conf
|
||||
install -D -m 0644 -p src/github.com/cgrates/cgrates/packages/redhat_fedora/%{name}.options %{buildroot}%{_sysconfdir}/sysconfig/%{name}
|
||||
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
|
||||
install -D -m 0644 -p src/github.com/cgrates/cgrates/packages/redhat_fedora/%{name}.service $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
|
||||
install -D -m 0644 -p src/github.com/cgrates/cgrates/packages/redhat_fedora/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
|
||||
%else
|
||||
install -D -m 0755 -p src/github.com/cgrates/cgrates/packages/redhat_fedora/%{name}.init $RPM_BUILD_ROOT%{_initrddir}/%{name}
|
||||
install -D -m 0755 -p src/github.com/cgrates/cgrates/packages/redhat_fedora/%{name}.init %{buildroot}%{_initrddir}/%{name}
|
||||
%endif
|
||||
|
||||
%post
|
||||
# After package installation, enable and start the service
|
||||
%systemd_post %{name}.service
|
||||
|
||||
%preun
|
||||
# Before package removal, stop the service
|
||||
%systemd_preun %{name}.service
|
||||
|
||||
%postun
|
||||
# After package removal, try to restart the service in case of an update
|
||||
%systemd_postun_with_restart %{name}.service
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%{_datarootdir}/%{name}/*
|
||||
@@ -121,12 +107,5 @@ install -D -m 0644 -p src/github.com/cgrates/cgrates/packages/redhat_fedora/%{na
|
||||
%{_sysconfdir}/sysconfig/%{name}
|
||||
/etc/logrotate.d/%{name}
|
||||
/etc/rsyslog.d/%{name}.conf
|
||||
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
|
||||
%{_unitdir}/%{name}.service
|
||||
%else
|
||||
%{_initrddir}/%{name}
|
||||
%endif
|
||||
|
||||
%clean
|
||||
#sudo rm -rf $RPM_BUILD_DIR/%{name}-%{version}
|
||||
#sudo rm -rf $RPM_BUILD_ROOT
|
||||
%{?_unitdir:%{_unitdir}/%{name}.service}
|
||||
%{!?_unitdir:%{_initrddir}/%{name}}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
Building package for RHEL/Centos/Oracle Linux/Scientific Linux/Fedora
|
||||
|
||||
PREREQUISITES
|
||||
1. Go
|
||||
|
||||
2. Git
|
||||
|
||||
3. rpm-build and make packages.
|
||||
# dnf install rpm-build make
|
||||
|
||||
BUILD
|
||||
1. Create build environment:
|
||||
- Make directories
|
||||
# mkdir -p $HOME/cgr_build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
|
||||
- Download source file
|
||||
# wget -P $HOME/cgr_build/SOURCES https://github.com/cgrates/cgrates/archive/[GIT_COMMIT].tar.gz
|
||||
- Place cgrates.spec file into $HOME/cgr_build/SPECS
|
||||
2. Build:
|
||||
# cd $HOME/cgr_build
|
||||
# rpmbuild -bb --define "_topdir $HOME/cgr_build" SPECS/cgrates.spec
|
||||
Reference in New Issue
Block a user