-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy patharchivematica.spec
279 lines (235 loc) · 10.5 KB
/
archivematica.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')
#
# Packages
#
Name: archivematica
Version: %{rpmversion}
Release: %{rpmrelease}
Summary: Archivematica digital preservation system
Group: Application/System
License: AGPLv3
Source0: %{git_repo}
BuildRequires: git, gcc, openldap-devel, openssl-devel, python-virtualenv, python-pip, mariadb-devel, libxslt-devel, python-devel, libffi-devel, openssl-devel, gcc-c++, postgresql-devel, nodejs
Requires: archivematica-common
AutoReq: No
AutoProv: No
%description
Archivematica is a web- and standards-based, open-source application which allows your institution to preserve long-term access to trustworthy, authentic and reliable digital content.
%package common
Summary: Archivematica common libraries
Requires: shadow-utils
%description common
Common files and libraries for Archivematica.
%package mcp-server
Requires: archivematica-common
Summary: Archivematica MCP server
%description mcp-server
Archivematica MCP server.
%package mcp-client
Summary: Archivematica MCP client
Requires: archivematica-common
Requires: bzip2
Requires: tesseract
Requires: tree
Requires: p7zip
Requires: p7zip-plugins
Requires: pbzip2
Requires: ImageMagick
Requires: ghostscript
Requires: perl-Image-ExifTool
Requires: inkscape
Requires: clamav-data
Requires: clamav-update
Requires: clamav-filesystem
Requires: clamav
Requires: clamav-devel
Requires: clamav-lib
Requires: clamd
Requires: libvpx
Requires: libraw1394
Requires: libpst
Requires: openjpeg
Requires: mediainfo
Requires: mediaconch
Requires: md5deep
Requires: uuid
# Packages from Archivematica repo
Requires: siegfried
Requires: fits
Requires: atool
Requires: jhove
# Packages from https://forensics.cert.org/
Requires: bulk_extractor
Requires: sleuthkit
Requires: libewf
# Packages from Nux repo
Requires: ffmpeg
Requires: ufraw
AutoReq: No
AutoProv: No
%description mcp-client
Archivematica MCP client.
%package dashboard
Summary: Archivematica dashboard
Requires: nginx, policycoreutils-python
%description dashboard
Archivematica dashboard with Nginx + gunicorn.
#
# Files
#
# There is no need for a main package "archivematica", so we avoid using the
# unnamed $files tag in this section.
# Common
%files common
/usr/lib/archivematica/archivematicaCommon/
/var/archivematica/sharedDirectory/
# MCPServer
%files mcp-server
/usr/share/archivematica/virtualenvs/archivematica-mcp-server/
/usr/lib/archivematica/MCPServer/
/usr/lib/systemd/system/archivematica-mcp-server.service
%config /etc/sysconfig/archivematica-mcp-server
%config /etc/archivematica/serverConfig.conf
%config /etc/archivematica/serverConfig.logging.json
# MCPClient
%files mcp-client
/usr/share/archivematica/virtualenvs/archivematica-mcp-client/
/usr/lib/archivematica/MCPClient/
/usr/lib/systemd/system/archivematica-mcp-client.service
%config /etc/sysconfig/archivematica-mcp-client
%config /etc/archivematica/clientConfig.conf
%config /etc/archivematica/clientConfig.logging.json
# Dashboard
%files dashboard
/usr/share/archivematica/virtualenvs/archivematica-dashboard/
/usr/share/archivematica/dashboard/
/usr/lib/systemd/system/archivematica-dashboard.service
%config /etc/sysconfig/archivematica-dashboard
%config /etc/nginx/conf.d/archivematica-dashboard.conf
%config /etc/archivematica/dashboard.gunicorn-config.py
%config /etc/archivematica/dashboard.logging.json
#
# Preparations
#
%prep
rm -rf /usr/share/python/archivematica*
rm -rf /usr/lib/archivematica
rm -rf %{_sourcedir}/*
rm -rf %{buildroot}/*
mkdir -p %{buildroot}/%{install_dir}
git clone \
--quiet \
--branch %{_branch} \
--depth 1 \
--single-branch \
--recurse-submodules \
%{git_repo} \
%{_sourcedir}/%{name}
#
# Install
#
%install
mkdir -p \
%{buildroot}/etc/archivematica/ \
%{buildroot}/usr/lib/archivematica/MCPServer \
%{buildroot}/usr/lib/archivematica/MCPClient \
%{buildroot}/usr/lib/archivematica/archivematicaCommon \
%{buildroot}/usr/share/archivematica/virtualenvs/archivematica-mcp-server \
%{buildroot}/usr/share/archivematica/virtualenvs/archivematica-mcp-client \
%{buildroot}/usr/share/archivematica/virtualenvs/archivematica-dashboard \
%{buildroot}/usr/share/archivematica/dashboard \
%{buildroot}/var/archivematica/sharedDirectory \
%{buildroot}/etc/sysconfig \
%{buildroot}/usr/lib/systemd/system \
%{buildroot}/etc/nginx/conf.d
# Common
cp -rf %{_sourcedir}/%{name}/src/archivematicaCommon/lib/* %{buildroot}/usr/lib/archivematica/archivematicaCommon/
# MCPServer
virtualenv /usr/share/archivematica/virtualenvs/archivematica-mcp-server
/usr/share/archivematica/virtualenvs/archivematica-mcp-server/bin/pip install --upgrade pip
/usr/share/archivematica/virtualenvs/archivematica-mcp-server/bin/pip install -r %{_sourcedir}/%{name}/src/archivematicaCommon/requirements/production.txt
/usr/share/archivematica/virtualenvs/archivematica-mcp-server/bin/pip install -r %{_sourcedir}/%{name}/src/dashboard/src/requirements/production.txt
/usr/share/archivematica/virtualenvs/archivematica-mcp-server/bin/pip install -r %{_sourcedir}/%{name}/src/MCPServer/requirements/production.txt
virtualenv --relocatable /usr/share/archivematica/virtualenvs/archivematica-mcp-server
cp -rf /usr/share/archivematica/virtualenvs/archivematica-mcp-server/* %{buildroot}/usr/share/archivematica/virtualenvs/archivematica-mcp-server/
cp -rf %{_sourcedir}/%{name}/src/MCPServer/lib/* %{buildroot}/usr/lib/archivematica/MCPServer/
cp %{_sourcedir}/%{name}/src/MCPServer/install/serverConfig.logging.json %{buildroot}/etc/archivematica/serverConfig.logging.json
cp %{_sourcedir}/%{name}/src/MCPServer/install/serverConfig.conf %{buildroot}/etc/archivematica/serverConfig.conf
cp %{_etcdir}/archivematica-mcp-server.service %{buildroot}/usr/lib/systemd/system/archivematica-mcp-server.service
cp %{_etcdir}/archivematica-mcp-server.env %{buildroot}/etc/sysconfig/archivematica-mcp-server
# MCPClient
virtualenv /usr/share/archivematica/virtualenvs/archivematica-mcp-client
/usr/share/archivematica/virtualenvs/archivematica-mcp-client/bin/pip install --upgrade pip
/usr/share/archivematica/virtualenvs/archivematica-mcp-client/bin/pip install -r %{_sourcedir}/%{name}/src/archivematicaCommon/requirements/production.txt
/usr/share/archivematica/virtualenvs/archivematica-mcp-client/bin/pip install -r %{_sourcedir}/%{name}/src/dashboard/src/requirements/production.txt
/usr/share/archivematica/virtualenvs/archivematica-mcp-client/bin/pip install -r %{_sourcedir}/%{name}/src/MCPClient/requirements/production.txt
virtualenv --relocatable /usr/share/archivematica/virtualenvs/archivematica-mcp-client
cp -rf /usr/share/archivematica/virtualenvs/archivematica-mcp-client/* %{buildroot}/usr/share/archivematica/virtualenvs/archivematica-mcp-client/
cp -rf %{_sourcedir}/%{name}/src/MCPClient/lib/* %{buildroot}/usr/lib/archivematica/MCPClient
cp %{_sourcedir}/%{name}/src/MCPClient/install/clientConfig.logging.json %{buildroot}/etc/archivematica/clientConfig.logging.json
cp %{_sourcedir}/%{name}/src/MCPClient/install/clientConfig.conf %{buildroot}/etc/archivematica/clientConfig.conf
cp %{_etcdir}/archivematica-mcp-client.service %{buildroot}/usr/lib/systemd/system/archivematica-mcp-client.service
cp %{_etcdir}/archivematica-mcp-client.env %{buildroot}/etc/sysconfig/archivematica-mcp-client
# Dashboard
virtualenv /usr/share/archivematica/virtualenvs/archivematica-dashboard
/usr/share/archivematica/virtualenvs/archivematica-dashboard/bin/pip install --upgrade pip
/usr/share/archivematica/virtualenvs/archivematica-dashboard/bin/pip install -r %{_sourcedir}/%{name}/src/archivematicaCommon/requirements/production.txt
/usr/share/archivematica/virtualenvs/archivematica-dashboard/bin/pip install -r %{_sourcedir}/%{name}/src/dashboard/src/requirements/production.txt
virtualenv --relocatable /usr/share/archivematica/virtualenvs/archivematica-dashboard
cd %{_sourcedir}/%{name}/src/dashboard/frontend/ && npm install --unsafe-perm
find %{_sourcedir}/%{name}/src/dashboard/ | grep static
cp -rf /usr/share/archivematica/virtualenvs/archivematica-dashboard/* %{buildroot}/usr/share/archivematica/virtualenvs/archivematica-dashboard/
cp -rf %{_sourcedir}/%{name}/src/dashboard/src/* %{buildroot}/usr/share/archivematica/dashboard/
cp %{_sourcedir}/%{name}/src/dashboard/install/dashboard.gunicorn-config.py %{buildroot}/etc/archivematica/dashboard.gunicorn-config.py
cp %{_sourcedir}/%{name}/src/dashboard/install/dashboard.logging.json %{buildroot}/etc/archivematica/dashboard.logging.json
cp %{_etcdir}/archivematica-dashboard.service %{buildroot}/usr/lib/systemd/system/archivematica-dashboard.service
cp %{_etcdir}/archivematica-dashboard.env %{buildroot}/etc/sysconfig/archivematica-dashboard
cp %{_etcdir}/dashboard.nginx %{buildroot}/etc/nginx/conf.d/archivematica-dashboard.conf
#
# Clean up build directory
#
%clean
rm -rf %{buildroot}
#
# Post install scripts
#
# Common
%post common
# Create archivematica user and group
getent group archivematica >/dev/null || groupadd -f -g 333 -r archivematica
if ! getent passwd archivematica >/dev/null ; then
if ! getent passwd 333 >/dev/null ; then
useradd -r -u 333 -g archivematica -d /var/lib/archivematica/ -s /sbin/nologin -c "Archivematica system account" -m archivematica
else
useradd -r -g archivematica -d /var/lib/archivematica/ -s /sbin/nologin -c "Archivematica system account" -m archivematica
fi
fi
# Configure permissions of shared directory
chown -R archivematica:archivematica /var/archivematica/sharedDirectory
# MCP Server
%post mcp-server
mkdir -p /var/log/archivematica/MCPServer
chown -R archivematica:archivematica /var/log/archivematica/MCPServer
systemctl daemon-reload
# MCP Client
%post mcp-client
mkdir -p /var/log/archivematica/MCPClient
chown -R archivematica:archivematica /var/log/archivematica/MCPClient
systemctl daemon-reload
# Dashboard
%post dashboard
mkdir -p /var/log/archivematica/dashboard
# Create Django key
KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
sed -i "s/CHANGE_ME_WITH_A_SECRET_KEY/\"$KEY\"/g" /etc/sysconfig/archivematica-dashboard
# Run django collectstatic
mkdir -p /usr/share/archivematica/dashboard/static
export $(cat /etc/sysconfig/archivematica-dashboard)
cd /usr/share/archivematica/dashboard
/usr/share/archivematica/virtualenvs/archivematica-dashboard/bin/python manage.py collectstatic --noinput --clear
chown -R archivematica:archivematica /var/log/archivematica/dashboard
systemctl daemon-reload
# Update SELinux policy
if [ x$(semanage port -l | grep http_port_t | grep 7400 | wc -l) == x0 ]; then
semanage port -a -t http_port_t -p tcp 7400
fi