Debian package updates by Jochen Kunkel
[openxpki.git] / trunk / package / suse / openxpki-deployment / openxpki-deployment.spec.in
blob671b99b5657a38c0595528c4c09f445ae470858a
1 ## Written 2006 by Martin Bartosch for the OpenXPKI project
2 ## Copyright (C) 2005-2006 by The OpenXPKI Project
5 # - OpenXPKI deployment package -
8 %define pkgname openxpki-deployment
9 %define filelist %{pkgname}-%{version}-filelist
10 %define NVR %{pkgname}-%{version}-%{release}
11 %define instancedir /etc/openxpki/instances
12 %define instance trustcenter1
13 %define install_prefix _PREFIX_
15 name: openxpki-deployment
16 summary: OpenXPKI Deployment Tools
17 version: _VERSION_
18 release: 1
19 vendor: OpenXPKI Project
20 packager: Martin Bartosch <m.bartosch@cynops.de>
21 license: Apache
22 group: Applications/CPAN
23 url: http://www.openxpki.org
24 buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n)
25 prefix: %(echo %{_prefix})
26 source: openxpki-deployment-%{version}.tar.gz
28 %description
29 OpenXPKI deployment and administration tools.
31 %prep
32 %setup -q -n %{pkgname}-%{version}
33 chmod -R u+w %{_builddir}/%{pkgname}-%{version}
35 %build
36 ./configure _CONFIGURE_ARGS_ -- \
37 --setcfg dir.sysconfdir=/etc \
38 --setcfg dir.openxpkiconfdir=%{instancedir}/%{instance} \
39 --setcfg dir.localstatedir=/var \
40 --setcfg server.pidfile=/var/run/openxpkid.pid \
41 --setcfg server.admgroup=openxpki \
44 # Debian used this (does not take into account %prefix properly)
45 # --setcfg dir.mandir=/usr/share/man \
46 # --setcfg dir.sysconfdir=/etc \
47 # --setcfg dir.openxpkiconfdir=%{instancedir}/%{instance} \
48 # --setcfg dir.localedir=/usr/share/locale \
49 # --setcfg dir.localstatedir=/var \
50 # --setcfg server.pidfile=/var/run/openxpkid.pid \
51 # --setcfg server.admgroup=openxpki \
54 %{__make}
56 %install
57 [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
58 DESTDIR=%{buildroot} make install
60 install -D -m 755 -o root -g openxpki etc/initscripts/suse/openxpki.rc %{buildroot}/etc/init.d/openxpki
61 install -D -m 644 -o root -g openxpki etc/initscripts/suse/openxpki.sysconfig %{buildroot}/etc/sysconfig/openxpki
63 cmd=/usr/share/spec-helper/compress_files
64 [ -x $cmd ] || cmd=/usr/lib/rpm/brp-compress
65 [ -x $cmd ] && $cmd
67 # SuSE Linux
68 if [ -e /etc/SuSE-release -o -e /etc/UnitedLinux-release ]
69 then
73 # remove special files
75 # no empty directories
76 find %{buildroot}%{_prefix} \
77 -type d -depth \
78 -exec rmdir {} \; 2>/dev/null
80 %{__perl} -MFile::Find -le '
81 find({ wanted => \&wanted, no_chdir => 1}, "%{buildroot}");
82 print "%doc README\n";
83 print "%config /etc/sysconfig/openxpki";
84 for my $x (sort @dirs, @files) {
85 push @ret, $x unless indirs($x);
87 print join "\n", sort @ret;
89 sub wanted {
90 return if /auto$/;
91 return if /etc\/sysconfig\/openxpki$/;
93 local $_ = $File::Find::name;
94 my $f = $_; s|^\Q%{buildroot}\E||;
95 return unless length;
96 return $files[@files] = $_ if -f $f;
98 $d = $_;
99 /\Q$d\E/ && return for reverse sort @INC;
100 $d =~ /\Q$_\E/ && return
101 for qw|/etc %_prefix/man %_prefix/bin %_prefix/share|;
103 $dirs[@dirs] = $_;
106 sub indirs {
107 my $x = shift;
108 $x =~ /^\Q$_\E\// && $x ne $_ && return 1 for @dirs;
110 ' > %filelist
113 [ -z %filelist ] && {
114 echo "ERROR: empty %files listing"
115 exit -1
119 %pre
120 # find unused user/group id
121 id=60
122 while cut /etc/passwd -f3 -d: | egrep "^$id\$" >/dev/null || cut /etc/group -f3 -d: | egrep "^$id\$" >/dev/null ; do
123 id=$(($id + 1))
124 done
126 if ! cut -f1 -d: /etc/group | egrep "^openxpki\$" >/dev/null ; then
127 echo "Creating openxpki group ($id)" >&2
128 /usr/sbin/groupadd -g $id openxpki 2>/dev/null
132 if ! id openxpki >/dev/null 2>&1 ; then
133 echo "Creating openxpki user ($id)" >&2
134 /usr/sbin/useradd -c "OpenXPKI User" -r -s /bin/false -u $id -g $id -d /tmp openxpki 2>/dev/null
138 %post
139 export PATH=%{install_prefix}/bin:$PATH
140 # check for already configured trustcenter1
141 if [ -e %{instancedir}/%{instance}/openxpki.conf ]; then
142 echo "Detected an existing deployment (leaving it untouched)." >&2
143 else
144 install -d -m 750 -o root -g openxpki %{instancedir}/%{instance}
145 install -m 750 -o root -g openxpki %{install_prefix}/share/openxpki/templates/default/openxpki.conf %{instancedir}/%{instance}
146 echo -n "Deploying instance '%{instance}'... " >&2
147 openxpkiadm deploy -- --setcfg dir.openxpkiconfdir=%{instancedir}/%{instance} 2>>/var/log/messages
148 echo "DONE." >&2
149 cd %{instancedir}/%{instance}
150 echo -n "Configuring instance '%{instance}'... " >&2
151 openxpki-configure --batch --createdirs >>/var/log/messages
152 echo "DONE." >&2
155 %clean
156 [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
158 %files -f %filelist
159 %defattr(-,root,root)
161 %changelog
162 * Mon Nov 27 2006 m.bartosch@cynops.de
163 - Initial build.