-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrecodex-api.spec
133 lines (107 loc) · 4.31 KB
/
recodex-api.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
127
128
129
130
%define name recodex-core
%define short_name api
%define install_dir /opt/%{name}
%define version 2.16.1
%define unmangled_version 9f2e984f03086c228016bc7e420bfa23d8c7e8b9
%define release 1
Summary: ReCodEx core API component
Name: %{name}
Version: %{version}
Release: %{release}
License: MIT
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Prefix: %{_prefix}
Vendor: Petr Stefan <UNKNOWN>
Url: https://github.com/ReCodEx/api
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Requires: git php php-json php-mysqlnd php-ldap php-pecl-yaml php-pecl-zip php-pecl-zmq php-xml php-intl php-mbstring php-pecl-inotify
Source0: https://github.com/ReCodEx/%{short_name}/archive/%{unmangled_version}.tar.gz#/%{short_name}-%{unmangled_version}.tar.gz
%global debug_package %{nil}
%description
Core business logic and REST API of ReCodEx code examiner, an educational application for evaluating programming assignments.
%prep
%setup -n %{short_name}-%{unmangled_version}
curl "https://getcomposer.org/composer-stable.phar" -o composer-stable.phar
%build
# Nothing to do here
%install
mkdir -p %{buildroot}%{install_dir}
mkdir -p %{buildroot}/var/log/recodex/core-api
ln -sf /var/log/recodex/core-api %{buildroot}%{install_dir}/log
mkdir -p %{buildroot}%{install_dir}/temp
cp -r www %{buildroot}%{install_dir}/www
cp -r app %{buildroot}%{install_dir}/app
cp -r bin %{buildroot}%{install_dir}/bin
cp -r migrations %{buildroot}%{install_dir}/migrations
mkdir -p %{buildroot}%{install_dir}/fixtures
cp -r fixtures/init %{buildroot}%{install_dir}/fixtures/init
cp composer.json composer.lock composer-stable.phar cleaner %{buildroot}%{install_dir}/
mkdir -p %{buildroot}/%{_sysconfdir}/recodex/core-api
mv %{buildroot}%{install_dir}/app/config/config.local.neon.example %{buildroot}%{install_dir}/app/config/config.local.neon
ln -sf %{install_dir}/app/config/config.local.neon %{buildroot}/%{_sysconfdir}/recodex/core-api/config.local.neon
install -d %{buildroot}/lib/systemd/system
cp -r install/recodex-core.service %{buildroot}/lib/systemd/system/recodex-core.service
%clean
%post
setfacl -Rd -m u:apache:rwX %{install_dir}/temp
setfacl -Rd -m u:recodex:rwX %{install_dir}/temp
setfacl -Rd -m u:apache:rwX /var/log/recodex/core-api
setfacl -Rd -m u:recodex:rwX /var/log/recodex/core-api
# Install dependencies
php %{install_dir}/composer-stable.phar install --no-ansi --no-dev --no-interaction --no-progress --no-scripts --optimize-autoloader --working-dir=%{install_dir}/
# Run cleaner after installation
%{install_dir}/cleaner
%systemd_post 'recodex-core.service'
%postun
%systemd_postun_with_restart 'recodex-core.service'
%pre
getent group recodex >/dev/null || groupadd -r recodex
getent passwd recodex >/dev/null || useradd -r -g recodex -d %{_sysconfdir}/recodex -s /sbin/nologin -c "ReCodEx Code Examiner" recodex
exit 0
%preun
%systemd_preun 'recodex-core.service'
if [ $1 == 0 ]; then
%{install_dir}/cleaner
rm -rf %{install_dir}/vendor
rm -rf %{install_dir}/temp
fi
%files
%defattr(-,recodex,recodex)
%dir %{install_dir}
%dir %attr(-,recodex,recodex) %{_sysconfdir}/recodex/core-api
%dir %attr(0775,apache,recodex) /var/log/recodex/core-api
%attr(0775,apache,recodex) %{install_dir}/log
%dir %attr(0775,apache,recodex) %{install_dir}/temp
%dir %{install_dir}/app
%dir %{install_dir}/bin
%{install_dir}/app/Bootstrap.php
%{install_dir}/app/async
%{install_dir}/app/commands
%{install_dir}/app/exceptions
%{install_dir}/app/helpers
%{install_dir}/app/http
%{install_dir}/app/model
%{install_dir}/app/presenters
%{install_dir}/app/router
%{install_dir}/app/V1Module
%{install_dir}/app/web.config
%{install_dir}/app/.htaccess
%{install_dir}/composer.json
%{install_dir}/composer.lock
%{install_dir}/composer-stable.phar
%attr(0770,recodex,recodex) %{install_dir}/cleaner
%{install_dir}/fixtures
%{install_dir}/migrations
%{install_dir}/www
%attr(0660,apache,recodex) %{_sysconfdir}/recodex/core-api/config.local.neon
%attr(0770,recodex,recodex) %{install_dir}/bin/async-worker
%attr(0770,recodex,recodex) %{install_dir}/bin/console
%config %{install_dir}/app/config/config.neon
%config %{install_dir}/app/config/permissions.neon
%config(noreplace) %attr(0660,apache,recodex) %{install_dir}/app/config/config.local.neon
#%{_unitdir}/recodex-core.service
%attr(-,root,root) /lib/systemd/system/recodex-core.service
%changelog