-
Notifications
You must be signed in to change notification settings - Fork 12
/
nexus-repository-manager.spec
117 lines (102 loc) · 3.66 KB
/
nexus-repository-manager.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
Name: nexus-repository-manager
Version: %%VERSION%%
Release: %%RELEASE%%
Summary: Nexus Repository Manager 3
License: Proprietary
Requires: systemd
Requires: java-17-openjdk-headless
URL: https://www.sonatype.com
Source0: %%BUNDLE_FILE%%
Source1: %{name}-%{version}-rpm-extra.tar.gz
BuildRoot: %{_tmppath}/nexus-repository-manager
BuildArch: noarch
#Prefix: /
%define __jar_repack %{nil}
%define service_name %{name}.service
%description
Nexus Repository Manager 3
%prep
rm -rf ${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}
mkdir -p ${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}
cd ${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}
tar -xz \
-f %{SOURCE0}
tar -xz -f %{SOURCE1}
%build
cd ${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/opt/sonatype/nexus3
mkdir -p %{buildroot}/opt/sonatype/sonatype-work/nexus3
rsync -a ${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}/nexus-$(echo ${RPM_PACKAGE_VERSION} | tr '_' '-')/ %{buildroot}/opt/sonatype/nexus3
rsync -a ${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}/extra %{buildroot}/opt/sonatype/nexus3/
rsync -a ${RPM_PACKAGE_NAME}-${RPM_PACKAGE_VERSION}/sonatype-work/nexus3/ %{buildroot}/opt/sonatype/sonatype-work/nexus3
#patch config
perl -p -i -e 's/#run_as_user=""/run_as_user="nexus3"/' %{buildroot}/opt/sonatype/nexus3/bin/nexus.rc
perl -p -i -e 's/\.\.\/sonatype-work/\/opt\/sonatype\/sonatype-work/g' %{buildroot}/opt/sonatype/nexus3/bin/nexus.vmoptions
mkdir -p %{buildroot}/etc/systemd/system
ln -sf /opt/sonatype/nexus3/extra/daemon/%{service_name} %{buildroot}/etc/systemd/system/%{service_name}
%clean
rm -rf %{buildroot}
%pre
echo pre $1
if [ $1 = 1 ] || [ "$1" = "install" ]; then
[ -d /opt/sonatype/sonatype-work/nexus3 ] || mkdir -p /opt/sonatype/sonatype-work/nexus3
# create user account
getent group nexus3 >/dev/null || groupadd -r nexus3
getent passwd nexus3 >/dev/null || \
useradd -r -g nexus3 -d /opt/sonatype/sonatype-work/nexus3 -m -c "nexus3 role account" -s /bin/bash nexus3
fi
# stop the service before upgrading
if [ $1 = 2 ] || [ "$1" = "upgrade" ]; then
if [ ! -f /etc/systemd/system/%{service_name} ]; then
# use old init script to stop old service
if [ $1 = 2 ]; then
/sbin/service nexus3 stop
elif [ "$1" = "upgrade" ]; then
/usr/sbin/service nexus3 stop
fi
else
systemctl stop %{service_name}
fi
fi
%post
echo post $1
# start the service upon first installation
if [ $1 = 1 ] || [ "$1" = "configure" ]; then
systemctl daemon-reload
systemctl enable %{service_name}
systemctl start %{service_name}
fi
# start the service after upgrading
if [ $1 = 2 ] || [ "$1" = "upgrade" ]; then
systemctl start %{service_name}
fi
%preun
echo preun $1
if [ $1 = 0 ] || [ "$1" = "remove" ]; then
systemctl stop %{service_name}
systemctl disable %{service_name}
fi
%files
%defattr(-,root,root,-)
/etc/systemd/system/%{service_name}
/opt/sonatype/nexus3
%dir %config(noreplace) /opt/sonatype/nexus3/extra
%dir %config(noreplace) /opt/sonatype/nexus3/etc
%config(noreplace) /opt/sonatype/nexus3/bin/nexus.rc
%config(noreplace) /opt/sonatype/nexus3/bin/nexus.vmoptions
%config /opt/sonatype/nexus3/extra/daemon/%{service_name}
%defattr(-,nexus3,nexus3)
/opt/sonatype/sonatype-work/nexus3
%changelog
* Thu Aug 08 2024 Dan Rollo <drollo@sonatype.com>
require jdk 17.
* Thu Mar 05 2020 Dan Rollo <drollo@sonatype.com>
switch to systemd
* Thu Feb 06 2020 Dan Rollo <drollo@sonatype.com>
add openjdk dependency
* Wed May 29 2019 Dan Rollo <drollo@sonatype.com>
automatically start and stop service daemon as needed during initial install and upgrades
* Tue May 21 2019 Dan Rollo <drollo@sonatype.com>
initial .spec from prior work of Jason Swank, Rick Briganti, Alvin Gunkel