-
Notifications
You must be signed in to change notification settings - Fork 0
/
issabel-addons.spec
126 lines (103 loc) · 3.92 KB
/
issabel-addons.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
%define modname addons
Summary: Issabel Addons
Name: issabel-addons
Version: 5.0.0
Release: 1
License: GPL
Group: Applications/System
Source0: issabel-%{modname}-%{version}.tar.gz
#Patch0: repo-40.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildArch: noarch
Requires(pre): issabel-framework >= 5.0.0-1
Requires(pre): chkconfig, php-soap
Requires: yum
# commands: /usr/bin/uname
Requires: coreutils
# commands: rpm
Requires: rpm
Obsoletes: elastix-addons
%description
Issabel Addons
%prep
%setup -n %{name}-%{version}
#%patch0 -p0
%install
rm -rf $RPM_BUILD_ROOT
# Files provided by all Issabel modules
mkdir -p $RPM_BUILD_ROOT/var/www/html/
mv modules/ $RPM_BUILD_ROOT/var/www/html/
# Additional (module-specific) files that can be handled by RPM
mkdir -p $RPM_BUILD_ROOT/opt/issabel/
mv setup/issabel-moduleconf $RPM_BUILD_ROOT/opt/issabel/issabel-updater
mkdir -p $RPM_BUILD_ROOT/etc/init.d/
mv $RPM_BUILD_ROOT/opt/issabel/issabel-updater/issabel-updaterd $RPM_BUILD_ROOT/etc/init.d/
chmod +x $RPM_BUILD_ROOT/etc/init.d/issabel-updaterd
mkdir -p $RPM_BUILD_ROOT/etc/yum.repos.d/
## Add the GNU Privacy Guard for the Postgresql91 repo
mkdir -p $RPM_BUILD_ROOT/etc/pki/
mv setup/etc/pki/rpm-gpg/ $RPM_BUILD_ROOT/etc/pki/
rmdir setup/etc/pki
# The following folder should contain all the data that is required by the installer,
# that cannot be handled by RPM.
mkdir -p $RPM_BUILD_ROOT/usr/share/issabel/module_installer/%{name}-%{version}-%{release}/
mv setup/etc/yum.repos.d/ $RPM_BUILD_ROOT/etc/
rmdir setup/etc
mv setup/ $RPM_BUILD_ROOT/usr/share/issabel/module_installer/%{name}-%{version}-%{release}/
mv menu.xml $RPM_BUILD_ROOT/usr/share/issabel/module_installer/%{name}-%{version}-%{release}/
%pre
mkdir -p /usr/share/issabel/module_installer/%{name}-%{version}-%{release}/
touch /usr/share/issabel/module_installer/%{name}-%{version}-%{release}/preversion_%{modname}.info
if [ $1 -eq 2 ]; then
rpm -q --queryformat='%{VERSION}-%{RELEASE}' %{name} > /usr/share/issabel/module_installer/%{name}-%{version}-%{release}/preversion_%{modname}.info
fi
%post
pathModule="/usr/share/issabel/module_installer/%{name}-%{version}-%{release}"
# Run installer script to fix up ACLs and add module to Issabel menus.
issabel-menumerge /usr/share/issabel/module_installer/%{name}-%{version}-%{release}/menu.xml
pathSQLiteDB="/var/www/db"
mkdir -p $pathSQLiteDB
preversion=`cat $pathModule/preversion_%{modname}.info`
rm -f $pathModule/preversion_%{modname}.info
if [ $1 -eq 1 ]; then #install
# The installer database
issabel-dbprocess "install" "$pathModule/setup/db"
elif [ $1 -eq 2 ]; then #update
# Removing addons_installed modules
issabel-menuremove "addons_installed"
issabel-menuremove "addons_avalaibles"
# Removing addons_installed files
rm -rf /var/www/html/modules/addons_installed
issabel-dbprocess "update" "$pathModule/setup/db" "$preversion"
# restart daemon
/usr/bin/systemctl daemon-reload
/sbin/service issabel-updaterd restart
fi
# The installer script expects to be in /tmp/new_module
mkdir -p /tmp/new_module/%{modname}
cp -r /usr/share/issabel/module_installer/%{name}-%{version}-%{release}/* /tmp/new_module/%{modname}/
chown -R asterisk.asterisk /tmp/new_module/%{modname}
php /tmp/new_module/%{modname}/setup/installer.php
rm -rf /tmp/new_module
# Install issabel-updaterd as a service
chkconfig --add issabel-updaterd
chkconfig --level 2345 issabel-updaterd on
%clean
rm -rf $RPM_BUILD_ROOT
%preun
pathModule="/usr/share/issabel/module_installer/%{name}-%{version}-%{release}"
if [ $1 -eq 0 ] ; then # Validation for desinstall this rpm
echo "Delete Addons menus"
issabel-menuremove "%{modname}"
echo "Dump and delete %{name} databases"
issabel-dbprocess "delete" "$pathModule/setup/db"
fi
%files
%defattr(-, root, root)
%{_localstatedir}/www/html/*
/usr/share/issabel/module_installer/*
/etc/init.d/issabel-updaterd
/opt/issabel/issabel-updater
/etc/pki/rpm-gpg/*
/etc/yum.repos.d/*
%changelog