RT notifier: parse templates without header correctly
[openxpki.git] / trunk / package / suse / openxpki-deployment / openxpki-deployment.spec.in
blob66763bfb48f03a195a2f55ff148e2b63be214f71
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 source0: openxpki-deployment-%{version}.tar.gz
27 source1: openxpki-deployment-susefiles.tar.gz
29 %description
30 OpenXPKI deployment and administration tools.
32 %prep
33 %setup -q -n %{pkgname}-%{version}
34 %setup -a 1
35 chmod -R u+w %{_builddir}/%{pkgname}-%{version}
37 %build
38 ./configure _CONFIGURE_ARGS_ -- \
39 --setcfg dir.sysconfdir=/etc \
40 --setcfg dir.openxpkiconfdir=%{instancedir}/%{instance} \
41 --setcfg dir.localstatedir=/var \
42 --setcfg server.pidfile=/var/run/openxpkid.pid \
43 --setcfg server.admgroup=openxpki \
46 # Debian used this (does not take into account %prefix properly)
47 # --setcfg dir.mandir=/usr/share/man \
48 # --setcfg dir.sysconfdir=/etc \
49 # --setcfg dir.openxpkiconfdir=%{instancedir}/%{instance} \
50 # --setcfg dir.localedir=/usr/share/locale \
51 # --setcfg dir.localstatedir=/var \
52 # --setcfg server.pidfile=/var/run/openxpkid.pid \
53 # --setcfg server.admgroup=openxpki \
56 %{__make}
58 %install
59 [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
60 DESTDIR=%{buildroot} make install
62 install -D -m 755 etc/init.d/openxpki %{buildroot}/etc/init.d/openxpki
63 install -D -m 644 etc/sysconfig/openxpki %{buildroot}/etc/sysconfig/openxpki
65 cmd=/usr/share/spec-helper/compress_files
66 [ -x $cmd ] || cmd=/usr/lib/rpm/brp-compress
67 [ -x $cmd ] && $cmd
69 # SuSE Linux
70 if [ -e /etc/SuSE-release -o -e /etc/UnitedLinux-release ]
71 then
75 # remove special files
77 # no empty directories
78 find %{buildroot}%{_prefix} \
79 -type d -depth \
80 -exec rmdir {} \; 2>/dev/null
82 %{__perl} -MFile::Find -le '
83 find({ wanted => \&wanted, no_chdir => 1}, "%{buildroot}");
84 print "%doc README\n";
85 print "%config /etc/sysconfig/openxpki";
86 for my $x (sort @dirs, @files) {
87 push @ret, $x unless indirs($x);
89 print join "\n", sort @ret;
91 sub wanted {
92 return if /auto$/;
93 return if /etc\/sysconfig\/openxpki$/;
95 local $_ = $File::Find::name;
96 my $f = $_; s|^\Q%{buildroot}\E||;
97 return unless length;
98 return $files[@files] = $_ if -f $f;
100 $d = $_;
101 /\Q$d\E/ && return for reverse sort @INC;
102 $d =~ /\Q$_\E/ && return
103 for qw|/etc %_prefix/man %_prefix/bin %_prefix/share|;
105 $dirs[@dirs] = $_;
108 sub indirs {
109 my $x = shift;
110 $x =~ /^\Q$_\E\// && $x ne $_ && return 1 for @dirs;
112 ' > %filelist
115 [ -z %filelist ] && {
116 echo "ERROR: empty %files listing"
117 exit -1
121 %pre
122 # find unused user/group id
123 id=60
124 while cut /etc/passwd -f3 -d: | egrep "^$id\$" >/dev/null || cut /etc/group -f3 -d: | egrep "^$id\$" >/dev/null ; do
125 id=$(($id + 1))
126 done
128 if ! cut -f1 -d: /etc/group | egrep "^openxpki\$" >/dev/null ; then
129 echo "Creating openxpki group ($id)" >&2
130 /usr/sbin/groupadd -g $id openxpki 2>/dev/null
134 if ! id openxpki >/dev/null 2>&1 ; then
135 echo "Creating openxpki user ($id)" >&2
136 /usr/sbin/useradd -c "OpenXPKI User" -r -s /bin/false -u $id -g $id -d /tmp openxpki 2>/dev/null
140 %post
141 export PATH=%{install_prefix}/bin:$PATH
142 # check for already configured trustcenter1
143 if [ -e %{instancedir}/%{instance}/openxpki.conf ]; then
144 echo "Detected an existing deployment (leaving it untouched)." >&2
145 else
146 install -d -m 750 -o root -g openxpki %{instancedir}/%{instance}
147 install -m 750 -o root -g openxpki %{install_prefix}/share/openxpki/templates/default/openxpki.conf %{instancedir}/%{instance}
148 echo -n "Deploying instance '%{instance}'... " >&2
149 openxpkiadm deploy -- --setcfg dir.openxpkiconfdir=%{instancedir}/%{instance} 2>>/var/log/messages
150 echo "DONE." >&2
151 cd %{instancedir}/%{instance}
152 echo -n "Configuring instance '%{instance}'... " >&2
153 openxpki-configure --batch --createdirs >>/var/log/messages
154 echo "DONE." >&2
157 %clean
158 [ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
160 %files -f %filelist
161 %defattr(-,root,root)
162 %config(noreplace) %attr(644,root,root) /etc/sysconfig/openxpki
164 %changelog
165 * Mon Nov 27 2006 m.bartosch@cynops.de
166 - Initial build.